GLBasic forum

Main forum => GLBasic - en => Topic started by: okee on 2009-Oct-26

Title: GENSPRITE() problem
Post by: okee on 2009-Oct-26
Having trouble with GENSPRITE() anytime i use it the program
builds but i get the message Start debug session.
but the program doesn't run
if i change GENSPRITE() to an actual number it runs fine
I might be overlooking something but right now i don't know what ...

Code (glbasic) Select


SETCURRENTDIR("Media") // seperate media and binaries?
GLOBAL sprPlayer = GENSPRITE()
LOADSPRITE "player.png",sprPlayer

GLOBAL Quit = 0
SETSCREEN 320,480,0
WHILE Quit <> 1

DRAWSPRITE sprPlayer,0,0
SHOWSCREEN
WEND
Title: Re: GENSPRITE() problem
Post by: MrTAToad on 2009-Oct-26
Certainly does - however : as mentioned elsewhere, RGB is the only command that can be used to initialise variables.  Any other command causes...problems...
Title: Re: GENSPRITE() problem
Post by: okee on 2009-Oct-26
It seems to work without the global declaration in debug/non debug and
running the executable file.
Title: Re: GENSPRITE() problem
Post by: MrTAToad on 2009-Oct-26
Yes, it would do..

GLOBAL sprPlayer = GENSPRITE()

and

sprPlayer = GENSPRITE()

are slightly different.  The first specificly defines the type of variable whilst the second would leave to the compiler, with the result that if its invalid for the area where you are defining the variable, you will get either warning or an error - it will only work if you don't enable explicit declarations.

It would be nice if the compiler could spot this sort of thing and stop compiling with an error or something (perhaps only if explicit declarations are on).
Title: Re: GENSPRITE() problem
Post by: FutureCow on 2009-Oct-27
I would like to see the compiler flag an error when declaring globals with a variable too!
Title: Re: GENSPRITE() problem
Post by: Kitty Hello on 2009-Oct-27
Yes, but that's really hard to program for me. I tried several times already :/