thecplusplusguy

Simple sidescroller game - enemy.h

Jul 14th, 2011
2,055
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 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 enemy.h a class for the enemies
  6. #include <SDL/SDL.h>    //for SDL
  7. #include <vector>   //we need it for the map
  8. #include "base.h"
  9. #ifndef ENEMY_H //avoid multiple inclusion
  10. #define ENEMY_H
  11. class enemy:public baseclass{   //we inherit from baseclass because the collision function
  12.     SDL_Rect box;   //collision box (bounding box)
  13.     int xvel,yvel;  //velocity (speed)
  14.     SDL_Surface* image; //image
  15.     bool ground;    //are we on the ground?
  16.     SDL_Rect clips[2];  //clips for the animation in enemy.bmp picture
  17.     double frame;   //the current frame
  18.     public:
  19.     //obvious
  20.     enemy(SDL_Surface*,int x,int y,int xvel,int yvel);
  21.     void move(std::vector<std::vector<int> >&);
  22.     void show(SDL_Surface*);
  23.     SDL_Rect* getRect();
  24. };
  25. #endif
Advertisement
Add Comment
Please, Sign In to add comment