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 game.h it's a class, which put everything other together to one program
- #include <iostream> //for write out things
- #include <fstream> //to read the map from file (and you could write error messages to file)
- #include <vector> //for the map
- #include <SDL/SDL.h>//for SDL
- #include <SDL/SDL_ttf.h> //for the menu and showmessage function
- #include "base.h" //we include our own header files
- #include "player.h"
- #include "bullet.h"
- #include "enemy.h"
- #ifndef GAME_H //avoid multiple inclusion
- #define GAME_H
- class game:public baseclass{ //we inherit it from baseclass, because of the collision funtion
- SDL_Surface* screen,*background,*block,*bul,*ene; //images and screen
- SDL_Rect camera; //for the scrolling background (the current position of the background)
- std::vector<std::vector<int> > map; //a multidimensional dynamically allocated vector for the map
- std::vector<bullet*> bullets; //a dynamically allocated vector for the bullets (which will contain address of dynamically allocated bullets)
- std::vector<enemy*> enemies; //vector for the enemies (which will contain address of dynamically allocated enemies)
- bool direction[2]; //what key are we pressing?
- TTF_Font* font; //the font
- SDL_Rect finish; //the finish coordinates
- //obvious
- SDL_Surface* load_image(const char* filename);
- void loadmap(const char* filename);
- void showmap();
- void handleEvents();
- bool running; //is the program running?
- static const int SCREEN_WIDTH=640; //few const
- static const int SCREEN_HEIGHT=480;
- player* player1; //Pointer to a dynamically allocated player
- int showmenu(SDL_Surface*);
- void showmessage(const char* c);
- public:
- game();
- ~game();
- void start();
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement