|
Post by OddChild on Sept 6, 2006 22:25:51 GMT -5
Many times, a sleep command works better than a timer... For example doing a dialog in a game. Have an action occur, then sleep 2000MS or so... While in sleep mode, it would be good if it wouldnt stop the ability to exit.
|
|
|
Post by Guilect on Sept 7, 2006 6:58:36 GMT -5
Hello Oddchild,
There exists the 'system.pause' command.
Does this not do what you want?
|
|
|
Post by OddChild on Sept 9, 2006 16:45:35 GMT -5
it does... but unlike the sleep command in many other languages... it disables exit. so a user cannot exit... it would temporarily freeze the program.
unrelated: what macros are there?
we need some more like
@programdir @startmenu etc...
|
|
|
Post by Guilect on Sept 10, 2006 9:52:02 GMT -5
In Brutus2D the pause command does just that, it pauses the program execution for a certain amount of time.
e.g.
do while bRunning = True if key.pressed(1) or key.pressed(0) = True then bRunning = False graphics.clear Rnd * 255 graphics.display system.pause 5000 loop
This code segment example above draws a colored window every 5 seconds. While Brutus2D is stepping through the code it stays on the pause line for the 5 seconds then continues through the loop processing each line of code. While on the system.pause line, pressing the escape key will have no effect. Only when Brutus is executing the key.keypress line will the escape key status be looked at. This is normal.
if you want to be able to to escape out of a delay then I would recommend what you probably have already done and that is to code it that way.
option explicit
dim bRunning bRunning = True
sub main()
if (graphics.initialize <> True) then exit sub graphics.setTitle "Demo - Pause - press [ESC] to exit" key.initialize
do while bRunning = True if key.pressed(1) or key.pressed(0) = True then bRunning = False graphics.clear Rnd * 255 graphics.display 'system.pause 5000 mypause(5000) loop key.terminate graphics.terminate
end sub
sub mypause(howlong) dim starttime starttime = system.gettime Do While (system.gettime - starttime) < howlong If key.pressed(1) or key.pressed(0) = True then exit sub Loop end sub
Call Main()
I do not think that the pause command should have any different behavior. For example you might make a shareware game that pops up a splash screen reminding people to buy it. And you want the screen to stay up for 10 seconds without the user being able to skip by it by pressing the escape key.
Perhaps I could add a new command (sleep?) that could be aborted on an escape key or window 'X' press event.
|
|
|
Post by OddChild on Sept 11, 2006 0:58:45 GMT -5
that would be neat... with autoit there is a wait for event type of function... wait for kepress etc... that would be useful.
|
|