-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphics.py
49 lines (37 loc) · 1.14 KB
/
graphics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import numpy as np
import os
# Display title ASCII art and authors
def print_title():
file = open("title.txt", "r")
print(file.read())
file.close()
# Run the right clear command depending on what OS the user is using
def clear_screen():
if os.name == "nt":
os.system("cls")
else:
os.system("clear")
print_title()
class Grid:
GRID_SIZE = 10
def __init__(self):
self.grid = np.array([['.' for i in range(Grid.GRID_SIZE)] for j in range(Grid.GRID_SIZE)])
def display_grid(self):
print()
# Print column numbers
for i in range(Grid.GRID_SIZE):
if i == 0:
print(f" {i} ", end="")
else:
print(f"{i} ", end="")
print()
letter = 'A'
for i in range(Grid.GRID_SIZE):
# Print row letters
print(f"{letter} ", end="")
# Print rows from grid
for j in range(Grid.GRID_SIZE):
print(f"{self.grid[i, j]} ", end="")
print()
letter = chr(ord(letter) + 1)
print()