-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboard.py
More file actions
151 lines (130 loc) · 4.8 KB
/
board.py
File metadata and controls
151 lines (130 loc) · 4.8 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
'''board.py'''
from config import FLOOR, PIPE, MOUNTAIN, WATER, BRICK, SURFACE
class Board():
'''code for board of mario'''
def __init__(self, height, width):
self.height = height
self.width = width
self.mat = []
for i in range(self.height):
self.mat.append([])
for i in range(self.height):
for j in range(self.width):
self.mat[i+j-j].append(' ')
def board_initialise(self, length):
'''Initialise the board'''
for i in range(30):
for j in range(length, length + 80):
self.mat[i][j] = ' '
# earth_bricks
for i in range(0, self.width, 1):
self.mat[self.height - 2][i] = FLOOR
self.mat[self.height - 3][i] = FLOOR
self.mat[self.height - 4][i] = FLOOR
# castle
self.mat[25][520] = '|'
self.mat[24][520] = '|'
self.mat[23][520] = '|'
self.mat[22][520] = '|'
self.mat[25][538] = '|'
self.mat[24][538] = '|'
self.mat[23][538] = '|'
self.mat[22][538] = '|'
for i in range(522, 538, 2):
self.mat[22][i] = '|'
for i in range(521, 538, 2):
if i % 4 == 1:
self.mat[21][i] = '_'
else:
self.mat[22][i] = '_'
self.mat[20][525] = '|'
self.mat[19][525] = '|'
self.mat[18][525] = '|'
self.mat[20][533] = '|'
self.mat[19][533] = '|'
self.mat[18][533] = '|'
self.mat[17][526] = '_'
self.mat[17][527] = '_'
self.mat[18][528] = '|'
self.mat[18][530] = '|'
self.mat[18][529] = '_'
self.mat[17][531] = '_'
self.mat[17][532] = '_'
self.mat[25][528] = '*'
self.mat[24][528] = '*'
self.mat[24][529] = '*'
self.mat[24][530] = '*'
self.mat[25][531] = '*'
self.mat[24][531] = '*'
def make_pipe(self, i, hgt1):
'''Make pipe'''
for j in range(self.height - 4 - hgt1, self.height - 4):
self.mat[j][i] = PIPE
self.mat[j][i + 4] = PIPE
for j in range(i, i + 5):
self.mat[self.height - 4 - hgt1][j] = PIPE
# spring
def make_spring(self, i, j):
'''Make Spring'''
self.mat[j][i] = '/'
self.mat[j - 1][i + 1] = '/'
self.mat[j][i + 1] = '\\'
self.mat[j - 1][i] = '\\'
self.mat[j - 2][i] = '-'
self.mat[j - 2][i + 1] = '-'
def make_cloud(self, j, k):
'''Make Cloud'''
for i in range(0, self.width - 100, 90):
self.mat[j][k + i] = '\033[1;36m(\033[1;m'
self.mat[j][k + 1 + i] = '\033[1;36m_\033[1;m'
self.mat[j][k + 2 + i] = '\033[1;36m_\033[1;m'
self.mat[j][k + 3 + i] = '\033[1;36m_\033[1;m'
self.mat[j][k + 4 + i] = '\033[1;36m)\033[1;m'
self.mat[j - 1][k + 2 + i] = '\033[1;36m(\033[1;m'
self.mat[j - 2][k + 3 + i] = '\033[1;36m_\033[1;m'
self.mat[j - 2][k + 4 + i] = '\033[1;36m_\033[1;m'
self.mat[j - 1][k + 5 + i] = '\033[1;36m)\033[1;m'
self.mat[j][k + 5 + i] = '\033[1;36m_\033[1;m'
self.mat[j][k + 6 + i] = '\033[1;36m_\033[1;m'
self.mat[j][k + 7 + i] = '\033[1;36m)\033[1;m'
def make_mountain(self, hgt2, mid):
'''Make cloud'''
for k in range(0, self.width - 100, 90):
for i in range(self.height - 4 - hgt2, self.height - 4):
for j in range(0, i - (self.height - 4 - hgt2)):
self.mat[i][k + mid - j] = MOUNTAIN
self.mat[i][k + mid + j] = MOUNTAIN
def make_brick(self, i, j, sym, size):
'''Make brick'''
for xps in range(i, i + size):
for yps in range(j, j + size):
self.mat[xps][yps] = BRICK
if size % 2 == 1 and sym != '*':
self.mat[i + size // 2][j + size // 2] = sym
def make_coin(self, i, j):
'''Make coin'''
self.mat[i][j] = '\x1b[1;35mO\x1b[1;m'
def make_pit(self, j, size):
'''Make pit'''
for i in range(self.height - 4, self.height - 1):
for k in range(j, j + size):
if i == self.height - 4:
self.mat[i][k] = " "
else:
self.mat[i][k] = WATER
def checkstar(self, xps, yps):
'''Check for asteric(*)'''
if self.mat[xps][yps] == WATER:
return 2
for i in SURFACE:
if self.mat[xps][yps] == i:
return 1
return 3
# changing name of print
def print_on_board(self, left, right):
'''Print Board'''
for i in range(self.height):
for j in range(left, right):
print(self.mat[i][j], end='')
print('')
BOARD = Board(30, 620)