forums

TNT Basic Forums > Programming Q&A
Odd problem with screen not clearing
< Last Thread     Next Thread >
Author
Thread        Post A Reply

07-16-2004 05:59

Posted by:
Freefall

Click Here to Email Freefall   Find more posts by Freefall

I started using TNT Basic today, and I decided today to write a particle engine.
Now, I have run into a few problems:
1) When I call "Draw Text ..." and print the number of particles to the screen, it prints the text ok but doesn't remove it for the next frame. This rapidly ends up with two white rectangles where the letters should be because it isn't removing the text before it puts more on top.

2) A similar problem I guess: When I kill a particle, it stops moving but wont go away. I have used "Sprite Off ..." to remove it, but even though it shouldn't be there, it is getting rendered anyway. Once I re-allocate that space in the array for a new particle it disapears though, so it seems like "Sprite Off" simply isnt removing the sprite from the screen like it says.

I am pretty sure that I must be doing something silly in my code, but I'll be damned if I can see what it is.

07-16-2004 07:36

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

You have to erase the text yourself; the draw text command won't erase it for you. You can use fill rect to color the area where the text was drawn.

As for the sprite problem: does your game loop run through the array and set the sprites' coordinates? If so, the sprites will just get turned back on, unless you record in an array which sprites are dead and not call the sprite function for them. If that's not it, maybe you could post the code.

07-16-2004 07:36

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

And welcome to the community. :)

07-16-2004 08:01

Posted by:
Freefall

Click Here to Email Freefall   Find more posts by Freefall

Thanks for the tip about the text. The reason for the sprites staying there must be something to do with me turning off the wrong sprite of not removing it from the array correctly or something, because they do disapear when it gets revived as a new particle.

I'm gonna try re-writing it and see if that helps.

07-16-2004 08:33

Posted by:
Freefall

Click Here to Email Freefall   Find more posts by Freefall

Cool, the Fill Rect thing fixes the text problem.

Another unrelated question now: How do I use random? I know how to use it and all, but it doesn't seem to generate random numbers; even if I re-seed it every time I call it. I'm sure that isn't right.

07-16-2004 09:19

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Hrm. What do you mean it isn't working? The numbers are predicatable?

07-16-2004 12:52

Posted by:
Fischgurkensenf

Location:
Bern, Switzerland

Click Here to Email Fischgurkensenf   Find more posts by Fischgurkensenf

You use random like this:

random(m,n)

where m is the minimum of the generated number and n ist the maximum.

random(15,20)
generates a random number between 15 and 20.

random(3.000,9.000)
generates a number between 3.000 and 9.000.

07-16-2004 13:09

Posted by:
Fischgurkensenf

Location:
Bern, Switzerland

Click Here to Email Fischgurkensenf   Find more posts by Fischgurkensenf

to the 2nd question:
2) A similar problem I guess: When I kill a particle, it stops moving but wont go away. I have used "Sprite Off ..." to remove it, but even though it shouldn't be there, it is getting rendered anyway. Once I re-allocate that space in the array for a new particle it disapears though, so it seems like "Sprite Off" simply isnt removing the sprite from the screen like it says.

if you're using a code similar to this:

for n=0 to particlenumbers

if the sprite is on the screen:
change position and speed of the nth particle
end if
draw the nth particle on the screen with the "sprite"command a the particle's cordinates
if the sprite is too old then remove it with the "sprite off n" command

next n

add every 10th frame(for example) a new particle


then the problem is, that the killed particle (for example number 12) again gets drawed in the next frame (when n is equal to 12).

Please try to understand me, my english isn't very good, because i'm from switzerland and 14 years old.

07-18-2004 23:19

Posted by:
Mark Tully

Location:
TNT HQ, England

Click Here to Email Mark Tully   Find more posts by Mark Tully

Are you sure you're calling 'Draw Frame' every frame? If you do a 'Sprite Off' the results won't appear on screen until the next time 'Draw Frame' is called.

Mark

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.