aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/entity.cpp14
-rw-r--r--src/gameplay.cpp50
2 files changed, 32 insertions, 32 deletions
diff --git a/src/entity.cpp b/src/entity.cpp
index c68ff10..3b21557 100644
--- a/src/entity.cpp
+++ b/src/entity.cpp
@@ -17,34 +17,30 @@ Entity::Entity(void) : hp(1)
case (0):
{
posX = GetRandomValue((SCREENWIDTH / 2) - 30, (SCREENWIDTH / 2) + 30);
- posY = 0;
+ posY = GetRandomValue(0, 40);
break;
}
case (1):
{
- posX = SCREENWIDTH;
+ posX = GetRandomValue(SCREENWIDTH - 20, SCREENWIDTH + 20);
posY = GetRandomValue((SCREENHEIGHT / 2) - 30, (SCREENHEIGHT / 2) + 30);
break;
}
case (2):
{
posX = GetRandomValue((SCREENWIDTH / 2) - 30, (SCREENWIDTH / 2) + 30);
- posY = SCREENHEIGHT;
+ posY = GetRandomValue(SCREENHEIGHT - 20, SCREENHEIGHT + 20);
break;
}
case (3):
{
- posX = SCREENWIDTH;
+ posX = GetRandomValue(SCREENWIDTH - 20, SCREENWIDTH + 20);
posY = GetRandomValue((SCREENHEIGHT / 2), (SCREENHEIGHT / 2) + 10);
break;
}
}
- // if (static_cast<int>(posX) & 1) {
- direction = (Vector2){0.1f, 0.1f};
- // } else {
- // direction = (Vector2){-posX / 100, posY / 100};
- // } // old pseudo-random path finder. now reworking so that they go towards the player
+ direction = (Vector2){0.02f, 0.02f};
radius = 10; // default radius. this is changed later
threshold = false;
}
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 1a4a9e4..bce787b 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -44,7 +44,7 @@ Game::Game(std::string const & path)
}
player = new Entity;
player->posX = 0;
- player->posY = SCREENHEIGHT / 2;
+ player->posY = SCREENHEIGHT / 2.0f;
player->direction.x = 100;
player->direction.y = 100;
player->radius = 10;
@@ -109,25 +109,29 @@ int Game::tick() const
for (auto en = enemies->begin(); en != enemies->end(); en++)
{
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->posX >= player->posX) {
- en->direction.x -= 0.1f;
- }
- if (en->posY >= player->posY) {
- en->direction.y -= 0.1f;
- }
- if (en->posX <= player->posX) {
- en->direction.x += 0.1f;
- }
- if (en->posY <= player->posY) {
- en->direction.y += 0.1f;
- }
+ {
+ 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->posX >= player->posX) {
+ en->posX -= 2.1f;
+ en->direction.x -= 0.1f;
+ }
+ if (en->posY >= player->posY) {
+ en->posY -= 2.1f;
+ en->direction.y -= 0.1f;
+ }
+ if (en->posX <= player->posX) {
+ en->posX += 2.1f;
+ en->direction.x += 0.1f;
+ }
+ if (en->posY <= player->posY) {
+ en->posY += 2.1f;
+ en->direction.y += 0.1f;
+ }
} else {
if (en->posX >= SCREENWIDTH || en->posX <= 0 || en->posY >= SCREENHEIGHT ) {
enemies->erase(en);
@@ -135,7 +139,7 @@ int Game::tick() const
}
}
- en->posX += en->direction.x;
+ en->posX += en->direction.x; // zoning better
en->posY += en->direction.y;
if (en->hp != 0 && // check for player death (one shot one kill)
CheckCollisionCircles((Vector2){player->posX, player->posY}, 10,
@@ -246,8 +250,8 @@ Game::shoot() const
CheckCollisionPointLine((Vector2){en->posX, en->posY}, (Vector2){player->posX, player->posY}, add2, (en->radius * 2)))
{ // enemy hit
en->hp = 0;
- en->direction.x = (player->direction.x / 2);
- en->direction.y = (player->direction.y / 2);
+ en->direction.x = player->direction.x;
+ en->direction.y = player->direction.y;
player->victims++;
player->fury++;
DrawLineEx((Vector2){player->posX, player->posY}, add1, 10,