Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Need some help

Author
Message
Steel
18
Years of Service
User Offline
Joined: 7th Apr 2006
Location:
Posted: 21st Apr 2006 14:53
I am rotating an image by making it a sprite and I want it to start when I press return. I tried

If Returnkey()=1

but that only allows it to rotate if it stays pressed. I and I want it to start rotating on the push of a button and stop on the push of differant button.
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 21st Apr 2006 15:41 Edited at: 21st Apr 2006 15:50
Why not put a while or until loop inside an if statement? In english it would read

if the return key is pressed then perform the rotation code until spacekey is pressed.

so.... you have your main do loop and the above inside

do

if Returnkey()=1
while SpaceKey()=0
rem rotate code goes here
sync
endwhile
endif

rem make sure to sync outside of the while loop
sync
loop


Now if you want to make your program neater and avoid nested loops and syncs then you can just have a variable called rotate and check once per loop if the start or stop key has been pressed and set rotate accordingly. It could be a boolean variable, or just use 0 for false and 1 for true.

rotate=0 ;rem this means initially rotate is false

do ; main loop

rem check user input
if returnkey()=1 then rotate=1
if spacekey()=1 then rotate=0

if rotate=1
rem rotate code goes here
endif

sync
loop

Login to post a reply

Server time is: 2024-11-27 21:48:26
Your offset time is: 2024-11-27 21:48:26