killertypo/seed — Issue #13: Timed events
Author: killertypo
Created: 2011-10-20 22:37:18+00:00
State: open
Labels: Engine Logic, Game Logic

We need a way to key events based on time. I think our game engine needs to keep track of time and cache it at the start of each render/frame.

Like

GameEngine::GetTime()

That will return the time in Milis as well as update a static LONGLONG that points to the current time.

Then I can lets say on game go, hey has 5 seconds elapsed since the last time i checked (keeping track of my own internal time from the last time a frame was rendered)

If so then do something !

So GameEngine::GetTime(bool) (currently have Time::GetTime() will be easy enough to stuff that into the game). The bool will true update cache, or false just returns what's been cached .

Then in GameLogic::EventTriggers

we can do something like

if (GameEngine::GetTime(false) - GameLogic::EventTrigger::Time() > 5000 )
// Do something because 5 seconds has passed since our triggers time

We also need a way to keep track of event triggers like this, they can be character specific - like if you stand idle for too long. Dungeon specific (after 10 minutes of being in a dungeon all monsters become stronger, but i doubt we'll do that, just an example). Auto pause if no input is detected...etc

Then there are EventTriggers that happen because of other things in the game, but I'm not too worried about those at the moment. that's more on the game logic side of things.