diff --git a/CMakeLists.txt b/CMakeLists.txt index 80750a7..34d7312 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,7 @@ add_executable(breakhack src/stats src/actiontext src/random + src/pathfind ) target_link_libraries(breakhack diff --git a/data/monstergen.lua b/data/monstergen.lua index ac17c68..4dff4cb 100644 --- a/data/monstergen.lua +++ b/data/monstergen.lua @@ -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 }; diff --git a/src/monster.c b/src/monster.c index 3bf99f8..d716a44 100644 --- a/src/monster.c +++ b/src/monster.c @@ -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); diff --git a/src/random.c b/src/random.c index 08c5569..e1b9544 100644 --- a/src/random.c +++ b/src/random.c @@ -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); }