diff --git a/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj b/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj index 42c2e56..08cc254 100644 --- a/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj +++ b/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj @@ -137,6 +137,7 @@ + @@ -148,6 +149,7 @@ + diff --git a/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj.filters b/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj.filters index bbd419b..f6a7384 100644 --- a/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj.filters +++ b/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj.filters @@ -60,6 +60,9 @@ Header Files\Assignment3 + + Header Files\Assignment3 + @@ -83,6 +86,9 @@ Source Files\Assignment3Implement + + Source Files\Assignment3Implement + diff --git a/Assignment3Project/Assignment3Project/bullet.cpp b/Assignment3Project/Assignment3Project/bullet.cpp index d60d256..d9f5b20 100644 --- a/Assignment3Project/Assignment3Project/bullet.cpp +++ b/Assignment3Project/Assignment3Project/bullet.cpp @@ -23,4 +23,8 @@ void Bullet::move(Direction dir) { if (y_pos < 0 - height) { oob = true; } -} \ No newline at end of file +} + +void Bullet::collide(GameElement * x) +{ +} diff --git a/Assignment3Project/Assignment3Project/bullet.h b/Assignment3Project/Assignment3Project/bullet.h index 85a0544..1d00584 100644 --- a/Assignment3Project/Assignment3Project/bullet.h +++ b/Assignment3Project/Assignment3Project/bullet.h @@ -1,5 +1,4 @@ #pragma once -#include #include #include "game_element.h" @@ -11,4 +10,5 @@ public: void reset_pos(float x, float y); void draw(); void move(Direction dir); + void collide(GameElement* x); }; \ No newline at end of file diff --git a/Assignment3Project/Assignment3Project/enemy.cpp b/Assignment3Project/Assignment3Project/enemy.cpp new file mode 100644 index 0000000..d6a81f8 --- /dev/null +++ b/Assignment3Project/Assignment3Project/enemy.cpp @@ -0,0 +1,21 @@ +#include "enemy.h" + +Enemy::Enemy() +{ +} + +void Enemy::reset_pos(float x, float y) +{ +} + +void Enemy::draw() +{ +} + +void Enemy::move(Direction dir) +{ +} + +void Enemy::collide(GameElement * x) +{ +} diff --git a/Assignment3Project/Assignment3Project/enemy.h b/Assignment3Project/Assignment3Project/enemy.h new file mode 100644 index 0000000..470930b --- /dev/null +++ b/Assignment3Project/Assignment3Project/enemy.h @@ -0,0 +1,15 @@ +#pragma once + +#include "game_element.h" + +class Enemy : public GameElement { +public: + ALLEGRO_BITMAP* sprite; + + Enemy(); + + void reset_pos(float x, float y); + void draw(); + void move(Direction dir); + void collide(GameElement* x); +}; \ No newline at end of file diff --git a/Assignment3Project/Assignment3Project/game_element.h b/Assignment3Project/Assignment3Project/game_element.h index 49cead8..9de5c68 100644 --- a/Assignment3Project/Assignment3Project/game_element.h +++ b/Assignment3Project/Assignment3Project/game_element.h @@ -1,4 +1,5 @@ #pragma once +#include #include "enums.h" @@ -14,4 +15,5 @@ public: virtual void reset_pos(float x, float y) = 0; virtual void move(Direction dir) = 0; virtual void draw() = 0; + virtual void collide(GameElement* x) = 0; }; \ No newline at end of file diff --git a/Assignment3Project/Assignment3Project/ship.cpp b/Assignment3Project/Assignment3Project/ship.cpp index f560830..c1a77c4 100644 --- a/Assignment3Project/Assignment3Project/ship.cpp +++ b/Assignment3Project/Assignment3Project/ship.cpp @@ -25,6 +25,10 @@ void Ship::draw() { al_draw_bitmap(sprite, x_pos, y_pos, NULL); } +void Ship::collide(GameElement * x) +{ +} + void Ship::move(Direction dir) { float factor = 4 * speed; switch (dir) { @@ -73,12 +77,10 @@ void Ship::move(Direction dir) { } Bullet Ship::fire() { - if (!fired) { - Bullet new_bullet; - float x = (x_pos) + width / 2.0; - float y = y_pos - new_bullet.height; - new_bullet.reset_pos(x, y); - fired = true; - return new_bullet; - } + Bullet new_bullet; + float x = (x_pos) + width / 2.0; + float y = y_pos - new_bullet.height; + new_bullet.reset_pos(x, y); + fired = true; + return new_bullet; } \ No newline at end of file diff --git a/Assignment3Project/Assignment3Project/ship.h b/Assignment3Project/Assignment3Project/ship.h index 3edede7..1f34ebf 100644 --- a/Assignment3Project/Assignment3Project/ship.h +++ b/Assignment3Project/Assignment3Project/ship.h @@ -1,5 +1,4 @@ #pragma once -#include #include "enums.h" #include "game_element.h" @@ -19,6 +18,7 @@ public: void reset_pos(float x, float y); void set_sprite(ALLEGRO_BITMAP* _sprite); void draw(); + void collide(GameElement* x); void move(Direction dir); Bullet fire(); }; \ No newline at end of file