1. Timer
- Posted by Chris Saik <csaik2002 at yahoo.com> Oct 01, 2002
- 457 views
Hello all, I am writing a text-based game in DOS32 and am trying to determine the best way to simulate real time. For instance, in my game each action that the character does takes a specified amount of time -- walking (ft per second), firing a weapon (number of shots per second, reload time), etc, for added realism. I am considering using a global timing procedure that will execute commands entered by the user (currently via keyboard) and display the results of those commands every tick of the clock, if applicable. If the user sits there and does nothing, then time will continue to pass allowing opponents within the game to reposition themselves, take cover, reload, etc. My question is, what in your opinion is the best way to accomplish the timing procedure?
2. Re: Timer
- Posted by Robert Craig <rds at RapidEuphoria.com> Oct 01, 2002
- 432 views
Chris Saik writes: > My question is, what in your opinion is the best way > to accomplish the timing procedure? You should take a look at sched.e in euphoria\demo\langwar. It manages several independent "tasks" using cooperative multitasking. A centralized scheduler maintains a list of tasks (procedures) along with the next time that they should be activated. Even when a phasor is quickly drawn across the screen, there's an opening every .01 seconds for another task to get in and do something. Occasionally you'll see multiple phasors or torpedos drawn simultaneously, along with a planet exploding, the "Euphoria" ship moving etc. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: Timer
- Posted by Chris Saik <csaik2002 at yahoo.com> Oct 02, 2002
- 440 views
Thanks Rob! --- Robert Craig <rds at RapidEuphoria.com> wrote: > > Chris Saik writes: > > My question is, what in your opinion is the best > way > > to accomplish the timing procedure? > > You should take a look at sched.e > in euphoria\demo\langwar. It manages several > independent "tasks" using cooperative multitasking. > A centralized scheduler maintains a list of tasks > (procedures) > along with the next time that they should be > activated. > Even when a phasor is quickly drawn across the > screen, > there's an opening every .01 seconds for another > task > to get in and do something. Occasionally you'll see > multiple phasors or torpedos drawn simultaneously, > along with a planet exploding, the "Euphoria" ship > moving etc. > > Regards, > Rob Craig > Rapid Deployment Software > http://www.RapidEuphoria.com > > > > > >
4. Timer
- Posted by "Michelle Rogers" <michellerogers at bellsouth.net> Jun 27, 2004
- 444 views
What stupid thing am I missing? I've done timers before...but for some reason, I can't get this one to work tonight (heh..probably too sleepy)...I've even taken it out of the code i'm working with and reduced it to just a skeleton timer code ..which is as follows.... without warning include win32lib.ew constant dummywin=create(Window,"A Timer",0,0,0,300,300,0), dummytext=create(LText,"Beginning text",dummywin,10,10,100,40,0) integer mytimer,timerint timerint=0 mytimer=-1 global procedure onOpen_dummywin() warnErr("open") setText(dummytext,"It's open") setTimer(dummywin,mytimer,1000) end procedure global procedure onTimer_dummywin(object val) timerint=timerint+1 setText(dummytext,"Timer: "&sprint(timerint)) end procedure WinMain(dummywin,Normal) onOpen[dummywin]=routine_id("onOpen_dummywin") onTimer[dummywin]=routine_id("onTimer_dummywin") Actually, though, on second thought..it's not the timer that's not working..it's the onOpen that isn't working....why would the onOpen not trigger in this case? Michelle Rogers ----- Original Message ----- From: "cklester" <guest at RapidEuphoria.com> To: <EUforum at topica.com> Sent: Sunday, June 27, 2004 12:53 AM Subject: OpenGL GUI > > > posted by: cklester <cklester at yahoo.com> > > There's a package called GLUI User Interface Library. It's an OpenGL GUI > package. > > The source is available here: http://www.nigels.com/glt/glui/#download > > I can't use those files as given, so I was hoping somebody > could compile it all into a .dll for me (to be used on Windows) and > maybe provide a list of all the functions. > > Thank you. :) > > -=ck > "Programming in a state of EUPHORIA." > > > >
5. Re: Timer
- Posted by "Greg Haberek" <ghaberek at wowway.com> Jun 27, 2004
- 430 views
I can't stress this enough..... use setHandler(). That's the first thing that's wrong, but not the problem. Try using a positive integer for 'mytimer' instead of -1. That's probably the problem. ~Greg ----- Original Message ----- From: "Michelle Rogers" <michellerogers at bellsouth.net> To: <EUforum at topica.com> Sent: Sunday, June 27, 2004 12:56 AM Subject: Timer > > > What stupid thing am I missing? I've done timers before...but for some > reason, I can't get this one to work tonight (heh..probably too > sleepy)...I've even taken it out of the code i'm working with and reduced it > to just a skeleton timer code ..which is as follows.... > > without warning > include win32lib.ew > > constant > dummywin=create(Window,"A Timer",0,0,0,300,300,0), > dummytext=create(LText,"Beginning text",dummywin,10,10,100,40,0) > > > integer mytimer,timerint > timerint=0 > mytimer=-1 > > global procedure onOpen_dummywin() > warnErr("open") > setText(dummytext,"It's open") > setTimer(dummywin,mytimer,1000) > end procedure > > global procedure onTimer_dummywin(object val) > timerint=timerint+1 > setText(dummytext,"Timer: "&sprint(timerint)) > end procedure > > WinMain(dummywin,Normal) > > onOpen[dummywin]=routine_id("onOpen_dummywin") > onTimer[dummywin]=routine_id("onTimer_dummywin") > > > Actually, though, on second thought..it's not the timer that's not > working..it's the onOpen that isn't working....why would the onOpen not > trigger in this case? > Michelle Rogers > ----- Original Message ----- > From: "cklester" <guest at RapidEuphoria.com> > To: <EUforum at topica.com> > Sent: Sunday, June 27, 2004 12:53 AM > Subject: OpenGL GUI > > > > posted by: cklester <cklester at yahoo.com> > > > > There's a package called GLUI User Interface Library. It's an OpenGL GUI > > package. > > > > The source is available here: http://www.nigels.com/glt/glui/#download > > > > I can't use those files as given, so I was hoping somebody > > could compile it all into a .dll for me (to be used on Windows) and > > maybe provide a list of all the functions. > > > > Thank you. :) > > > > -=ck > > "Programming in a state of EUPHORIA." > > > > > > >
6. Re: Timer
- Posted by "Michelle Rogers" <michellerogers at bellsouth.net> Jun 27, 2004
- 421 views
why use setHandler? and the number isn't the problem, because it's not even triggering the onOpen event...the "warnErr" doesn't even trigger. Michelle Rogers ----- Original Message ----- From: "Greg Haberek" <ghaberek at wowway.com> To: <EUforum at topica.com> Sent: Sunday, June 27, 2004 1:26 AM Subject: Re: Timer > > > I can't stress this enough..... use setHandler(). That's the first thing > that's wrong, but not the problem. Try using a positive integer for > 'mytimer' instead of -1. That's probably the problem. > > ~Greg > > ----- Original Message ----- > From: "Michelle Rogers" <michellerogers at bellsouth.net> > To: <EUforum at topica.com> > Sent: Sunday, June 27, 2004 12:56 AM > Subject: Timer > > > > What stupid thing am I missing? I've done timers before...but for some > > reason, I can't get this one to work tonight (heh..probably too > > sleepy)...I've even taken it out of the code i'm working with and reduced > it > > to just a skeleton timer code ..which is as follows.... > > > > without warning > > include win32lib.ew > > > > constant > > dummywin=create(Window,"A Timer",0,0,0,300,300,0), > > dummytext=create(LText,"Beginning text",dummywin,10,10,100,40,0) > > > > > > integer mytimer,timerint > > timerint=0 > > mytimer=-1 > > > > global procedure onOpen_dummywin() > > warnErr("open") > > setText(dummytext,"It's open") > > setTimer(dummywin,mytimer,1000) > > end procedure > > > > global procedure onTimer_dummywin(object val) > > timerint=timerint+1 > > setText(dummytext,"Timer: "&sprint(timerint)) > > end procedure > > > > WinMain(dummywin,Normal) > > > > onOpen[dummywin]=routine_id("onOpen_dummywin") > > onTimer[dummywin]=routine_id("onTimer_dummywin") > > > > > > Actually, though, on second thought..it's not the timer that's not > > working..it's the onOpen that isn't working....why would the onOpen not > > trigger in this case? > > Michelle Rogers > > ----- Original Message ----- > > From: "cklester" <guest at RapidEuphoria.com> > > To: <EUforum at topica.com> > > Sent: Sunday, June 27, 2004 12:53 AM > > Subject: OpenGL GUI > > > > > > > posted by: cklester <cklester at yahoo.com> > > > > > > There's a package called GLUI User Interface Library. It's an OpenGL GUI > > > package. > > > > > > The source is available here: http://www.nigels.com/glt/glui/#download > > > > > > I can't use those files as given, so I was hoping somebody > > > could compile it all into a .dll for me (to be used on Windows) and > > > maybe provide a list of all the functions. > > > > > > Thank you. :) > > > > > > -=ck > > > "Programming in a state of EUPHORIA." > > > > > > > > >
7. Re: Timer
- Posted by Jonas Temple <jtemple at yhti.net> Jun 27, 2004
- 430 views
Michelle, I think the problem is you've got your onOpen[] and onTime[] AFTER the call to WinMain. This means the event handler is not set until WinMain returns, which is at the end of the program. Jonas > > > > > > without warning > > > include win32lib.ew > > > > > > constant > > > dummywin=create(Window,"A Timer",0,0,0,300,300,0), > > > dummytext=create(LText,"Beginning text",dummywin,10,10,100,40,0) > > > > > > > > > integer mytimer,timerint > > > timerint=0 > > > mytimer=-1 > > > > > > global procedure onOpen_dummywin() > > > warnErr("open") > > > setText(dummytext,"It's open") > > > setTimer(dummywin,mytimer,1000) > > > end procedure > > > > > > global procedure onTimer_dummywin(object val) > > > timerint=timerint+1 > > > setText(dummytext,"Timer: "&sprint(timerint)) > > > end procedure > > > These should be here: onOpen[dummywin]=routine_id("onOpen_dummywin") onTimer[dummywin]=routine_id("onTimer_dummywin") > > > WinMain(dummywin,Normal) > > > Not here: > > > onOpen[dummywin]=routine_id("onOpen_dummywin") > > > onTimer[dummywin]=routine_id("onTimer_dummywin") > > > > > >
8. Re: Timer
- Posted by "Greg Haberek" <ghaberek at wowway.com> Jun 27, 2004
- 457 views
> I think the problem is you've got your onOpen[] and onTime[] AFTER the > call to WinMain. This means the event handler is not set until WinMain > returns, which is at the end of the program. I just noticed that, too. You need to call WinMain() last. You need to get in the habit of using setHandler() because soon Derek will phase out the onXXX[] handler system all together. setHandler() is much nicer, too. It allows you to have multiple handlers for the same event, or one handler for multiple events or multiple controls.
-- begin example code -- include Win32Lib.ew constant MyWin1 = create( Window, "MyWin", 0, Center, Center, 400, 300, 0 ), Btn1 = create( PushButton, "Button 1", MyWin1, 10, 10, 90, 30, 0 ), Btn2 = create( PushButton, "Button 2", MyWin1, 110, 10, 90, 30, 0 ) procedure MyGenericHandler( integer pSelf, integer pEvent, sequence pParams ) if pEvent = w32HOpen then if pSelf = MyWin1 then -- do open stuff here end if elsif pEvent = w32HClick then if pSelf = Btn1 then -- do Button 1 stuff here elsif pSelf = Btn2 then -- do Button 2 stuff here end if end if end procedure setHandler( MyWin1, w32HOpen, routine_id("MyGenericHandler") ) setHandler( {Btn1, Btn2}, w32HClick, routine_id("MyGenericHandler") ) WinMain( MyWin1, Normal ) -- end example code --