Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create-wall-object #22

Merged
merged 10 commits into from
May 30, 2021
1 change: 1 addition & 0 deletions game/common/map_object.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from game.common.game_object import GameObject
from game.common.enums import *


class MapObject(GameObject):
def __init__(self, health=None, coordinates=None, hitbox=None, collidable=None):
super().__init__()
Expand Down
2 changes: 2 additions & 0 deletions game/common/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class GameStats:
game_board_width = 500
game_board_height = 500

default_wall_health = 50

player_stats = {
'starting_health': 10,
Expand Down
17 changes: 17 additions & 0 deletions game/common/walls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from game.common.map_object import MapObject
from game.common.stats import GameStats


class Walls(MapObject):
def __init__(self, coordinates, hitbox, health = GameStats.default_wall_health, destructible = False):
super().__init__(health, coordinates, hitbox, True )
self.destructible = destructible

def to_json(self):
data = super().to_json()
data['destructible'] = self.destructible
return data

def from_json(self, data):
super().from_json(data)
self.destructible = data['destructible']