I want to develop it into something useful for anyone wanting to create games.
I also want it to be bug free and unproblematic as I develop it.
So I made it very simple to start with, even though it's probably not the way most game makers would want it to run.
So,
I'd really appreciate all constructive criticism and also ideas on modifying or expanding it. (I'll put the code below)
I want to make a note:
For a game/game engine you obviously need game specific event handlers, since different games will do different things.
So in it's current simple state, the OnEvent() function will call the appropriate game specific event handlers to handle the events.
OnEvent() basically gets the event, then selects which game specific handler to call and calls it passing some or all of the event data as parameter/s.
I also keep track of KeyDown.
and raise my 1st question
Should I keep track of the state of the keyboard keys, but only call the game specific HandleKeys() function once per game loop?
What is appropriate for a game? and what are the reasons?
I know that joystick events only occur once per loop anyway.
And I'm pretty sure that I should leave Mouse events as instant rather than maintaining a state of buttons and then calling a game specific mouse handler once per game cycle. Because we could miss mouse clicks if the button gets released before the handler is called during each loop. But, at the same time, should I keep track of the state of the mouse buttons like I do with the keyboard?
(I hope I'm not being too confusing)
A typical game loop may look something like this:
Code: Select all
while (device->run())
{
HandleKeys();
HandleJoystick();
GameCycle();
GamePaint();
}
Or it can be done directly as in my code.
Any opinions or advice, please explain your reasons, especially if you have experience making or attempting to make games.
I'll post the code next...