Moving object with loops problem
Author |
Message |
bill_ion_boi
|
Posted: Wed Dec 01, 2004 9:05 pm Post subject: Moving object with loops problem |
|
|
Im in the process of creating a game and when i hold the right arrow my object moves but it leaves a trail of past images..Can anyone help?
Input.KeyDown (key)
if key (KEY_RIGHT_ARROW) then
loop
awidth := awidth + 1
Pic.ScreenLoad ("carright.bmp", awidth, aheight, picMerge)
delay (5)
exit
end loop
end if |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Neo
|
Posted: Wed Dec 01, 2004 9:10 pm Post subject: (No subject) |
|
|
You can use cls to clear the screen at the end of your loop and use
setscreen("offscreenonly") at the beginnning and View.Update at the end of your loop to stop flickering. |
|
|
|
|
|
Pinto2
|
Posted: Wed Dec 01, 2004 9:40 pm Post subject: (No subject) |
|
|
Just us cls just before end loop, and your set to go |
|
|
|
|
|
bill_ion_boi
|
Posted: Wed Dec 01, 2004 10:28 pm Post subject: (No subject) |
|
|
im sorry
i forgot to mention i have a background and thus cls would well u know... |
|
|
|
|
|
bill_ion_boi
|
Posted: Thu Dec 02, 2004 3:30 pm Post subject: (No subject) |
|
|
please help |
|
|
|
|
|
Cervantes
|
Posted: Thu Dec 02, 2004 4:26 pm Post subject: (No subject) |
|
|
Have patience. There is no need to spam your own thread, as Asian would say.
I assume you are looking for a way to erase and redraw just the foreground image, not the background. I have had no experience with Sprites, but I do know that Turing 4.x does not include sprites. You can try to use DanSprite if you want. That is if sprites help with this at all.
The easier way is to just use cls, as has been mentioned, twice. Yes, it erases the background. Just redraw it.
Also, the code you posted is a little ineffecient:
code: |
Input.KeyDown (key)
if key (KEY_RIGHT_ARROW) then
loop
awidth := awidth + 1
Pic.ScreenLoad ("carright.bmp", awidth, aheight, picMerge)
delay (5)
exit
end loop
end if
|
There is no need for the loop since it is going to exit the first time through no matter what (your exit statement has no condition). You can save three lines by eliminating the loop, exit, and end loop lines.
Finally, please use [ code] [ /code] tags when posting code. |
|
|
|
|
|
SuperGenius
|
Posted: Thu Dec 02, 2004 5:36 pm Post subject: (No subject) |
|
|
make sure that you read up fully on DanSprites before you use them, because there were some issues last time I checked. |
|
|
|
|
|
|
|