Advertisement
Kitomas

player.hpp as of 2024-03-21

Mar 21st, 2024
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #ifndef _PLAYER_HPP
  2. #define _PLAYER_HPP
  3.  
  4. #include <globals.hpp>
  5.  
  6.  
  7.  
  8.  
  9.  
  10. struct Player {
  11.   kit::shape::fpoint pos; //the player's CENTER position, in pixels
  12.   kit::shape::fpoint vel; //how many pixels to move pos by
  13.   kit::shape::fpoint acc; //how many pixels to change vel by
  14.  
  15.   kit::u32 ticksInAir = 0; //game ticks, which are approx. 4.1ms
  16.  
  17.   kit::f32 runningState = 0.0f; //current animation frame when running
  18.  
  19.   bool facingRight   = true;
  20.   bool visible       = true;
  21.   bool enforceMaxVel = true;
  22.   bool confused      = false;
  23.   bool jumped        = false;
  24.   bool footstep      = false; //used to sync footstep sound effects
  25.  
  26.   char _[2];
  27.  
  28.  
  29.   Player(kit::f32 startX = 0.0f, kit::f32 startY = 0.0f) : pos(startX, startY) {}
  30.  
  31.  
  32.   void blit(kit::f32 scaleX = 1.0f, kit::f32 scaleY = 1.0f);
  33.  
  34.   void update(); //advance animation by 1 frame
  35.  
  36.   bool queryFootstep(){ //resets the footstep flag after reading it
  37.     bool state = footstep;
  38.     footstep = false;
  39.     return state;
  40.   }
  41. };
  42.  
  43.  
  44.  
  45.  
  46.  
  47. #endif /* _PLAYER_HPP */
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement