18void Game::displayAll(
unsigned fps)
const {
19 pm->drawSprite(pm->gameBackground,
Position(0, 0));
20 for (
unsigned i = 0; i < this->grid.size(); ++i){
21 for (
unsigned j = 0; j < this->grid[i].size(); ++j){
26 displayInvader(vec, grid[i][j]);
30 for(
const missile& miss : missiles){
33 for(
const Torpedo& tor : torpedos){
42 pm->drawText(
Position(pm->getScreenWidth()-200, 20),
"FPS : "+to_string(fps), nsGraphics::KWhite, Font::BITMAP_8_BY_13);
45 for(
unsigned i=0;i<players.size();++i){
46 if(!players[i].isEliminated()){
47 if(players[i].deathAnimCounter%2==0){
56void Game::displayHearts(
playerID pID)
const {
64 for(
unsigned i=0;i<players[pID].lives;++i){
68 if(players[pID].hasDeathAnimation()){
69 pm->drawHeart(
Position(x, y+players[pID].deathAnimCounter*5));
73void Game::displayScore()
const{
75 unsigned playerNumber = 1;
76 for (
auto& player: players){
77 pm->drawText(
Position(0,10+margin),
"player "+to_string(playerNumber)+
" :",nsGraphics::KWhite,Font::BITMAP_8_BY_13);
78 pm->drawText(
Position(100,10+margin),to_string(player.score) ,nsGraphics::KWhite,Font::BITMAP_8_BY_13);
104 pos += (point-pos)*percent;
107void Game::displayGod()
const {
116 pm->drawSprite(pm->leftHand, leftHand);
117 pm->drawSprite(pm->rightHand, rightHand);
125 pm->drawSprite(pm->leftHand, leftHand);
126 pm->drawSprite(pm->rightHand, rightHand);
145 pm->drawSprite(pm->rightHand, pos);
165 invaderPos = invaderPos + a;
170 unsigned handCounter;
172 else handCounter = 30-god.
counter;
173 handPos = handPos + god.
thrownVector * (handCounter / 100.0);
175 pm->drawSprite(pm->rightHand, handPos);
unsigned counter
manage all sorts of things, gods secrets remains unknown
unsigned thrownInvPosY
y pixel coordinate of the invader thrown by the hand of god
Position thrownTransition
position of a point for bezier's curve
Position getRightHandPos(unsigned screenWidth) const
give initial the pixel coordinates of god's right hand
Position thrownVector
direction of the thrown invader movement
GodState state
god's current state
InvaderType thrownInvType
type of the invader thrown by the hand of god
unsigned thrownInvPosX
x pixel coordinate of the invader thrown by the hand of god
void applyBezier(Position &pos, const Position &point, const double percent)
full game logic and display management
#define GOD_HAND_DISTANCE
InvaderType
List of all invader type.
unsigned missilesWidth
invaders missiles width in pixel
nsGraphics::RGBAcolor torpedosColor
players torpedos color
vector< PlayerDef > playerDefs
player key configuration
unsigned invadersDistance
distance in pixel between two invader
nsGraphics::RGBAcolor missilesColor
invaders missiles color
unsigned playersWidth
player horizontal size in pixel
unsigned invadersSize
invader radius size in pixel
unsigned torpedosWidth
players torpedos width in pixel
map< InvaderType, InvaderTypeDef > invadersDef
link between an invader type, and its data
nsGraphics::RGBAcolor color
color of the invader type
void applyTransformation(Position &pos, unsigned sizeFrom, unsigned sizeTo)
change the size of a Position object
nsGraphics::Vec2D Position