AsteroidDefender

Dependencies:   4DGL-uLCD-SE DebounceIn mbed

game.h

Committer:
rquinn7
Date:
2015-10-20
Revision:
0:bbc2ad180020
Child:
1:34bb7c386b9f

File content as of revision 0:bbc2ad180020:

#include <vector>
#include "mbed.h"

struct vec2 {
    double x;
    double y;  
};

class Missile{
private:

public:
    bool moved;
    bool interactive;         //collidable in physics
    bool render;
    double x_change;
    double y_change;
    vec2 spawn;
    vec2 dest;
    vec2 coord;
    vec2 old_coord;
    vec2 size;
    int steps;
    //vec2 velocity;
    //Color color;
    
    vec2 prev_coord;
    //vec2 prev_size;
  
Missile(vec2 giv_spawn, vec2 giv_dest, int steps_in) :  moved(false), interactive(true), render(true)
{

    spawn = giv_spawn;
    dest = giv_dest;
    coord = giv_spawn;
    old_coord = coord;
    //color = RED;
    size.x = 6;
    size.y = 6;
    steps = steps_in;
    x_change = (dest.x - spawn.x) / steps;
    y_change = (dest.y - spawn.y) / steps;
    
}

void move(){ 
//    float x_change = 20;
//    float y_change = 20;
    old_coord = coord;
    moved = true;
    coord.x = coord.x + x_change;
    coord.y = coord.y + y_change;
}
};

class Projectile{
private:

public:
    bool moved;
    bool interactive;         //collidable in physics
    bool render;
    vec2 old_coord;
    vec2 coord;
    vec2 size;
    
Projectile(vec2 coord_in) : moved(false), interactive(true), render(true)
{
    coord.x = coord_in.x + 3;
    coord.y = coord_in.y + 6;
    old_coord = coord;
    size.x = 3;
    size.y = 3;
}

void move(){ 
//    float x_change = 20;
//    float y_change = 20;
    old_coord = coord;
    moved = true;
    coord.y = coord.y - 4;
}
};

class Shooter{
private:

public:
    bool moved;
    bool interactive;         //collidable in physics
    bool render;
    vec2 coord;
    vec2 old_coord;
    vec2 size;
    
Shooter() : moved(false), interactive(true), render(true)
{
    coord.x = 58;
    coord.y = 125;
    old_coord = coord;
    size.x = 11;
    size.y = 5;
}
};