forums

TNT Basic Forums > Programming Q&A
Unexpected cut-off
< Last Thread     Next Thread >
Author
Thread        Post A Reply

04-25-2004 15:52

Posted by:
mark_667

Location:
England

Click Here to Email mark_667   Find more posts by mark_667

Hi,
I have a problem with thee following bit of code which I can't work out. Part way through (when switching control of the sprite from one loop to another), the sprite cuts off, the background disappears and you are returned to the main screen.

set image bank n,130
unload images 129

for image=0 to 3
draw picture 161
sprite n,x,y,image
line 150,40 to x,y
draw frame
x=x+XVelocity
y=y+YVelocity
next image

'Sprite cuts off here and returns to menu - WHY?

repeat
if image=3
sprite n,x,y,image 'When sprite 3 is reached move straight down only
draw frame
set sprite rotation 90,n'Rotate by 90 degrees
y=y+YVelocity
end if
until rotation=90

04-25-2004 16:30

Posted by:
philipp

Location:
Switzerland

Click Here to Email philipp   Find more posts by philipp

hi,
I've found the problem is in this line:

if image=3
...

the problem is that image hasn't got the value 3 at this moment, but it has the value 4 (try it) so there won't happen anything. Instead you could try this:

int image

image=0
while image<=3
.....
wend

'now image=3

repeat
if image=3
...
end if
until rotation=90

probably rotation has the value 90 before the repeat command, so it won't repeat and it seems that tntbasic cut off before it.

regards,
philipp

04-25-2004 16:35

Posted by:
philipp

Location:
Switzerland

Click Here to Email philipp   Find more posts by philipp

sorry I forgot:

image=0
while image<=3
...
if image=3
break
end if
image=image+1
wend

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.