Created
June 21, 2020 10:48
-
-
Save ModMaamari/81b8e7d963be3ca0674c6ac53739ce6c to your computer and use it in GitHub Desktop.
Field Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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