generated from mwc/project_game
added char attributes, enemies, combat
I used the strategy/movement system for NPCs from Beast and added in some of my own mechanics for melee and projectile combat. A leveling system has also been established which modifies damage as the player levels up. Next order of business is level design, monster spawning, and game progression.
This commit is contained in:
61
map.py
Normal file
61
map.py
Normal file
@@ -0,0 +1,61 @@
|
||||
from retro.game import Game
|
||||
from random import sample
|
||||
from player import Player
|
||||
from wall import Wall
|
||||
from random import randint
|
||||
|
||||
def board_edges(board_size):
|
||||
x,y = board_size
|
||||
positions = []
|
||||
top = [(i,0) for i in range(x)]
|
||||
bottom = [(i,y-1) for i in range(x)]
|
||||
left = [(0,j) for j in range(1,y-1)]
|
||||
right = [(x-1,j) for j in range(1,y-1)]
|
||||
return top + bottom + left + right
|
||||
|
||||
def inner_board(board_size):
|
||||
x,y = board_size
|
||||
positions = []
|
||||
for i in range(1,x-1):
|
||||
for j in range(1,y-1):
|
||||
positions.append((i,j))
|
||||
return positions
|
||||
|
||||
def random_empty_position(game):
|
||||
"""Returns a random empty position.
|
||||
"""
|
||||
agents_by_position = game.get_agents_by_position()
|
||||
while True:
|
||||
x, y = game.board_size
|
||||
i = randint(1, x-2)
|
||||
j = randint(1, y-2)
|
||||
if not agents_by_position[(i,j)]:
|
||||
return (i,j)
|
||||
|
||||
def level_one(board_size):
|
||||
x,y = board_size
|
||||
positions = []
|
||||
for i in range(1,x-1):
|
||||
for j in range(1,y//4):
|
||||
if i <= x // 4 or i >= x - (x // 4):
|
||||
positions.append((i,j))
|
||||
for i in range(1,x//4):
|
||||
for j in range((y - (y // 4)), y-1):
|
||||
positions.append((i,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:
|
||||
# if j >= 4 and j <= 7 or j >= 13 and j <= 16:
|
||||
# positions.append((i,j))
|
||||
return positions
|
||||
|
||||
def level_two(board_size):
|
||||
x,y = board_size
|
||||
positions = []
|
||||
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:
|
||||
if j >= 4 and j <= 7 or j >= 13 and j <= 16:
|
||||
positions.append((i,j))
|
||||
return positions
|
||||
Reference in New Issue
Block a user