added a monster spawner and modified lvl mechanics

Monsters have a weighting on how many to spawn and roll which
specific monster to spawn from the pool. I have not added the
ability to advance levels yet, though that should work to
add monsters if the Floor number advances. I did notice a bug
where the player cannot be harmed by the monsters unless the
player moves into them, not the other way around. The monsters
seem to treat the player as a wall that cannot be passed through.
This is confusing because the code for the player and monsters match
as far as their ability to move into each other...
This commit is contained in:
Pat Wick
2024-03-12 20:13:02 -04:00
parent 12d0763a95
commit c3b2775a80
11 changed files with 133 additions and 30 deletions

11
map.py
View File

@@ -5,6 +5,9 @@ from wall import Wall
from random import randint
def board_edges(board_size):
"""The outline of the generated board. Used in angband to surround
the level with immovable objects to keep the enemies and player inside
"""
x,y = board_size
positions = []
top = [(i,0) for i in range(x)]
@@ -20,7 +23,7 @@ def inner_board(board_size):
for j in range(1,y-1):
positions.append((i,j))
return positions
def random_empty_position(game):
"""Returns a random empty position.
"""
@@ -43,6 +46,12 @@ def level_one(board_size):
for j in range((y - (y // 4)), y-1):
positions.append((i,j))
# Introduce randomness within predefined pattern
for _ in range(10): # Example: Add 10 random obstacles
rand_i = randint(1, x - 2)
rand_j = randint(1, y - 2)
positions.append((rand_i, rand_j))
# for i in range(1,x-1):
# for j in range(1,y-1):
# if i >=4 and i <= 7 or i >= 13 and i <= 16: