I can't look sprites in the screen

Previous topic - Next topic

maverick2

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

backslider

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

maverick2

Ahh
Ok
Thank You , Very Much
:-)

backslider


MrTAToad

Or, even better, use :

Code (glbasic) Select
LOADSPRITE "Media/mario.bmp", 1

backslider

Why do you think it is better, MrTaToad? :)
It´s more text to write, when you have thousand of sprites *g*

XanthorXIII

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.
Owlcat has wise

MrTAToad

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

maverick2

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?

backslider

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

matchy

Just an additional note, regardless of what it does that code is missing ENDIF and DRAWSPRITE is one statement.


backslider

That´s right  :good:

Early in the morning  :whistle:

maverick2

¿Where is the project options for define the variables?

Ian Price

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.
I came. I saw. I played.

maverick2

Ahh Ok Thank you

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