LOOP help!
Author |
Message |
smit9192
|
Posted: Sun Jan 28, 2007 5:02 pm Post subject: LOOP help! |
|
|
hi guys
i REALLY need HELP!!!! ASAP in ending LOOP
i have created a power bar ---
a box constantly goes left to right and then left to right again (infinetly)
i want it to stop when i press "y" / any other key (doesnt really matter)
HOW DO I GO ABOUT DOING IT!?!?!?!?!?!?
i would really appriciate ur time and help
this is currently my program:
%Powerbar
var a:int:=55
var aa:int:=65
Draw.Line (50,25,750,25,black)
loop
Draw.FillBox (a,15,aa,35,green)
a:=a+10
aa:=aa+10
delay (10)
if aa>=750 then
Draw.FillBox (0,0,800,40,white)
Draw.Line (50,25,750,25,black)
a:=55
aa:=65
end if
end loop |
|
|
|
|
|
Sponsor Sponsor
|
|
|
CodeMonkey2000
|
Posted: Sun Jan 28, 2007 5:07 pm Post subject: RE:LOOP help! |
|
|
Look up input.keydown. And please use code tas. |
|
|
|
|
|
smit9192
|
Posted: Sun Jan 28, 2007 6:46 pm Post subject: Re: LOOP help! |
|
|
OH.. i will def. check it out THANK YOU spearmonkey2000 |
|
|
|
|
|
zedx_26
|
Posted: Mon Jan 29, 2007 3:59 pm Post subject: RE:LOOP help! |
|
|
if you think then all you have to do is exit loop when some one presses any key so, try this.
code:
if hasch then
exit
end if
put this code in your program any where |
|
|
|
|
|
Bored
|
Posted: Mon Jan 29, 2007 6:22 pm Post subject: Re: LOOP help! |
|
|
zedx_26 wrote:
if you think then all you have to do is exit loop when some one presses any key so, try this.
code
if hasch then
exit
end if
put this code in your program any where
That can be reduced to one line there zedx:
Aswell generally you would want this placed at the end of the loop, or beginning just incase it causes anything funny to happen.
Also if you would like it to run only on one key, such as 'y', we can add to that code.
The reason you need to leave the hasch in there is that if you don't then the computer will run getchar even if no key is pressed, this will cause the program to stop and wait for input whereas if you place the haschh infront it will only evaluate the second half if hasch returns true. That means it will only run getchar when there is already a character waiting, thus not stopping the program. This also means the hasch must be placed before getchar or it will not work. |
|
|
|
|
|
|
|