Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef FROG_H
- #define FROG_H
- #include <SFML/Graphics.hpp>
- class Frog : public sf::Drawable
- {
- public:
- enum direction{u,d,l,r,none};
- private:
- float m_fJumpSpeed; //speed at which frog jumps
- float m_fMoveDistance;
- direction m_Dir; //direction frog is facing
- sf::Sprite m_Sprite; //frog's sprite
- sf::Texture m_FrogTexture; //frog's texture
- sf::Texture m_DieTexture; //frog's death texture
- void draw(sf::RenderTarget& target, sf::RenderStates states) const; //draw function inherited from sf::Drawable
- bool m_bDead; //toggle to track whether the frog is alive or dead
- sf::Clock m_FrogTimer; //frog's life timer
- float m_fLaneSpeed; //speed at which frog moves due to lane speed
- public:
- //default constructor
- Frog(){};
- //kills the frog and calls reset()
- void die();
- //moves the frog and updates its animation frame
- void updateFrog(sf::Time elapsedTime);
- //returns the bounding rectangle of the frog
- sf::FloatRect getRect() const;
- //sets the frog's movedistance so that it moves on the next update
- bool startMove(direction dir);
- //initialises the frog setting its jump speed and position with the passed parameters
- void init(float fJumpSpeed, sf::Vector2f position);
- //returns true if the frog is dead, false otherwise
- bool isDead() const;
- //resets the frog's position and timer
- void reset();
- //sets the lanespeed of the frog to passed float 'fLaneSpeed'
- void setLaneSpeed(float fLaneSpeed);
- //returns the time held by the m_FrogTimer
- sf::Time getTime() const;
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement