forums

TNT Basic Forums > Programming Q&A
Sprite not working!
< Last Thread     Next Thread >
Author
Thread        Post A Reply

03-24-2009 17:07

Posted by:
Teak

Location:
Victoria B.C. Canada

Click Here to Email Teak   Find more posts by Teak

I'm Making a game its going well but when added the code for setting a sprite to the mouse like this:

'...other int's
int mx=mouse x
int my=mouse y 'not inside loop

hide mouse

repeat

'...more code

mx=mouse x 'inside loop
my=mouse y
sprite 1,mx,my,1

'...more code

end

the sprite simply is not there.
It's not under any of the other sprites ether.
I don't get it! Why!

03-24-2009 18:43

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Are you calling 'Draw Frame" ?

You need to call 'draw frame' within your draw loop to update the graphics, this sounds like the most likely explanation.

Danny (nod the mod)

03-24-2009 22:48

Posted by:
Teak

Location:
Victoria B.C. Canada

Click Here to Email Teak   Find more posts by Teak

Yes!

Of course I use the Draw Frame command. Who doesn't!
And I know its in the loop! I'm not that stupid!

03-26-2009 09:30

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Calm down Nods...

quote:
Of course I use the Draw Frame command. Who doesn't!
And I know its in the loop! I'm not that stupid!
- Rude?

OK, despite the tone I will continue... Your listing was not the most informative of things, and the code you did post was correct. As you omitted the 'draw frame' call from the listing I thought I'd check. As the developer of TNT2 and the sole moderator on these boards it's my job to suggest possible solutions to problems, and from the limited information available I suggested the most likely.

As this is obviously not the problem, it may be an issue with the co-ordinate updates while the mouse is hidden.

Try this...

hide mouse

repeat

'...more code

show mouse
sprite 1, x mouse, y mouse, 1
hide mouse

'...more code

draw frame

until exit_condition=true

end


If this doesn't work you will need to post a more complete listing in order for me to track down the problem...

Danny (nod the mod)

03-26-2009 19:30

Posted by:
Teak

Location:
Victoria B.C. Canada

Click Here to Email Teak   Find more posts by Teak

Sorry

Sorry for being rude but where I put in "more code" it was supposed to tell you that I had lots of other code that was working.

Anyway I tried your code and tnt thinks that "x" and "mouse" were variables that weren't declared and when I tried just showing and hiding the mouse (leaving every thing else the same) the mouse flickered on and off.
Are you sure you meant "sprite 1, x mouse, y mouse, 1"?

Do you want me to post all the code? (it's vary long)

03-26-2009 21:48

Posted by:
JHVipond

Location:
South Dakota

Find more posts by JHVipond

I think Danny meant "mouse x, mouse y" rather than "x mouse, y mouse".

03-26-2009 23:31

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Oops... My Bad!

Yes, that should have been 'mouse x, mouse y'...

Danny (nod the mod)

03-27-2009 17:40

Posted by:
Teak

Location:
Victoria B.C. Canada

Click Here to Email Teak   Find more posts by Teak

I tried that too!

I tried all of the following:

show mouse
mx=mouse x
my=mouse y
sprite 1,mx,my,1
hide mouse

show mouse
sprite 1,x mouse,y mouse,1
hide mouse

show mouse
sprite 1,mouse x,mouse y,1
hide mouse

sprite 1,mouse x,mouse y,1

none of it worked.

03-29-2009 03:27

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

Make an empty program that only displays the sprite. Does it work? If it does then just add to it gradually by copying code until it doesn't work. Then you've found the problem.

03-30-2009 22:49

Posted by:
Teak

Location:
Victoria B.C. Canada

Click Here to Email Teak   Find more posts by Teak

Fixed it!

I fixed it! I don't know why it wasn't working before put I will show you what I did:

start: 'so that I can reset the program

int mx=mouse x
int my=mouse y
int sx=100
int sy=100 'and lots more vars for other sprites

sprite 1,sx,sy,1 'not in loop
sprite 2,mx,my,2 'this wasn't there. when I added it itworked!

repeat

mx=mouse x
my=mouse y
sprite 2,mx,my,2

sprite 1,sx,sy,1

if blablabla happens
goto start
end if

until something=1

03-31-2009 17:40

Posted by:
Maxime

Location:
Paris France

Find more posts by Maxime

Suggestion

Excuse me, TEAK, if you already... Please, don't be rude !

Did you add :
"window (or graphics) mode x, y"
AND
"load images 128" 'so the images are known

at the beginning of the prog ?

04-06-2009 22:16

Posted by:
Teak

Location:
Victoria B.C. Canada

Click Here to Email Teak   Find more posts by Teak

Yes

Yes at the start of the program there are all of the following:

graphics mode 550,400
load images 128
load sounds 128
VBL sync on
set framerate 60

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.