Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef _PLAYER_HPP
- #define _PLAYER_HPP
- #include <globals.hpp>
- struct Player {
- SoundEffect* sfx_footstep = nullptr;
- SoundEffect* sfx_jumping = nullptr;
- SoundEffect* sfx_landing = nullptr;
- kit::shape::fpoint pos; //the player's CENTER position, in pixels
- kit::shape::fpoint vel; //how many pixels to move pos by
- kit::shape::fpoint acc; //how many pixels to change vel by
- kit::u32 ticksInAir = 0; //game ticks, which are 1/4 a frame long (approx. 4.1ms)
- kit::f32 runningState = 0.0f; //current animation frame when running
- bool gc_sfx = true; //'garbage collect sound effects?'
- bool facingRight = true;
- bool visible = true;
- bool enforceMaxVel = true;
- bool confused = false;
- bool jumped = false;
- bool footstep = false; //used to sync footstep sound effects
- char _[1];
- Player(kit::f32 startX = 0.0f, kit::f32 startY = 0.0f) : pos(startX, startY) {}
- ~Player(){
- if(gc_sfx){
- if(sfx_footstep) delete sfx_footstep;
- if(sfx_jumping ) delete sfx_jumping;
- if(sfx_landing ) delete sfx_landing;
- }
- }
- void blit(kit::f32 scaleX = 1.0f, kit::f32 scaleY = 1.0f);
- void update(); //advance animation by 1 frame
- bool queryFootstep(){ //resets the footstep flag after reading it
- bool state = footstep;
- footstep = false;
- return state;
- }
- };
- #endif /* _PLAYER_HPP */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement