GLBasic forum

Main forum => Tutorials => Topic started by: maverick2 on 2011-Mar-31

Title: I can't look sprites in the screen
Post by: maverick2 on 2011-Mar-31
I have a problem.
My first progras is for load an sprite and draw at screen, but it don't draw at screen :-(
The code is:
LOADSPRITE "mario.bmp", 1
DRAWSPRITE 1, 100, 100
SHOWSCREEN
MOUSEWAIT

When I compiling the code it's ok no problema Build sucessed , but the screen is Black and don't look the Sprite in the screen.
The sprite image is BMP format

anybody can help me ?
Thank's
Title: Re: I can't look sprites in the screen
Post by: backslider on 2011-Mar-31
Do you use the command
Code (glbasic) Select

SETCURRENTDIR("Media")

before?

If not, do it and put your image into the Project - "Media" folder.

cheers
Title: Re: I can't look sprites in the screen
Post by: maverick2 on 2011-Mar-31
Ahh
Ok
Thank You , Very Much
:-)
Title: Re: I can't look sprites in the screen
Post by: backslider on 2011-Mar-31
You´re welcome! ;)
Title: Re: I can't look sprites in the screen
Post by: MrTAToad on 2011-Apr-01
Or, even better, use :

Code (glbasic) Select
LOADSPRITE "Media/mario.bmp", 1
Title: Re: I can't look sprites in the screen
Post by: backslider on 2011-Apr-01
Why do you think it is better, MrTaToad? :)
It´s more text to write, when you have thousand of sprites *g*
Title: Re: I can't look sprites in the screen
Post by: XanthorXIII on 2011-Apr-01
Both methods work fine for what your needs are. I think giving it the path to the folder might be better so you know where that Sprite or file is coming from and so you don't have to run code to switch different folders when you need to load additional resources.
It's really more of a preference thing though.
Title: Re: I can't look sprites in the screen
Post by: MrTAToad on 2011-Apr-01
I dont like using SETDIRECTORY in case you have files in different directories from the one that you select.

It is quite possible (and legal) for the command to fail too...

QuoteIt´s more text to write, when you have thousand of sprites *g*
In that case you would use an array
Title: Re: I can't look sprites in the screen
Post by: maverick2 on 2011-Apr-04
I have a problema, i need writed 3 animations, but when i write for example
WHILE TRUE
cont=cont+1
if cont>10
s=1-s
cont=0
DRAW SPRITE s, 100,100
SHOWSCREEN
WEND

when compile my code then get this mesage (23) error : variable is not explicitly defined cont etc

can your help me?
Title: Re: I can't look sprites in the screen
Post by: backslider on 2011-Apr-04
Code (glbasic) Select

//if you have enabled "explicit variables" in the project options you have to DEFINE your variables before using as LOCAL or GLOBAL

LOCAL cont
LOCAL s

WHILE TRUE
cont=cont+1
if cont>10
s=1-s
cont=0
DRAW SPRITE s, 100,100
SHOWSCREEN
WEND
Title: Re: I can't look sprites in the screen
Post by: matchy on 2011-Apr-04
Just an additional note, regardless of what it does that code is missing ENDIF and DRAWSPRITE is one statement.

Title: Re: I can't look sprites in the screen
Post by: backslider on 2011-Apr-04
That´s right  :good:

Early in the morning  :whistle:
Title: Re: I can't look sprites in the screen
Post by: maverick2 on 2011-Apr-04
¿Where is the project options for define the variables?
Title: Re: I can't look sprites in the screen
Post by: Ian Price on 2011-Apr-04
Quote¿Where is the project options for define the variables?

PROJECT->  OPTIONS -> [ ] EXPLICIT DECLARATIONS (untick the box)

It is worth noting that if you turn them off, then spelling errors etc. in your variable names will not be identified, potentially causing you time to find where the mistakes are when something isn't working.
Title: Re: I can't look sprites in the screen
Post by: maverick2 on 2011-Apr-04
Ahh Ok Thank you

I'm sorry but I'm begginer at GLBASIC :-(, I saw



Title: Re: I can't look sprites in the screen
Post by: Ian Price on 2011-Apr-04
No need to apologise for being a beginner - we were all beginners once, and we are all still learning  :)

A forum without questions would be pretty boring.