more game initialization
This commit is contained in:
parent
ee2e18db4d
commit
23f58602e2
18
src/game.d
18
src/game.d
@ -12,12 +12,20 @@ struct Player
|
||||
class Game
|
||||
{
|
||||
public:
|
||||
this()
|
||||
{
|
||||
for (int i = 0; i < NUM_PLAYERS; i++)
|
||||
{
|
||||
m_events[i] = new InputEventList();
|
||||
}
|
||||
}
|
||||
void change_player()
|
||||
{
|
||||
m_pindex ^= 1;
|
||||
}
|
||||
void handle_move_event(int type, bool active)
|
||||
{
|
||||
m_events[m_pindex].add_event(m_tick + 1, type, active);
|
||||
}
|
||||
void update(uint ms)
|
||||
{
|
||||
@ -25,14 +33,24 @@ public:
|
||||
{
|
||||
m_last_tick_ms += TICK_MS;
|
||||
m_tick++;
|
||||
uint min_tick = m_tick;
|
||||
for (int i = 0; i < NUM_PLAYERS; i++)
|
||||
{
|
||||
apply_tick(m_players[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Player[] get_players() { return m_players; }
|
||||
|
||||
protected:
|
||||
void apply_tick(Player p)
|
||||
{
|
||||
}
|
||||
|
||||
uint m_tick;
|
||||
uint m_last_tick_ms;
|
||||
Player[NUM_PLAYERS] m_players;
|
||||
InputEventList[NUM_PLAYERS] m_events;
|
||||
uint m_ticks[NUM_PLAYERS];
|
||||
int m_pindex;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user