Skip to content

Instantly share code, notes, and snippets.

@ModMaamari
Created June 21, 2020 10:48
Show Gist options
  • Save ModMaamari/81b8e7d963be3ca0674c6ac53739ce6c to your computer and use it in GitHub Desktop.
Save ModMaamari/81b8e7d963be3ca0674c6ac53739ce6c to your computer and use it in GitHub Desktop.
Field Class
class Field:
def __init__(self, height=10, width=5):
self.width = width
self.height = height
self.body = np.zeros(shape=(self.height, self.width))
def update_field(self,walls, player):
try:
# Clear the field:
self.body = np.zeros(shape=(self.height, self.width))
# Put the walls on the field:
for wall in walls:
if not wall.out_of_range :
self.body[wall.y:min(wall.y+wall.height,self.height),:] = wall.body
# Put the player on the field:
self.body[player.y:player.y+player.height,
player.x:player.x+player.width] += player.body
except :
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment