Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - hardyx

#451
In this case is more efficient to save the funcion result in a variable.   =D
#452
GLB supports this sentences. I think *= or <<= is more C-like than BASIC.
Code (glbasic) Select

INC var, 2      // var += 2
DEC var, 2      // var -= 2
INC var         // var++
DEC var         // var--

var = ASL(var, 2)    // var <<= 2
var = ASR(var, 2)    // var >>= 2


You can use too:

Code (glbasic) Select
INLINE
   var *= 2;
ENDINLINE

#453
GLBasic - en / Re: Piracy
2011-Jan-05
I'm not in iOS development, but I think you can check the binary or some data file with MD5 algorithm for detect if was modified. Then *the most important* don't say "you are a bad guy" (you give clues here), continue and disable little things in the app or game, or generate a div by 0 later in the code, or fail with a message ("cracked version, sorry") when you are in the last level or you want to save the records. This way you can't avoid a cracked version, but the differences are not obvious to the cracker. The crackers sometimes not complete the full game. But the cracker "clients", got frustrated when they discover that this cracked thing not works. If someone likes the game/app very much, he will go to buy legally.

#454
Off Topic / Re: Quick test
2010-Dec-05
xxx.xxx.xxx.xxx ES ESP Spain
works for me too.
#455
Off Topic / Re: web design
2010-Nov-29
I like the second design colours, its more readable and clear.
#456
IDE/Syntax / Re: IDE Request
2010-Nov-27
In the last version the IDE remeber the size of the output window. But I think that the output window margins are big for medium resolutions (1024x768). There is a space (+-10 pixels) between the text box and the window borders. In earlier versions (7.x?) this not happens.
#457
In the last version, you can use numeric C types like: short (signed), WORD (unsigned short), char (signed), BYTE (unsigned char), double (floating 64 bits). These types are case sensitive: Byte isn't the same as BYTE.

Code (glbasic) Select
LOCAL mapb[] AS BYTE  // works ok
DIM mapb[100]
mapb[0] = 123


QuoteIf I define a variable as a "char" I can't use the function "Readbyte" with it. Readbyte wants "DGNat", I want to use a char though
I think you can use a integer(%) variable for READBYTE, and then assign the value to a BYTE variable using this: byteval = (num%).  Curiously using () works ok =D.
#458
GLBasic - en / Re: CentOS 5
2010-Nov-18
You can try editing the platform.ini file in the Compiler\platform folder of GLBasic (make a copy first). Go to the [Linux] section and find the Gcc variable, then remove the flag -DHAVE_OPENGL. Rebuild the proyect for Linux. If you have luck the executable will work. If you use 2D only this can work.
#459
.var is good for me, thanks Gernot for trying.

@Crivens: Self represent the type (*this in c++ or Me in VB). I think your method is original, but very complex, and a hell for the compiler's programmer. The code may became difficult to maintain. GLBasic must be "BASIC", easy to read and intuitive language.
#460
Another alternative to the self can be putting only a point "." before the fields, like in VB. This may be used in the type functions/subs only. No need to define a WITH command. The precompiler can replace each ".var" for "self.var".

This code:
Code (glbasic) Select
if self.x > self.y then inc self.x

Can be written like this:
Code (glbasic) Select
if .x > .y then inc .x

#461
Quote from: Kitty Hello on 2010-Oct-18
To get the width of that string in pixels, use LEN(text$, bKerning%)
This LEN() function could be confuse with the length of a string. I suggest PIXLEN() or PXLEN() as names to inform that the result units are different.
#462
Quote from: Slydog on 2010-Nov-04
Looking at your code in 'gpc_tempg.cpp', does GLBasic just convert our constants into standard C++ variables?
How do normal C++ constants work?  Do they take up memory?  Or just used as a direct text replacement on compile time, using no extra memory?

If using constants takes memory, then what advantages do they have? 
GLOBALs would work the same but without these problems.
GLBasic converts constants in special variables that you can't write.

C++ constants take memory too. But they say the optimizer "hey, I can't change", and the constant is replaced for the value many times. You use constants when you want to keep the type of the value, or to write cleaner code.

With constants in GLBasic you are sure that you don't change it. And you can use Globals and Constants in other file too.
#463
But in my GLBasic code the constants are defined correctly. I know that the code generated can be different or optmized, but with the same effects as the source. If this is normal, then you can't use constants using other constants.
#464
I use some constants in my game, including simple constant expressions with other constants. Like this:

Code (glbasic) Select
CONSTANT SCR_WIDTH = 640
CONSTANT TSIDE = 32 // tile side
CONSTANT SCR_COLS = SCR_WIDTH / TSIDE


When I use the SCR_COLS constant in the code, I notice that the value is -1.INF (infinite). I was investigating the code generated and I saw this. When SCR_COLS is defined, TSIDE is initialized to 0. The correct value is set after, because the compiler "reorders" the constant lines :blink:

Code in gpc_tempg.cpp:
Code (glbasic) Select
void __glb_init_globals(){
    SCR_WIDTH= 640;
    SCR_COLS= SCR_WIDTH / TSIDE;    // TSIDE is 0!!
    TSIDE = 32;
}


If I define the constant with a value works ok.

Code (glbasic) Select
CONSTANT SCR_COLS = SCR_WIDTH / 32


I use the last GLBasic version 8.148, but I remember this (constant expressions) worked in a older version (8.0xx I think).
#465
You use a function that modify the type (instance) and returns another type. Then, in the calling code you assign the result to the same object. I can't imagine a real case that can be useful with this code. Is a good code for programming skill tests anyway. :)