SUPER Space invader : Turbo edition DX - VS GOD 1.0.0
A simple space invader ripoff
pixelManager.h
Go to the documentation of this file.
1
13#ifndef GUARD_PIXELMANAGER_H
14#define GUARD_PIXELMANAGER_H
15
16#include <string>
17#include "mingl/mingl.h"
18#include "mingl/shape/line.h"
19#include "mingl/shape/triangle.h"
20#include "mingl/shape/rectangle.h"
21#include "mingl/shape/circle.h"
22#include "mingl/gui/sprite.h"
23#include "mingl/gui/text.h"
24#include "utils.h"
25#include "playMode.h"
26#include "menu.h"
27#include "scoresManager.h"
28#include "mySprite.h"
29
30using namespace std;
31
32typedef nsGui::GlutFont::GlutFonts Font;
33
39/*
40 * It's MinGL's fault. This is all I have to say
41 */
42
43// The convention seems to just add a number to the macro name
44#define ADD_SPRITE_TASK(X) ADD_SPRITE_TASK2(X, X)
45#define ADD_SPRITE_TASK2(X, Y) tasks.push_back((X).asyncLoad("assets/"#Y".si2"));
46
47typedef future<void> Task;
48
49
51public:
52 MinGL& window;
53 mutable vector<Task> drawTasks;
54
55
61 virtual void loadSprites(vector<Task>& tasks);
62
63
68
73
78
83
88
94 explicit PixelManager(MinGL& window);
95
103 void drawInvaderA(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
104
112 void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
113
121 void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
122
130 void drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const;
131
139 void drawMissile(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
140
148 void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
149
150#define HEART_LENGTH 40
151
157 void drawHeart(const Position& baseVector) const;
158
165 void drawSprite(const MySprite& msp, const Position& pos) const;
166
174 void displayButton(const Position& baseVector,const string& text,nsGraphics::RGBAcolor& color);
175
182 void displayMenu(const Position& pos, Menu& currentMenu);
183
192 void displayMenu(const Position& pos, Menu& currentMenu, const vector<ScoreLink>& rankings,const WinValue& winner);
200 void drawText(const Position& pos, const string& text, const RGBAcolor& color = nsGraphics::KWhite, Font font = Font::BITMAP_TIMES_ROMAN_24) const;
201
208
216 bool showDeathMenu(const vector<ScoreLink>& rankings,const WinValue& winner);
217
223 unsigned getScreenHeight() const;
224
230 unsigned getScreenWidth() const;
231
236 void startFrame() const;
237
242 void endFrame() const;
243
251 void askPlayerNameMenu(playerID pID, unsigned score, string& name);
252
253 // y will be negative sometimes, so not unsigned
254
260 void drawGodBench(int y) const;
261
268 void drawGodFace(int y, bool angry=false) const;
269
270private:
271 // Explanation for choices :
272 // non reference output : I don't think we have another choice than a std::move() here
273
280 static vector<RGBAcolor> mirrorData(const vector<RGBAcolor>& inPixels, unsigned rowSize);
281};
282
283
284#endif
main display function, clear the window and calls sub display functions
Definition: pixelManager.h:50
void startFrame() const
clear the screen for a new frame
MySprite leftHand
sprite of the left hand of god
Definition: pixelManager.h:87
virtual void loadSprites(vector< Task > &tasks)
loads sprites in parallel using multiple threads
Definition: pixelManager.cpp:4
void drawGodFace(int y, bool angry=false) const
display god's face
PixelManager(MinGL &window)
constructor the pixel manager class
void drawSprite(const MySprite &msp, const Position &pos) const
display a sprite on screen
MySprite menuBackground
sprite of the background during menu
Definition: pixelManager.h:72
PlayMode showInitialMenu()
show the title screen of the game
Definition: drawMenus.cpp:72
MySprite rightHand
sprite of the right hand of god
Definition: pixelManager.h:82
void displayButton(const Position &baseVector, const string &text, nsGraphics::RGBAcolor &color)
display a menu button on screen
Definition: drawMenus.cpp:22
void endFrame() const
finish a frame render
void drawGodBench(int y) const
display god's bar
void drawMissile(const Position &baseVector, unsigned width, const nsGraphics::RGBAcolor &color) const
display a missile on screen
void drawText(const Position &pos, const string &text, const RGBAcolor &color=nsGraphics::KWhite, Font font=Font::BITMAP_TIMES_ROMAN_24) const
display text on screen
void drawInvaderB(const Position &baseVector, unsigned size, const RGBAcolor &color) const
display a type B invader on screen
unsigned getScreenHeight() const
give the height of the screen
void drawHeart(const Position &baseVector) const
display a singular heart on screen
void drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor &color) const
display a player on screen
unsigned getScreenWidth() const
give the width of the screen
void drawTorpedo(const Position &baseVector, unsigned width, const nsGraphics::RGBAcolor &color) const
display a torpedo on screen
void drawInvaderA(const Position &baseVector, unsigned size, const RGBAcolor &color) const
display a type A invader on screen
vector< Task > drawTasks
Definition: pixelManager.h:53
MySprite logo
sprite of the logo of the game
Definition: pixelManager.h:67
MinGL & window
Definition: pixelManager.h:52
void displayMenu(const Position &pos, Menu &currentMenu)
display a menu on screen
Definition: drawMenus.cpp:28
bool showDeathMenu(const vector< ScoreLink > &rankings, const WinValue &winner)
show the menu after a player lose, or all invader has been defeated
Definition: drawMenus.cpp:156
void drawInvaderC(const Position &baseVector, unsigned size, const RGBAcolor &color) const
display a type C invader on screen
MySprite gameBackground
sprite of the background during gameplay
Definition: pixelManager.h:77
void askPlayerNameMenu(playerID pID, unsigned score, string &name)
Definition: drawMenus.cpp:108
simple menu backend implementation
nsGui::GlutFont::GlutFonts Font
Definition: pixelManager.h:32
future< void > Task
Definition: pixelManager.h:47
game mode options
PlayMode
List of all game playmode.
Definition: playMode.h:17
Score file manager.
menu stuct
Definition: menu.h:22
utilies for the game
unsigned playerID
Definition: utils.h:54
nsGraphics::Vec2D Position
Definition: utils.h:53
WinValue
list of win values
Definition: utils.h:45