aboutsummaryrefslogtreecommitdiff
path: root/src/levels
diff options
context:
space:
mode:
Diffstat (limited to 'src/levels')
-rw-r--r--src/levels/level1.c3
-rw-r--r--src/levels/level2.c3
-rw-r--r--src/levels/level3.c50
-rw-r--r--src/levels/level3.h4
4 files changed, 54 insertions, 6 deletions
diff --git a/src/levels/level1.c b/src/levels/level1.c
index 06bd518..882f314 100644
--- a/src/levels/level1.c
+++ b/src/levels/level1.c
@@ -3,6 +3,7 @@
#include "world.h"
#include "entity.h"
#include "entitiesInclude.h"
+#include "entityGrouping.h"
void initLevel1(Game * game, Levels * levels) {
int i;
@@ -47,7 +48,7 @@ bool updateLevel1(Game * game, Levels * levels) {
if (game->world.entitiesCount == 1) {
Vector3 position = Vector3Add(player->position, (Vector3){0.0, 0.0, 1000.0});
Vector3 spacing = (Vector3){0.0, 10.0, 10.0};
- addSoldatoGroupToWorld(game, 10, position, spacing);
+ addEntityGroupToWorld(game, ENTITY_SOLDATO, 10, position, spacing);
data->stage = 1;
}
diff --git a/src/levels/level2.c b/src/levels/level2.c
index 74e58c3..561ff75 100644
--- a/src/levels/level2.c
+++ b/src/levels/level2.c
@@ -3,6 +3,7 @@
#include "world.h"
#include "entity.h"
#include "entitiesInclude.h"
+#include "entityGrouping.h"
void initLevel2(Game * game, Levels * levels) {
int i;
@@ -29,7 +30,7 @@ void initLevel2(Game * game, Levels * levels) {
for (i = 0; i < sizeof(groups) / sizeof(Vector3); ++i) {
Vector3 spacing = (Vector3){0.0, 10.0, 10.0};
- addSoldatoGroupToWorld(game, 7, groups[i], spacing);
+ addEntityGroupToWorld(game, ENTITY_SOLDATO, 7, groups[i], spacing);
}
}
diff --git a/src/levels/level3.c b/src/levels/level3.c
index 799a5ee..4d688fc 100644
--- a/src/levels/level3.c
+++ b/src/levels/level3.c
@@ -1,8 +1,19 @@
#include "level3.h"
#include "game.h"
#include "world.h"
+#include "entityGrouping.h"
void initLevel3(Game * game, Levels * levels) {
+ levels->data = KF_MALLOC((sizeof(Level3)));
+
+ if (levels->data == NULL) {
+ ALLOCATION_ERROR;
+ return;
+ }
+
+ Level3 * data = (Level3*)levels->data;
+ data->stage = 0;
+
WorldEntry entries[] = {
(WorldEntry){ENTITY_ANTIFA, (Vector3){0.0, 0.0, 0.0}, QuaternionIdentity()},
(WorldEntry){ENTITY_CAPORALE, (Vector3){0.0, 0.0, 300.0}, QuaternionIdentity()}
@@ -17,12 +28,43 @@ void initLevel3(Game * game, Levels * levels) {
}
void closelevel3(Levels * levels) {
-
+ if (levels->data != NULL)
+ KF_FREE(levels->data);
}
bool updateLevel3(Game * game, Levels * levels) {
- if (game->world.entitiesCount == 1)
- return true;
+ int i;
+ Level3 * data = (Level3*)levels->data;
+ bool levelDone = false;
+
+ Vector3 groups[] = {
+ (Vector3){0.0, 0.0, 800.0},
+ (Vector3){0.0, 0.0, -800.0}
+ };
+
+ switch (data->stage) {
+ case 0:
+ if (game->world.entitiesCount == 1) {
+ Vector3 playerPosition = getEntityFromWorld(game->world, 0)->position;
+ Vector3 spacing = (Vector3){0.0, 15.0, 15.0};
+
+ for (i = 0; i < sizeof(groups) / sizeof(Vector3); ++i)
+ addSoldatoGroupWithLeader(game, ENTITY_CAPORALE, 3, Vector3Add(groups[i], playerPosition), spacing);
+
+ data->stage = 1;
+ }
+
+ break;
+ case 1:
+ if (game->world.entitiesCount == 1) {
+ levelDone = true;
+ }
+
+ break;
+ default:
+ levelDone = true;
+ break;
+ }
- return false;
+ return levelDone;
}
diff --git a/src/levels/level3.h b/src/levels/level3.h
index 85501a6..329627a 100644
--- a/src/levels/level3.h
+++ b/src/levels/level3.h
@@ -4,6 +4,10 @@
#ifndef LEVEL3_H
#define LEVEL3_H
+typedef struct Level3 {
+ int stage;
+} Level3;
+
void initLevel3(Game * game, Levels * levels);
void closelevel3(Levels * levels);
bool updateLevel3(Game * game, Levels * levels);