Added some more undead and fixed the random function.

This commit is contained in:
Linus Probert 2017-12-18 09:11:00 +01:00
parent 6007976d23
commit 3a464d8ea6
4 changed files with 29 additions and 2 deletions

View File

@ -47,6 +47,7 @@ add_executable(breakhack
src/stats
src/actiontext
src/random
src/pathfind
)
target_link_libraries(breakhack

View File

@ -37,6 +37,8 @@ local texturePaths = {
}
local enemies = {
-- PESTS
{ texturePaths.pest0, texturePaths.pest1, 0, 0 },
{ texturePaths.pest0, texturePaths.pest1, 16, 0 },
{ texturePaths.pest0, texturePaths.pest1, 32, 0 },
@ -84,6 +86,25 @@ local enemies = {
{ texturePaths.pest0, texturePaths.pest1, 32, 112 },
{ texturePaths.pest0, texturePaths.pest1, 48, 112 },
-- UNDEAD
{ texturePaths.undead0, texturePaths.undead1, 0, 0 };
{ texturePaths.undead0, texturePaths.undead1, 16, 0 };
{ texturePaths.undead0, texturePaths.undead1, 32, 0 };
{ texturePaths.undead0, texturePaths.undead1, 48, 0 };
{ texturePaths.undead0, texturePaths.undead1, 64, 0 };
{ texturePaths.undead0, texturePaths.undead1, 80, 0 };
{ texturePaths.undead0, texturePaths.undead1, 96, 0 };
{ texturePaths.undead0, texturePaths.undead1, 112, 0 };
{ texturePaths.undead0, texturePaths.undead1, 0, 16 };
{ texturePaths.undead0, texturePaths.undead1, 16, 16 };
{ texturePaths.undead0, texturePaths.undead1, 32, 16 };
{ texturePaths.undead0, texturePaths.undead1, 48, 16 };
{ texturePaths.undead0, texturePaths.undead1, 64, 16 };
{ texturePaths.undead0, texturePaths.undead1, 80, 16 };
{ texturePaths.undead0, texturePaths.undead1, 96, 16 };
{ texturePaths.undead0, texturePaths.undead1, 112, 16 };
{ texturePaths.undead0, texturePaths.undead1, 0, 32 };
{ texturePaths.undead0, texturePaths.undead1, 16, 32 };
{ texturePaths.undead0, texturePaths.undead1, 32, 32 };

View File

@ -108,7 +108,7 @@ monster_move(Monster *m, RoomMatrix *rm)
unsigned int i, maxMoveAttempts = 6;
Position monsterRoomPos;
if (get_random(4) == 0)
if (get_random(2) == 0)
return;
monsterRoomPos = position_to_matrix_coords(&m->sprite->pos);

View File

@ -5,6 +5,11 @@
unsigned int
get_random(unsigned int max)
{
srand(time(NULL));
static bool seeded = false;
if (!seeded) {
srand(time(NULL));
seeded = true;
}
return rand() % (max + 1);
}