当前位置: 首页>>代码示例>>Python>>正文


Python Camera.draw_grps方法代码示例

本文整理汇总了Python中Camera.draw_grps方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.draw_grps方法的具体用法?Python Camera.draw_grps怎么用?Python Camera.draw_grps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Camera的用法示例。


在下文中一共展示了Camera.draw_grps方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import draw_grps [as 别名]
class Game:

  def __init__(self, screen):
    self.screen = screen
    self.map_rows = len(map)
    self.map_cols = len(map[0])
    self.world_rect = pygame.Rect(0, 0, TILE_SIZE*(self.map_cols+1), SCR_SIZE[1])
    self.bg_col = (0x69, 0x50, 0x36)
    self.lives = 4 # should be in player class but whatever
    self.big_font = pygame.font.Font(join('data', 'cour.ttf'), 72)
    self.font = pygame.font.Font(join('data', 'cour.ttf'), 30)

    self.load_grps()
    self.load_data()

  def load_grps(self):
    self.static_sprites = SPRITE_GRP()
    self.wall_sprites = SPRITE_GRP()
    self.player_sprites = SPRITE_GRP()
    self.block_sprites = SPRITE_GRP()

    self.all = self.block_sprites, self.player_sprites, self.wall_sprites,\
                self.static_sprites
    
  def load_data(self):
    # Static stuff first
    self.ceil = Ceil()
    self.ceil.player_lives = self.lives
    self.ground = Ground()
    self.static_sprites.add(self.ceil, self.ground)

    # Wall stuff
    self.wall = Wall()
    self.wall_sprites.add(self.wall)

    # Player stuff
    self.player = Player()
    self.player_sprites.add(self.player, self.player.bullet)
    self.player.add_collision_grps(*self.all)

    # Block stuff
    self.map_var = 1
    self.render_blocks(0, self.map_cols/4)

  def render_blocks(self, start, end):
    for y in xrange(self.map_rows):
      for x in xrange(start, end):
        xx, yy = TILE_SIZE * x, TILE_SIZE * y + CEIL_Y
        cell = map[y][x]
        pos = xx, yy
        if cell == '.': continue
        elif cell == '#':
          self.block_sprites.add(Block(pos=pos, unbreakable=1))
        elif cell == '0':
          self.block_sprites.add(Block(pos=pos, reflect=1))
        elif cell == '*':
          self.block_sprites.add(Block(pos=pos))
        elif cell == '^':
          self.block_sprites.add(Spike(pos=pos))
        elif cell == '@':
          r = Rock(pos=pos)
          r.player = self.player
          r.ground = self.ground
          self.block_sprites.add(r)


  def start(self):
    self.clock = pygame.time.Clock()
    self.keep_going = 1
    self.camera = Camera(screen, self.world_rect, self.player)
    self.blank_scr("OMFG A WALL\nOF LAVA!\nRUN AWAY!")

    while self.keep_going:
      self.clock.tick(FRAME_RATE)
      for event in pygame.event.get():
        if event.type == QUIT:
          exit()
        if event.type == KEYDOWN:
          if event.key == K_ESCAPE:
            self.keep_going = 0
          """if event.key == K_z: # jump # handled in player class now
            if not self.player.states.jumping in self.player.state_lst and not self.player.states.falling in self.player.state_lst:
              self.player.state_lst.append(self.player.states.jumping)"""
          if event.key == K_x: # attack
            if not self.player.states.attacking in self.player.state_lst:
              self.player.state_lst.append(self.player.states.attacking)
              sounds['fire'].play()
          if event.key == K_f:
            print "FPS:", self.clock.get_fps()
          if event.key == K_p:
            self.blank_scr('PAUSED')

      self.screen.fill(self.bg_col, (0, CEIL_Y, SCR_SIZE[0], SCR_SIZE[1] - 2*CEIL_Y))
      self.camera.update()
      self.camera.update_grps(*self.all)
      self.check_some_collisions()
      self.camera.draw_grps(*self.all)
      if self.keep_going:
        pygame.display.flip()
    sounds['lava'].stop()
#.........这里部分代码省略.........
开发者ID:Jach,项目名称:ludum_dare_entries,代码行数:103,代码来源:main.py


注:本文中的Camera.draw_grps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。