I think I just added collide functions I didn't accomplish much

main
Braydon Kains 6 years ago
parent a016d98fbd
commit fe6a905e55

@ -137,6 +137,7 @@
<ItemGroup>
<ClInclude Include="bullet.h" />
<ClInclude Include="cursor.h" />
<ClInclude Include="enemy.h" />
<ClInclude Include="enums.h" />
<ClInclude Include="game.h" />
<ClInclude Include="game_element.h" />
@ -148,6 +149,7 @@
<ItemGroup>
<ClCompile Include="bullet.cpp" />
<ClCompile Include="cursor.cpp" />
<ClCompile Include="enemy.cpp" />
<ClCompile Include="game.cpp" />
<ClCompile Include="game_screen.cpp" />
<ClCompile Include="main.cpp" />

@ -60,6 +60,9 @@
<ClInclude Include="bullet.h">
<Filter>Header Files\Assignment3</Filter>
</ClInclude>
<ClInclude Include="enemy.h">
<Filter>Header Files\Assignment3</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
@ -83,6 +86,9 @@
<ClCompile Include="ship.cpp">
<Filter>Source Files\Assignment3Implement</Filter>
</ClCompile>
<ClCompile Include="enemy.cpp">
<Filter>Source Files\Assignment3Implement</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

@ -23,4 +23,8 @@ void Bullet::move(Direction dir) {
if (y_pos < 0 - height) {
oob = true;
}
}
}
void Bullet::collide(GameElement * x)
{
}

@ -1,5 +1,4 @@
#pragma once
#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
#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);
};

@ -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)
{
}

@ -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);
};

@ -1,4 +1,5 @@
#pragma once
#include <allegro5/allegro.h>
#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;
};

@ -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;
}

@ -1,5 +1,4 @@
#pragma once
#include <allegro5/allegro.h>
#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();
};
Loading…
Cancel
Save