136 lines
3.3 KiB
C++
136 lines
3.3 KiB
C++
#include "collections.h"
|
|
|
|
#include <vector>
|
|
#include <gint/rtc.h>
|
|
|
|
|
|
extern std::vector<Particle*> MyParticles;
|
|
extern std::vector<Bullet*> MyPlayerBullets;
|
|
extern std::vector<Enemy*> MyEnemies;
|
|
extern std::vector<Impact*> MyImpacts;
|
|
extern Starfield *MyStarField;
|
|
extern Player *MyPlayer;
|
|
|
|
|
|
|
|
void Create_Player_Shoot( uint8_t id )
|
|
{
|
|
|
|
if (id==0)
|
|
{
|
|
Bullet *b = new Bullet( (int) MyPlayer->x+21, (int) MyPlayer->y, id );
|
|
MyPlayerBullets.push_back( b );
|
|
}
|
|
else if (id==1)
|
|
{
|
|
Bullet *b1 = new Bullet( (int) MyPlayer->x, (int) MyPlayer->y-17, id );
|
|
MyPlayerBullets.push_back( b1 );
|
|
|
|
Bullet *b2 = new Bullet( (int) MyPlayer->x, (int) MyPlayer->y+17, id );
|
|
MyPlayerBullets.push_back( b2 );
|
|
}
|
|
else if (id==2)
|
|
{
|
|
Bullet *b1 = new Bullet( (int) MyPlayer->x+21, (int) MyPlayer->y, id );
|
|
MyPlayerBullets.push_back( b1 );
|
|
|
|
Bullet *b2 = new Bullet( (int) MyPlayer->x, (int) MyPlayer->y-17, id );
|
|
MyPlayerBullets.push_back( b2 );
|
|
|
|
Bullet *b3 = new Bullet( (int) MyPlayer->x, (int) MyPlayer->y+17, id );
|
|
MyPlayerBullets.push_back( b3 );
|
|
}
|
|
}
|
|
|
|
void Create_Ennemies( void )
|
|
{
|
|
Enemy* e1 = new Enemy( 348, 112, 0);
|
|
e1->Set_Speed_Vector( 1, 1, -6 );
|
|
MyEnemies.push_back( e1 );
|
|
|
|
Enemy* e2 = new Enemy( 348, 112, 0);
|
|
e2->Set_Speed_Vector( 1, 1, 6 );
|
|
MyEnemies.push_back( e2 );
|
|
|
|
Enemy* e3 = new Enemy( 348, 112, 1);
|
|
e3->Set_Speed_Vector( 1, 3, -3 );
|
|
MyEnemies.push_back( e3 );
|
|
|
|
Enemy* e4 = new Enemy( 348, 112, 1);
|
|
e4->Set_Speed_Vector( 1, 3, 3 );
|
|
MyEnemies.push_back( e4 );
|
|
|
|
|
|
|
|
|
|
Point2D *A = new Point2D( 348, 112 );
|
|
Point2D *B = new Point2D( 371, 199 );
|
|
Point2D *C = new Point2D( 198, 149 );
|
|
Point2D *D = new Point2D( 25, 199 );
|
|
Point2D *E = new Point2D( 25, 25 );
|
|
Point2D *F = new Point2D( 198, 75 );
|
|
Point2D *G = new Point2D( 371, 25 );
|
|
|
|
|
|
Trajectory *MyTrajectory= new Trajectory();
|
|
MyTrajectory->AddPoint( A );
|
|
MyTrajectory->AddPoint( B );
|
|
MyTrajectory->AddPoint( C );
|
|
MyTrajectory->AddPoint( D );
|
|
MyTrajectory->AddPoint( E );
|
|
MyTrajectory->AddPoint( F );
|
|
MyTrajectory->AddPoint( G );
|
|
|
|
Enemy* e5 = new Enemy( 348, 112, 2);
|
|
e5->hasTrajectory = true;
|
|
e5->pathToFollow = MyTrajectory;
|
|
MyEnemies.push_back( e5 );
|
|
}
|
|
|
|
|
|
void Create_Explosion( uint16_t xexplosion, uint16_t yexplosion )
|
|
{
|
|
srand(rtc_ticks());
|
|
|
|
for(int i=0; i<=50; i++)
|
|
{
|
|
Particle *p = new Particle( xexplosion, yexplosion, i );
|
|
MyParticles.push_back( p );
|
|
}
|
|
}
|
|
|
|
|
|
void Create_Impact( uint16_t ximpact, uint16_t yimpact )
|
|
{
|
|
Impact *i = new Impact( ximpact, yimpact );
|
|
MyImpacts.push_back( i );
|
|
}
|
|
|
|
|
|
|
|
void Clean_Everything( void )
|
|
{
|
|
for(unsigned int i=0; i<MyEnemies.size(); i++)
|
|
{
|
|
delete( MyEnemies[i] );
|
|
MyEnemies.erase( MyEnemies.begin() + i );
|
|
}
|
|
MyEnemies.clear();
|
|
|
|
for(unsigned int i=0; i<MyParticles.size(); i++)
|
|
{
|
|
delete( MyParticles[i] );
|
|
MyParticles.erase( MyParticles.begin() + i );
|
|
}
|
|
MyParticles.clear();
|
|
|
|
for(unsigned int i=0; i<MyPlayerBullets.size(); i++)
|
|
{
|
|
delete( MyPlayerBullets[i] );
|
|
MyPlayerBullets.erase( MyPlayerBullets.begin() + i );
|
|
}
|
|
MyPlayerBullets.clear();
|
|
}
|
|
|
|
|