Made a GameMap stub
The map is revolved around a dictionary. This way there's no need to spend computing power expanding the map, if it was a 2-dimensional list.
This commit is contained in:
parent
641d6be8f0
commit
c1b5a80f7f
33
GameMap.py
Normal file
33
GameMap.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
class GameMap:
|
||||||
|
|
||||||
|
def __init__(self, max_size_x = float('inf'), max_size_y = float('inf')):
|
||||||
|
self.max_size_x = max_size_x
|
||||||
|
self.max_size_y = max_size_y
|
||||||
|
data = {}
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def get_max_size_x(self):
|
||||||
|
return self.size_x
|
||||||
|
|
||||||
|
|
||||||
|
def get_max_size_y(self):
|
||||||
|
return self.size_y
|
||||||
|
|
||||||
|
|
||||||
|
def add_player_mark(self, x, y, player):
|
||||||
|
if x <= max_size_x or y <= max_size_y:
|
||||||
|
self.data[(x,y)] = player
|
||||||
|
else:
|
||||||
|
raise IndexOutOfBounds
|
||||||
|
|
||||||
|
|
||||||
|
def equal(what, to):
|
||||||
|
what = to
|
||||||
|
|
||||||
|
|
||||||
|
def clear_map(self):
|
||||||
|
self.data = {}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user