aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/maps/stage_1_boss.bfm4
-rw-r--r--meta/maps/stage_1_start.bfm2
-rw-r--r--src/gameplay.cpp54
-rw-r--r--src/main.cpp2
4 files changed, 38 insertions, 24 deletions
diff --git a/meta/maps/stage_1_boss.bfm b/meta/maps/stage_1_boss.bfm
index 2987ef6..470fd66 100644
--- a/meta/maps/stage_1_boss.bfm
+++ b/meta/maps/stage_1_boss.bfm
@@ -1,2 +1,2 @@
-E 2 100
-N 0
+ENEMIES 2 100
+NEXT 0
diff --git a/meta/maps/stage_1_start.bfm b/meta/maps/stage_1_start.bfm
index d850579..e735c3f 100644
--- a/meta/maps/stage_1_start.bfm
+++ b/meta/maps/stage_1_start.bfm
@@ -1,2 +1,2 @@
-ENEMIES 20 20
+ENEMIES 10 20
NEXT stage_1_boss.bfm
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 04facc2..622ff5a 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -89,31 +89,41 @@ void Game::draw() const
// NEW: go towards player NEXT: spawn at different times
int Game::tick() const
{
- for (auto & en : *enemies)
+ for (auto en = enemies->begin(); en != enemies->end(); en++)
{
- if (en.posX >= SCREENWIDTH || en.posX <= 0) {
- en.direction.x = -en.direction.x;
+ if (en->hp != 0)
+ {
+ if (en->posX >= SCREENWIDTH || en->posX <= 0) {
+ en->direction.x = -en->direction.x;
}
- if (en.posY >= SCREENHEIGHT || en.posY <= 0) {
- en.direction.y = -en.direction.y;
+ if (en->posY >= SCREENHEIGHT || en->posY <= 0) {
+ en->direction.y = -en->direction.y;
}
- if (en.posX >= player->posX) {
- en.direction.x -= 0.1f;
+ if (en->posX >= player->posX) {
+ en->direction.x -= 0.1f;
}
- if (en.posY >= player->posY) {
- en.direction.y -= 0.1f;
+ if (en->posY >= player->posY) {
+ en->direction.y -= 0.1f;
}
- if (en.posX <= player->posX) {
- en.direction.x += 0.1f;
+ if (en->posX <= player->posX) {
+ en->direction.x += 0.1f;
}
- if (en.posY <= player->posY) {
- en.direction.y += 0.1f;
+ if (en->posY <= player->posY) {
+ en->direction.y += 0.1f;
}
- en.posX += en.direction.x;
- en.posY += en.direction.y;
- if (CheckCollisionCircles((Vector2){player->posX, player->posY}, 10,
- (Vector2){en.posX, en.posY}, 10)) { // check for player death (one shot one kill)
- return (1);
+ } else {
+ if (en->posX >= SCREENWIDTH || en->posX <= 0 || en->posY >= SCREENHEIGHT ) {
+ enemies->erase(en);
+ return (0);
+ }
+ }
+
+ en->posX += en->direction.x;
+ en->posY += en->direction.y;
+ if (en->hp != 0 && // check for player death (one shot one kill)
+ CheckCollisionCircles((Vector2){player->posX, player->posY}, 10,
+ (Vector2){en->posX, en->posY}, 10)) {
+ return (1);
}
}
return (0);
@@ -163,6 +173,7 @@ int Game::getKeys() const
if (player->victims == nEnemies) {
return (2);
}
+ std::cout << player->victims << "|" << nEnemies << std::endl;
}
if (player->threshold)
{
@@ -207,12 +218,15 @@ Game::shoot() const
for (auto en = enemies->begin(); en != enemies->end(); en++)
{
if (CheckCollisionPointLine((Vector2){en->posX, en->posY}, (Vector2){player->posX, player->posY}, add1, (en->radius * 2)) ||
- CheckCollisionPointLine((Vector2){en->posX, en->posY}, (Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, Vector2Rotate(player->direction, 0.0f)), (en->radius * 2)) ||
+ CheckCollisionPointLine((Vector2){en->posX, en->posY}, (Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, player->direction), (en->radius * 2)) ||
CheckCollisionPointLine((Vector2){en->posX, en->posY}, (Vector2){player->posX, player->posY}, add2, (en->radius * 2)))
{
std::cout << "hit enemy at " << en->posX << "|" << en->posY
<< std::endl;
- enemies->erase(en);
+ en->hp = 0;
+ en->direction.x = (player->direction.x / 2);
+ en->direction.y = (player->direction.y / 2);
+ // enemies->erase(en);
player->victims++;
player->fury++;
DrawLineEx((Vector2){player->posX, player->posY}, add1, 10,
diff --git a/src/main.cpp b/src/main.cpp
index 48a24f8..52db18e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -45,7 +45,7 @@ int main(void) {
delete game;
CloseAudioDevice();
- if (next != "0") {
+ if (game->getNext() != "0") {
game = new Game(next);
}
}