a-game

2D platformer written from scratch.
git clone git://git.amin.space/a-game.git
Log | Files | Refs | README | LICENSE

input.c (606B)


      1 internal bool btn_is_down(u32 button_states, enum GameButton b)
      2 {
      3     assert(b < NUM_GAME_BUTTONS);
      4     bool result = button_states & (1 << b);
      5     return result;
      6 }
      7 
      8 internal bool btn_was_just_pressed(struct GameInput *game_input, enum GameButton b)
      9 {
     10     assert(game_input);
     11     assert(b < NUM_GAME_BUTTONS);
     12     bool result = game_input->button_downs & (1 << b);
     13     return result;
     14 }
     15 
     16 internal bool btn_was_just_released(struct GameInput *game_input, enum GameButton b)
     17 {
     18     assert(game_input);
     19     assert(b < NUM_GAME_BUTTONS);
     20     bool result = game_input->button_ups & (1 << b);
     21     return result;
     22 }