-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.py
63 lines (41 loc) · 1.38 KB
/
render.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import numpy as np
class screen:
def __init__(self,w,h,dictionary):
self.h=h
self.w=w
self.screen=np.array([[0]*h]*w)
self.dictionary=dictionary
def printScreen(self,doBorder,doIndex):
#print("started print")
screenString=""
i = self.h - 1
while i >= 0:
if doIndex:
if(i < 10):
screenString += "0"
screenString += str(i)
for j in range(self.w):
screenString+=self.dictionary[self.screen[j][i]]
if doBorder == True:
screenString += "X"
screenString+="\n"
i-=1
if doIndex:
screenString += " "
for i in range(self.w):
if(i < 10):
screenString += "0"
screenString += str(i)
if doBorder == True:
screenString += ("XX" * (self.w + 1))
print(screenString)
#print("ended print")
def clear(self):
self.screen=np.array([[0]*self.h]*self.w)
def addElement(self,x,y,e):
self.screen[x][y]=e
def addBlock(self,x1,x2,y1,y2,e):
"""adds a block to world"""
for i in range(x2-x1+1):
for j in range(y2-y1+1):
self.addElement(i+x1,j+y1,e)