Computer Science Canada Flexible Arrays / Timers |
Author: | tjmoore1993 [ Tue Jul 14, 2009 11:58 pm ] | ||
Post subject: | Flexible Arrays / Timers | ||
Hello, I haven't been on in a long time. I have gotten' ideas from my old game and wanted to improve on it. I plan on though remaking it, which by all means would really make a difference. What I plan on doing is not ADDING DELAY! Delay stops the game, although it is a quick fix, so what I am doing is adding a timer system so I can have things working in the background. So far, I've sketched a rough draft of how my timers will work.
In this rough draft, I have demonstrated how my Timers will work. I have setup 2 records for my CHARACTER (TIME and TIMEUPDATE), these 2 are used to calculate whether or not you as the player have exceeded the delay or you are still waiting. By having a timer started when you press a key, there will be an if statement to check if TIME is greater then TIMEUPDATE + 1000. Lost? Well, when you update your time you will never return to 0 so here's how it works, every time you reached your delay, TIMEUPDATE will be assigned TIME's value so that the timer can be used when numbers get higher then 1000. Feel free to suggest any ways possible to get this smaller then it already is. |
Author: | andrew. [ Wed Jul 15, 2009 10:33 am ] | ||
Post subject: | RE:Flexible Arrays / Timers | ||
I didn't really read over your code thoroughly, but could you just do something like:
That would be a 10 ms delay because your code would run every 10 ms. |
Author: | DemonWasp [ Wed Jul 15, 2009 10:57 am ] |
Post subject: | RE:Flexible Arrays / Timers |
@andrew: Not necessarily, as that isn't guaranteed to be run every millisecond. Even if it was, Time.Elapsed has some error margins in its return. @TJ: I ran that and didn't see anything (and yes, I did replace the image path with one that exists). What am I supposed to see? In either case, the usual way of doing this kind of thing is to loop, determine how long it's been since you last dealt with input from a given player, and use that "interpolation" time to determine how much they've moved (or whatever else) since you last checked. |
Author: | tjmoore1993 [ Wed Jul 15, 2009 11:34 am ] |
Post subject: | Re: RE:Flexible Arrays / Timers |
DemonWasp @ Wed Jul 15, 2009 10:57 am wrote: @andrew: Not necessarily, as that isn't guaranteed to be run every millisecond. Even if it was, Time.Elapsed has some error margins in its return.
@TJ: I ran that and didn't see anything (and yes, I did replace the image path with one that exists). What am I supposed to see? In either case, the usual way of doing this kind of thing is to loop, determine how long it's been since you last dealt with input from a given player, and use that "interpolation" time to determine how much they've moved (or whatever else) since you last checked. The image was a bullet (arrow)... I am making another version of Fantastic Story, this one will include the job Pirate. The pirate is able to shoot rapid fire. So far, the AI for it is comming along, I am trying to figure out though how to make it so that monsters have their own characteristics efficiently. |
Author: | DemonWasp [ Wed Jul 15, 2009 4:51 pm ] |
Post subject: | RE:Flexible Arrays / Timers |
For having multiple units that share a common set of characteristics (all basic orcs / kobolds / trolls have the same stats...), I would use a design like this: Class 1 is MonsterDefinition, and it contains anything that you would find in a monster entry in a book. Does not contain its location or current status. Class 2 is Monster, which contains a reference (not a copy!) of its MonsterDefinition, as well as its location, current status, and AI state. Then, just keep a small library of MonsterDefinitions and you skip duplicating all that information. Beyond that, I don't know what you mean by "efficiently". |
Author: | andrew. [ Wed Jul 15, 2009 6:00 pm ] | ||
Post subject: | Re: RE:Flexible Arrays / Timers | ||
DemonWasp @ Wed Jul 15, 2009 10:57 am wrote: @andrew: Not necessarily, as that isn't guaranteed to be run every millisecond. Even if it was, Time.Elapsed has some error margins in its return. You could make it so it's in the range like this:
That way it goes +/- 2. But I agree, Time.Elapsed is inaccurate and it still may not work. It's just a simple and quick way of doing it. Also, if you are looking to be accurate and precise in your timing and stuff, why would you use Turing? Use a better language. |
Author: | corriep [ Wed Jul 15, 2009 10:42 pm ] |
Post subject: | Re: Flexible Arrays / Timers |
I think what you are going after is Time.DelaySinceLast (10), it will give a 10 second delay from to last time it was called. ie if your calculations take 3 ms it will only delay 7 ms, if your calculations took 15 ms it will delay 0 ms. I could be totally wrong though ![]() |
Author: | copthesaint [ Fri Jul 17, 2009 12:27 am ] | ||
Post subject: | Re: Flexible Arrays / Timers | ||
Lets make this very simple.
|
Author: | andrew. [ Fri Jul 17, 2009 3:30 pm ] | ||
Post subject: | Re: Flexible Arrays / Timers | ||
copthesaint @ Fri Jul 17, 2009 12:27 am wrote: Lets make this very simple.
That's prety much what I meant by my code although mine was simpler and not as good
![]() |