Hi This my first little game in Pokitto. Im a fresh in C++ So, Wishing your advise!!!!!

Dependencies:   PokittoLib

playgame.h

Committer:
79859899
Date:
2018-03-17
Revision:
0:eff664bec7e0
Child:
1:8d5b6cdae9df

File content as of revision 0:eff664bec7e0:

/**************************************************************************/
/*!
    @file     Playgame.h
    @author

    @section

*/
/**************************************************************************/
#ifndef PLAYGAME_H
#define PLAYGAME_H
#include "Pokitto.h"
#include <vector>
#include "bullet.h"
#include "aircraft.h"
#include "palette.h"
#define BULLET_AMOUNT_MAX 300
#define BULLET_TIME_SPACE 10
#define AIRCRAFT_X_OFFSET 7
#define AIRCRAFT_Y_OFFSET 7
#define BULLET_X_OFFSET 1
#define BULLET_Y_OFFSET 1

std::vector<bullet> vbullet;
aircraft air1;
int bullettimespace = 0;
uint32_t oldTime,finalTime;

void playgame(){

    Pokitto::Display::load565Palette(playgame_pal);
    Pokitto::Display::invisiblecolor = PLAYGAME_INVISIBLE_COLOR;

    if (Pokitto::Core::update()) {
        //Pokitto::Display::print(0,0,"live");
        finalTime = Pokitto::Core::getTime()/1000 - oldTime/1000;
        //Pokitto::Display::print(25,0,finalTime);//show living time
        air1.move();
        air1.display();
        ++bullettimespace;

        if(bullettimespace == BULLET_TIME_SPACE){ //control bulltet object max amount
            if(vbullet.size() <= BULLET_AMOUNT_MAX){
                bullet *bl = new bullet(air1.getx()+AIRCRAFT_X_OFFSET, air1.gety()+AIRCRAFT_Y_OFFSET);
                vbullet.push_back(*bl);
                }
                bullettimespace = 0;
        }

        for(std::vector<bullet>::iterator bull = vbullet.begin();  bull != vbullet.end(); ++bull){
            bull->move();
            bull->renew(air1.getx()+AIRCRAFT_X_OFFSET, air1.gety()+AIRCRAFT_Y_OFFSET);
            bull->display();
            if(((air1.getx()+AIRCRAFT_X_OFFSET == bull->getxaxix()+BULLET_X_OFFSET)
               && (air1.gety()+AIRCRAFT_Y_OFFSET == bull->getyaxix()+BULLET_Y_OFFSET)) ||
               ((air1.getx()+AIRCRAFT_X_OFFSET+1 == bull->getxaxix()+BULLET_X_OFFSET)
               && (air1.gety()+AIRCRAFT_Y_OFFSET == bull->getyaxix()+BULLET_Y_OFFSET))||
                ((air1.getx()+AIRCRAFT_X_OFFSET == bull->getxaxix()+BULLET_X_OFFSET+1)
               && (air1.gety()+AIRCRAFT_Y_OFFSET == bull->getyaxix()+BULLET_Y_OFFSET))||
                ((air1.getx()+AIRCRAFT_X_OFFSET+1 == bull->getxaxix()+BULLET_X_OFFSET+1)
               && (air1.gety()+AIRCRAFT_Y_OFFSET == bull->getyaxix()+BULLET_Y_OFFSET))||

               ((air1.getx()+AIRCRAFT_X_OFFSET == bull->getxaxix()+BULLET_X_OFFSET)
               && (air1.gety()+AIRCRAFT_Y_OFFSET == bull->getyaxix()+BULLET_Y_OFFSET+1)) ||
               ((air1.getx()+AIRCRAFT_X_OFFSET+1 == bull->getxaxix()+BULLET_X_OFFSET)
               && (air1.gety()+AIRCRAFT_Y_OFFSET == bull->getyaxix()+BULLET_Y_OFFSET+1))||
                ((air1.getx()+AIRCRAFT_X_OFFSET == bull->getxaxix()+BULLET_X_OFFSET+1)
               && (air1.gety()+AIRCRAFT_Y_OFFSET == bull->getyaxix()+BULLET_Y_OFFSET+1)) ||
               ((air1.getx()+AIRCRAFT_X_OFFSET+1 == bull->getxaxix()+BULLET_X_OFFSET+1)
               && (air1.gety()+AIRCRAFT_Y_OFFSET == bull->getyaxix()+BULLET_Y_OFFSET+1))||

               ((air1.getx()+AIRCRAFT_X_OFFSET == bull->getxaxix()+BULLET_X_OFFSET)
               && (air1.gety()+AIRCRAFT_Y_OFFSET+1 == bull->getyaxix()+BULLET_Y_OFFSET)) ||
               ((air1.getx()+AIRCRAFT_X_OFFSET+1 == bull->getxaxix()+BULLET_X_OFFSET)
               && (air1.gety()+AIRCRAFT_Y_OFFSET+1 == bull->getyaxix()+BULLET_Y_OFFSET))||
                ((air1.getx()+AIRCRAFT_X_OFFSET == bull->getxaxix()+BULLET_X_OFFSET+1)
               && (air1.gety()+AIRCRAFT_Y_OFFSET+1 == bull->getyaxix()+BULLET_Y_OFFSET))||
                ((air1.getx()+AIRCRAFT_X_OFFSET+1 == bull->getxaxix()+BULLET_X_OFFSET+1)
               && (air1.gety()+AIRCRAFT_Y_OFFSET+1 == bull->getyaxix()+BULLET_Y_OFFSET))||

               ((air1.getx()+AIRCRAFT_X_OFFSET == bull->getxaxix()+BULLET_X_OFFSET)
               && (air1.gety()+AIRCRAFT_Y_OFFSET+1 == bull->getyaxix()+BULLET_Y_OFFSET+1)) ||
               ((air1.getx()+AIRCRAFT_X_OFFSET+1 == bull->getxaxix()+BULLET_X_OFFSET)
               && (air1.gety()+AIRCRAFT_Y_OFFSET+1 == bull->getyaxix()+BULLET_Y_OFFSET+1))||
                ((air1.getx()+AIRCRAFT_X_OFFSET == bull->getxaxix()+BULLET_X_OFFSET+1)
               && (air1.gety()+AIRCRAFT_Y_OFFSET+1 == bull->getyaxix()+BULLET_Y_OFFSET+1)) ||
               ((air1.getx()+AIRCRAFT_X_OFFSET+1 == bull->getxaxix()+BULLET_X_OFFSET+1)
               && (air1.gety()+AIRCRAFT_Y_OFFSET+1 == bull->getyaxix()+BULLET_Y_OFFSET+1))
               ){
                    gameConditon = 2;
                    bullettimespace = 0;
                    air1.clear();
                    vbullet.clear();
                    break;
            }

        }
    }
}
#endif