def draw(self, win):
h, w = win.getmaxyx()
win.bkgdset(' ', self.skycolor)
# Draw Particles
parttype = self.conf['particles_type']
for part in self.particles:
part[0] = part[0]%w
part[1] = part[1]%h
try:
if(parttype == 'Snow'):
if(part[2] > 60):
win.addstr(int(part[1]), int(part[0]), '?')
else:
win.addstr(int(part[1]), int(part[0]), '·')
elif(parttype == 'Rain'):
win.addstr(int(part[1]), int(part[0]), '|', curses.color_pair(2))
elif(parttype == 'Stars'):
if(randint(0, 200) == 0):
if(part[2] > 60):
win.addstr(int(part[1]), int(part[0]), '?')
else:
win.addstr(int(part[1]), int(part[0]), '?')
else:
if(part[2] > 60):
win.addstr(int(part[1]), int(part[0]), '?')
elif(part[2] > 40):
win.addstr(int(part[1]), int(part[0]), '·')
else:
win.addstr(int(part[1]), int(part[0]), '?')
except curses.error:
pass
# Draw Ground
try:
for x, col in enumerate(self.ground):
for y, cell in enumerate(col):
if(cell):
win.addstr(y, x, self.groundchars[x][y], self.groundcolor)
except curses.error:
# The very last character will error so except only once
pass
评论列表
文章目录