diff options
author | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-12-13 21:37:25 -0700 |
---|---|---|
committer | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-12-13 21:37:25 -0700 |
commit | 83a0e9ebe5600a431b9355ef623e57c61c220448 (patch) | |
tree | c1865672c32f0d39a304f099f7cf231b94c3521d | |
parent | 362b4f28fdd485e6aab7bee1bb4307797232a87c (diff) |
Made the annoying random level hehehe
-rw-r--r-- | src/levels/level11.c | 41 | ||||
-rw-r--r-- | src/levels/level11.h | 6 |
2 files changed, 46 insertions, 1 deletions
diff --git a/src/levels/level11.c b/src/levels/level11.c index 27ab28f..569a559 100644 --- a/src/levels/level11.c +++ b/src/levels/level11.c @@ -5,12 +5,51 @@ #include "entityGrouping.h" void initLevel11(Game * game, Levels * levels) { + int i; + const EntityType possibleTypes[] = {ENTITY_SOLDATO, ENTITY_SOLDATO, ENTITY_SOLDATO, ENTITY_CAPORALE, ENTITY_SERGENTE, ENTITY_MARESCIALLO, ENTITY_GENERALE}; + size_t possibleTypesSize = sizeof(possibleTypes) / sizeof(EntityType); + addEntryToWorld(&game->world, game, (WorldEntry){ENTITY_ANTIFA, (Vector3){0.0, 0.0, 0.0}, QuaternionIdentity()}); + + // Add lots of random entities to world. + // This level is ment to be fucking annoying hehehe. + SetRandomSeed(time(NULL)); + int randomEntityCount = GetRandomValue(LEVEL11_MIN_ENTITY_COUNT, LEVEL11_MAX_ENTITY_COUNT); + WorldEntry entries[randomEntityCount]; + + for (i = 0; i < randomEntityCount; ++i) { + + // Get random direction then push out to a random distance for a position. + Vector3 position = (Vector3){ + (float)GetRandomValue(-UCHAR_MAX, UCHAR_MAX) / UCHAR_MAX, + (float)GetRandomValue(-UCHAR_MAX, UCHAR_MAX) / UCHAR_MAX, + (float)GetRandomValue(-UCHAR_MAX, UCHAR_MAX) / UCHAR_MAX + }; + + float distance = GetRandomValue(LEVEL11_MIN_ENTITY_DISTANCE, LEVEL11_MAX_ENTITY_DISTANCE); + distance = (GetRandomValue(0, 1) == 0) ? distance : -distance; + + position = Vector3Scale(position, distance); + + // Add entry. + entries[i] = (WorldEntry){ + possibleTypes[GetRandomValue(0, possibleTypesSize - 1)], + position, + QuaternionIdentity() + }; + } + + addEntriesToWorld( + &game->world, + game, + entries, + sizeof(entries) / sizeof(WorldEntry) + ); } void closelevel11(Levels * levels) { } bool updateLevel11(Game * game, Levels * levels) { - return game->world.entitiesCount == 1 && false; + return game->world.entitiesCount == 1; } diff --git a/src/levels/level11.h b/src/levels/level11.h index ed89784..fe65405 100644 --- a/src/levels/level11.h +++ b/src/levels/level11.h @@ -4,6 +4,12 @@ #ifndef LEVEL11_H #define LEVEL11_H +#define LEVEL11_MIN_ENTITY_COUNT 15 +#define LEVEL11_MAX_ENTITY_COUNT 100 + +#define LEVEL11_MIN_ENTITY_DISTANCE 500.0 +#define LEVEL11_MAX_ENTITY_DISTANCE 2500.0 + void initLevel11(Game * game, Levels * levels); void closelevel11(Levels * levels); bool updateLevel11(Game * game, Levels * levels); |