Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. #ifndef FROG_H
  2. #define FROG_H
  3.  
  4. #include <SFML/Graphics.hpp>
  5.  
  6. class Frog : public sf::Drawable
  7. {
  8. public:
  9.     enum direction{u,d,l,r,none};
  10.  
  11. private:
  12.     float m_fJumpSpeed; //speed at which frog jumps
  13.     float m_fMoveDistance;
  14.     direction m_Dir; //direction frog is facing
  15.     sf::Sprite m_Sprite; //frog's sprite
  16.     sf::Texture m_FrogTexture; //frog's texture
  17.     sf::Texture m_DieTexture; //frog's death texture
  18.     void draw(sf::RenderTarget& target, sf::RenderStates states) const; //draw function inherited from sf::Drawable
  19.     bool m_bDead; //toggle to track whether the frog is alive or dead
  20.     sf::Clock m_FrogTimer; //frog's life timer
  21.     float m_fLaneSpeed; //speed at which frog moves due to lane speed
  22.  
  23. public:
  24.     //default constructor
  25.     Frog(){};
  26.  
  27.     //kills the frog and calls reset()
  28.     void die();
  29.  
  30.     //moves the frog and updates its animation frame
  31.     void updateFrog(sf::Time elapsedTime);
  32.  
  33.     //returns the bounding rectangle of the frog
  34.     sf::FloatRect getRect() const;
  35.  
  36.     //sets the frog's movedistance so that it moves on the next update
  37.     bool startMove(direction dir);
  38.    
  39.     //initialises the frog setting its jump speed and position with the passed parameters
  40.     void init(float fJumpSpeed, sf::Vector2f position);
  41.  
  42.     //returns true if the frog is dead, false otherwise
  43.     bool isDead() const;
  44.  
  45.     //resets the frog's position and timer
  46.     void reset();
  47.  
  48.     //sets the lanespeed of the frog to passed float 'fLaneSpeed'
  49.     void setLaneSpeed(float fLaneSpeed);
  50.  
  51.     //returns the time held by the m_FrogTimer
  52.     sf::Time getTime() const;
  53. };
  54.  
  55.  
  56. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement