Advertisement
thecplusplusguy

Simple sidescroller game - player.h

Jul 14th, 2011
1,950
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. //This example program is created by thecplusplusuy for demonstration purposes. It's a simple mario like side-scroller game:
  2. //http://www.youtube.com/user/thecplusplusguy
  3. //Free source, modify if you want, LGPL licence (I guess), I would be happy, if you would not delete the link
  4. //so other people can see the tutorial
  5. //this file is player.h class for our player
  6.  
  7. #include <SDL/SDL.h>    //for SDL
  8. #include <iostream> //for cout
  9. #include <vector>   //for the map
  10. #include "base.h"   //for collision and TILE_SIZE and coord
  11. #ifndef PLAYER_H
  12. #define PLAYER_H
  13. class player:baseclass{ //we inherit for collision
  14.     SDL_Rect box;                   //bounding box (position)
  15.     SDL_Surface* image;     //the image
  16.     int xvel,yvel;              //the velocity
  17.     SDL_Rect clips[4];      //clips of the part of the image for animation
  18.     bool ground,jump;           //are we on the ground or are we jumping?
  19.     char direction;             //left or right
  20.     double frame;                   //current frame
  21.     bool moving;                    //are we moving?
  22.     int health;                     //the health
  23.     public:
  24.     //obvious
  25.     player(SDL_Surface* img);
  26.     ~player();
  27.     SDL_Rect* getRect();
  28.     void setXvel(int vel);
  29.     int getXvel();
  30.     void move(const std::vector<std::vector<int> >& map);
  31.     void show(SDL_Surface* screen);
  32.     void setJump();
  33.     void setMoving(bool);
  34.     void setDirection(char);
  35.     char getDirection();
  36.     int getHealth();
  37.     void setHealth(int);
  38. };
  39. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement