Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This example program is created by thecplusplusuy for demonstration purposes. It's a simple mario like side-scroller game:
- //http://www.youtube.com/user/thecplusplusguy
- //Free source, modify if you want, LGPL licence (I guess), I would be happy, if you would not delete the link
- //so other people can see the tutorial
- //this file is player.h class for our player
- #include <SDL/SDL.h> //for SDL
- #include <iostream> //for cout
- #include <vector> //for the map
- #include "base.h" //for collision and TILE_SIZE and coord
- #ifndef PLAYER_H
- #define PLAYER_H
- class player:baseclass{ //we inherit for collision
- SDL_Rect box; //bounding box (position)
- SDL_Surface* image; //the image
- int xvel,yvel; //the velocity
- SDL_Rect clips[4]; //clips of the part of the image for animation
- bool ground,jump; //are we on the ground or are we jumping?
- char direction; //left or right
- double frame; //current frame
- bool moving; //are we moving?
- int health; //the health
- public:
- //obvious
- player(SDL_Surface* img);
- ~player();
- SDL_Rect* getRect();
- void setXvel(int vel);
- int getXvel();
- void move(const std::vector<std::vector<int> >& map);
- void show(SDL_Surface* screen);
- void setJump();
- void setMoving(bool);
- void setDirection(char);
- char getDirection();
- int getHealth();
- void setHealth(int);
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement