aboutsummaryrefslogtreecommitdiff
path: root/console
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-02-10 18:45:36 +0100
committerlonkaars <l.leblansch@gmail.com>2021-02-10 18:45:36 +0100
commit13156fc37de0cdd8db21c70c25ca407ae56f03c0 (patch)
treeeae774b8306b3b39b63b5b1d2e01c6cf7ed3380f /console
parent4686fe29b1e9e9f1545deef500fe3bc462527ed4 (diff)
added function for checking if coordinate in play field
Diffstat (limited to 'console')
-rw-r--r--console/main.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/console/main.py b/console/main.py
index dbf414f..f9b7e39 100644
--- a/console/main.py
+++ b/console/main.py
@@ -8,11 +8,19 @@ EMPTY = Fore.LIGHTBLACK_EX + "_" + Fore.RESET
class bord:
def __init__(self, w, h):
- self.board = [[EMPTY for x in range(w)] for u in range(h)]
+ self.width = w
+ self.height = h
+ self.board = [[EMPTY for x in range(self.width)] for u in range(self.height)]
def print(self):
print("\n".join([" ".join(y) for y in self.board]))
+ def outside_board(self, coords):
+ return coords[0] < 0 or \
+ coords[1] < 0 or \
+ coords[0] > self.width - 1 or \
+ coords[1] > self.height - 1
+
def drop_fisje(self, column, disc):
row = -1
for r in range(len(self.board)):