world.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:loltanks 作者: whentze 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号