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


Python Camera.update方法代码示例

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


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

示例1: update

# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import update [as 别名]
def update(screen):
    """Updates the game state one step.
    """
    for entity in Entity.collection:
        entity.update()

    Camera.update()
    Editor.update(screen.get_size())
开发者ID:garred,项目名称:cuadrados,代码行数:10,代码来源:main.py

示例2: Game

# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import update [as 别名]
class Game(object):
    
    def __init__(self, screen):
        self.deaths = 0
        
        
        self.screen = screen
        self.level = Level('reallevel')
        self.spawn()
        
        self.game_area = screen.subsurface((0, 40, screen.get_width(), screen.get_height() - 40))
        self.cam = Camera(self.player, self.level.bounds, self.game_area.get_size())
        
        self.hud = screen.subsurface((0, 0, screen.get_width(), 40))
        self.deathtext = pygame.font.Font(None, 20)


    def spawn(self):
        self.player = Player((self.level.spawnPoint), self.level, self)
        
            
    def quit(self):
        self.done = True
    
    def loop(self):
        self.done = False
        self.clock = pygame.time.Clock()
        while not self.done:
            dt = self.clock.tick(30)

            #input
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    self.quit()
                elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                    self.quit()
                elif event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:
                    self.player.jump()

            #update
            self.player.update(dt)
            self.cam.update(self.player.rect)

            #draw
            self.hud.fill((80, 80, 80))
            text = self.deathtext.render("deaths: " + str(self.deaths), True, (0, 255, 0)) 
        
            self.hud.blit(text, (0, 0))

            self.game_area.fill((0,0,0))
            self.cam.draw_background(self.game_area, self.level.background)
            self.cam.draw_sprite(self.game_area, self.player)

            #refresh
            pygame.display.flip()
开发者ID:redbassett,项目名称:Jump,代码行数:57,代码来源:Game.py

示例3: __init__

# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import update [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

示例4: main

# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import update [as 别名]
def main():
    # Initialise screen
    pygame.init()
    screen = display.set_mode(DISPLAY)
    display.set_caption("Game")            

   # create npc
    npc_list = []
    npc = Npc(200, 120)
    npc1 = Npc(300, 160)
    npc_list.append(npc)
    npc_list.append(npc1)

    # create player
    player = Player(HERO_X, HERO_X, npc_list)

    # Fill background
    background = pygame.Surface(screen.get_size())    
    background.fill(Color(BACKGROUND_COLOR))             

    #create level
    ar_level_size = create_level(background)
    level_width = ar_level_size[0] * 32
    level_height = ar_level_size[1] * 32
    
    entities = ar_level_size[2]
    timer = time.Clock()    
   
    camera = Camera(level_width, level_height)
    
    while 1:
        timer.tick(240)
        
        if player.rect.x + player.rect.width >= level_width:
            right = False 
        if player.rect.x <= 0:
            left = False
        if player.rect.y + player.rect.height >= level_height:
            down = False 
        if player.rect.y <= 0:
            up = False  

        for event in pygame.event.get():
            if event.type == QUIT:
                return

        # Move the player if an arrow key is pressed
        key_press = pygame.key.get_pressed()
        if key_press[pygame.K_LEFT]:
            player.update(-1, 0)
        if key_press[pygame.K_RIGHT]:
            player.update(1, 0)
        if key_press[pygame.K_UP]:
            player.update(0, -1)
        if key_press[pygame.K_DOWN]:
            player.update(0, 1)
        
        camera.update(player)
        
        for e in entities:
            screen.blit(e.image, camera.apply(e))
                    
        player.draw(screen, camera)

        for npc in npc_list:
            npc.draw(screen, camera)

        display.flip()
开发者ID:HelgIn,项目名称:pygame,代码行数:70,代码来源:main.py

示例5: GameState

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

#.........这里部分代码省略.........

      glMatrixMode(GL_MODELVIEW)
      glLoadIdentity()
      self.camera.draw()

      # Redraw the current blur texture
      glPushAttrib(GL_VIEWPORT_BIT)

      # Change the viewport to match the size of the texture
      glViewport(0, 0, self.blurTexture.getTexWidth(),
                       self.blurTexture.getTexHeight())
      self.drawMotionBlur(self.player.drunkAmount)
      self.drawScene()

      # Copy the contents of the frame buffer into our blur texture
      self.blurTexture.bind()
      glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0,
                       self.blurTexture.getTexWidth(),
                       self.blurTexture.getTexHeight(),
                       0)
      self.blurTexture.unbind()

      # Clear the fram buffer again
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
      glPopAttrib()

      # Blend in the motion blur with the background color
      self.drawMotionBlur(self.player.drunkAmount)

      # Draw the scene on top of the motion blur
      self.drawScene()


   def update(self, dt):
      '''
      Updates the game simulation based on the amount of time that has passed
      since the previous frame.
      '''
      # Update the input system
      self.updateInput(dt)

      # Update the avatar
      self.player.update(dt)

      # Update the camera
      self.camera.setTarget(self.player.pos, self.player.rot)
      self.camera.update(dt)

      for i in range(len(self.npcs)):
         self.npcs[i].update(dt)

      # Calculate the FPS
      self.numFrames += 1
      self.frameTime += dt
      if self.frameTime > 0.5:
         self.fps = float(self.numFrames) / self.frameTime
         self.frameTime = 0.0
         self.numFrames = 0
         print 'FPS: %f' % (self.fps)


   def updateInput(self, dt):
      '''
      Updates the state of the input system and processes all currently active
      actions.
      '''
开发者ID:chadaustin,项目名称:isugamedev,代码行数:70,代码来源:GameState.py

示例6: GameWorld

# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import update [as 别名]
class GameWorld():
    ### Constructors ###

    ##  Constructs a game world instance with the initial world specified by
    #   the input name parameter.
    #
    #   @param world_name The identifier for the initial world to be loaded.
    def __init__( self, world_name="" ):
        self._world = World()

        segment = self._world.levels[ "2" ].segments[ "2.1" ]
        segment_dims = segment.get_pixel_dims()

        self._tilemap = segment.get_tiles()

        self._entities = []
        # TODO: Update this logic to more elegantly designate the entity that
        # will be followed by the camera.
        player_entity = None
        for ( (idx_x, idx_y), entity_class ) in segment.get_entities():
            entity_pos = ( TILE_DIMS[0] * idx_x, TILE_DIMS[1] * idx_y )
            entity_delta = PhysicalState( CompositeHitbox(entity_pos[0], entity_pos[1]) )
            entity = Entity( entity_class, entity_delta )

            if entity_class == "player":
                player_entity = entity

            self._entities.append( entity )

        self._camera = Camera( target=player_entity.get_hitbox().get_hitbox(),
            new_border=PG.Rect(0, 0, segment_dims[0], segment_dims[1]) )
        self._collision_detector = SpatialDictionary( segment_dims[0] / 16,
            segment_dims[0], segment_dims[1] )

        self._setup_collision_detector()

    ### Methods ###

    ##  Updates the state of the game world based on the given time delta,
    #   which represents the amount of time that has passed since the last update.
    #
    #   @param time_delta The amount of game time that has passed in the frame.
    def update( self, time_delta ):
        # TODO: Handle the events passed back by the `Entity` updates.
        for entity in self._entities:
            entity.update( time_delta )
        self._collision_detector.update()

        for entity_collision in self._collision_detector.get_all_collisions():
            self._resolve_entity_collision( list(entity_collision) )

        for entity in self._entities:
            self._resolve_tile_collisions( entity )

        self._camera.update( time_delta )

    ##  Notifies the game world of the given event, which is propogated to
    #   all proper entities on the next update.
    #
    #   @param event The event of which the game world will be notified.
    #   @param entities An optional listing of entities to be notified of the
    #    event.  If this list is empty, the event will be broadcasted.
    def notify_of( self, event, entities=[] ):
        entities_to_notify = self._entities if len(entities) == 0 else entities

        for entity in entities_to_notify:
            entity.notify_of( event )

    ##  @return A listing of all the entity objects contained within the world
    #    (of type `Entity` list).
    def get_entities( self ):
        return self._entities

    ##  @return A 2D matrix of strings where each string represents the
    #    identifier of the corresponding tile in the game world.
    def get_tilemap( self ):
        return self._tilemap

    ##  @return The rectangular view representing the player viewpoint of the
    #    game world (of type `pygame.Rect`).
    def get_viewport( self ):
        return self._camera.get_viewport()

    ### Helper Functions ###

    ##  Establishes the proper infrastructure to get the collision detection
    #   system for the world instance up and running.
    def _setup_collision_detector( self ):
        self._cdrepr2entity_dict = {}
        [ self._add_to_collision_detector( entity ) for entity in self._entities ]

    ##  Adds the given entity to the collision detection system.
    #
    #   @param entity The `Entity` object instance to be added to the collision
    #    detection system for the game world.
    def _add_to_collision_detector( self, entity ):
        for hitbox in entity.get_hitbox().get_hitboxes():
            self._cdrepr2entity_dict[ hitbox ] = entity
            self._collision_detector.add( hitbox )

#.........这里部分代码省略.........
开发者ID:churay,项目名称:zol,代码行数:103,代码来源:GameWorld.py

示例7: Game_State

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

#.........这里部分代码省略.........
        self.ds = None
        self.extras = []

    def restart(self):
        return Game_State(self.levelname, self.levelhandle, text=self.introte, name=self.inname,final=self.final)

    def getbinpos(self, spriteobj, skip=False):
        obj = spriteobj.rect
        top = obj.top - self.search_padding
        left = obj.left - self.search_padding
        right = obj.right + self.search_padding
        bottom = obj.bottom + self.search_padding
        pos = [(left, top), (right, top), (left, bottom), (right, bottom)]
        for i in range(0, 4):
            pos[i] = (math.floor(pos[i][0]/self.gridsize)*self.gridsize, math.floor(pos[i][1]/self.gridsize)*self.gridsize)
        newbins = list(set(pos))
        if not skip:
            spriteobj.current_bin_pos = newbins
        else:
            return newbins

    def get_binobjs(self, obj):
        positions = obj.current_bin_pos
        hashset = []
        for p in positions:
            h = self.hashgrid.get(p)
            if h != None:
                hashset += h
        return hashset

    def check_active_dialog(self):
        pass

    def update_score(self, dt):
        if dt >= 5:
                if self.current_score_rate > 0:
                    self.current_score_rate -= 5
                self.current_score += self.current_score_rate
                self.time_flag += dt

    def nextl(self):
        if self.levelname == '../images/ASCIILEVEL1.txt':
            self.music.stop()
            GAME_GLOBALS.GAME_STATE = Game_State(levelname='../images/bigelevatorthing.txt', level = level2.init, prev = self, health = self.Player.current_health, name=2, score = self.current_score, final= True, text = "Kill the enemies")
        elif self.levelname == '../images/ASCIILEVEL0.txt':
            self.music.stop()
            GAME_GLOBALS.GAME_STATE = Game_State(levelname='../images/ASCIILEVEL1.txt', level = level1.init, prev = self, health = self.Player.current_health, name=1, score = self.current_score, final= False, text = "Survive")
        elif self.levelname == '../images/bigelevatorthing.txt':
            self.music.stop()
            GAME_GLOBALS.GAME_STATE = Game_State(levelname='../images/ASCIILEVEL3.txt', level = level3.init, prev = self, health = self.Player.current_health, name=3, score = self.current_score, final= False, text = "Escape")
        elif self.levelname == '../images/ASCIILEVEL3.txt':
            self.music.stop()
            GAME_GLOBALS.GAME_STATE = Game_State(levelname='../images/ASCIILEVEL4.txt', level = level4.init, prev = self, health = self.Player.current_health, name=4, score = self.current_score, final= False, text = "Freedom")

    def update(self, event):

        self.getbinpos(self.Player)
        worldob = self.get_binobjs(self.Player)

        dt = float(time.time() - self.timer)
        if dt >= 1:
            pass
        if dt >=  3:
            self.intro_text.set_alpha(self.intro_text.get_alpha() - (self.fade_rate + 2))
        if self.intro_text.get_alpha() <= 0:
            pass
开发者ID:ckim89,项目名称:EVE,代码行数:70,代码来源:Game_State.py

示例8: GameScene

# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import update [as 别名]
class GameScene(Scene):
    def __init__(self, music, host):
        super(GameScene, self).__init__()
        self.background = Surface((WINDOW_WIGTH, WINDOW_HEIGHT))
        self.background.fill(Color(BACKGROUND_COLOR))
        timer = pygame.time.Clock()
        self.music = music
        self.enemy = []
        self.net=Net()
        self.net.subscribe(self.sync)
        self.host = host
        mouse.set_pos([200, 300])
        
        self.heroes = []
        self.up = self.down = self.left = self.right = False

        self.entitles_walls = pygame.sprite.Group()
        self.entitles = pygame.sprite.Group()
        self.addHero(Player(300, 55, 1))
        self.walls = []
        
        #map:
        self.map = open("maps/testmap.txt", "r")
        self.x = 0
        self.y = 0
        self.lenx = 0
        self.leny = 0
        for self.row in self.map:
            for self.col in self.row:
                if self.col == "-":
                    self.wall = wall(self.x, self.y)
                    self.entitles_walls.add(self.wall)
                    self.walls.append(self.wall)
                if self.col == " ":
                    self.floor = floor1(self.x, self.y)
                    self.entitles_walls.add(self.floor)
                self.x = self.x + BLOCK_X
            self.y = self.y + BLOCK_Y
            self.lenx = self.x / BLOCK_X
            self.leny += 1
            self.x = 0

        for i in self.heroes:
            self.entitles.add(i)

        total_level_width = self.lenx*WINDOW_WIGTH
        total_level_height = self.leny*WINDOW_HEIGHT

        self.camera = Camera(camera_configure, total_level_width, total_level_height)

        self.enemy = []
        if self.host:
            self.enemy = [Enemy(100, 100, 1), Enemy(200, 200, 2), Enemy(100, 500, 3)]
            for i in self.enemy:
                self.entitles.add(i)
        self.bul = []
        self.bul.append(Bullet(0,0))
        if self.music == True:
            pygame.mixer.music.load("music/Game.mp3")
            pygame.mixer.music.play(-1)

    def render(self, screen):
        screen.blit(self.background, (0, 0))

        for i in self.entitles_walls:
            screen.blit(i.image, self.camera.apply(i))

        for i in self.entitles:
            screen.blit(i.image, self.camera.apply(i))

        

    def update(self, dt):
        self.send_sync(self.net)
        self.heroes[0].update(self.up, self.down, self.left, self.right, self.walls, dt)
        for i in self.enemy:
            i.update(self.walls, self.heroes, self.bul, dt)
            if i.hp == 0:
                self.enemy.remove(i)
                del i
        for i in self.bul:
            i.update(self.walls, dt)
            if i.col == True:
                self.bul.remove(i)
                del i
        self.camera.update(self.heroes[0])
        for i in self.entitles:
            if i.par == "bul":
                if i.col == True:
                    self.entitles.remove(i)
            if i.par == "enemy" or i.par == "player":
                if i.hp == 0:
                    self.entitles.remove(i)
        if self.heroes[0].hp == 0:
            if self.music == True:
                    pygame.mixer.music.stop()
            self.manager.go_to(LoseScreen())


    def handle_events(self, events):
#.........这里部分代码省略.........
开发者ID:zebzer,项目名称:ZombieProject,代码行数:103,代码来源:Scene.py

示例9: WhatABlockGame

# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import update [as 别名]
class WhatABlockGame(object):

	WINDOW_SIZE = Vector2(1366, 768)
	Clock = 0
	isGameOver = False
	folderDir = ''
	assetDir = ''
	bgImage = ''
	cam = ''
	mapCollection = ''
	player = ''
	inputManager = ''
	myRFIDReader = ''
	player_revealver = ''
	bgSound = ''


	def __init__(self, WINDOW_SIZE):

		self.WINDOW_SIZE = Vector2(1366, 768)
		self.isGameOver = False
		self.playWithRFID = True

		self.folderDir = os.path.split(os.getcwd())[0]
		self.assetDir = self.folderDir + '/Assets/'


		self.inputManager = InputManager()
		if self.playWithRFID:
			self.myRFIDReader = RFIDReader()
			self.inputManager.setRFIDInput(self.myRFIDReader)

		pygame.init()
		self.clock = pygame.time.Clock()
		self.display = pygame.display.set_mode((self.WINDOW_SIZE.getX(), self.WINDOW_SIZE.getY()), pygame.FULLSCREEN)
		pygame.display.set_caption('What A Block')

		self.loadAssets()
		
		self.cam = Camera(offSet = Vector2(self.WINDOW_SIZE.getX()/2 , self.WINDOW_SIZE.getY()/2 - self.player.getHeight()/2), camSize = self.WINDOW_SIZE)

		
		self.player_revealver = Revealer(IsoToScreen(self.player.getIsoPos(), self.mapCollection.getBlockSize().getX(), self.mapCollection.getBlockSize().getY()), 60)

		pygame.mixer.music.play(-1)


	def loadAssets(self):
		
		pygame.mixer.music.load(self.assetDir + 'bgSound.mp3')
		self.mapCollection = MapCollection(currentMap = 0, assetDir = self.assetDir, WINDOW_SIZE = self.WINDOW_SIZE)
		self.player = Player(self.mapCollection.getCurrentMapObject().getPlayerStartPos(), assetDir = self.assetDir, blockWidth = self.mapCollection.getBlockSize().getX(), blockHeight = self.mapCollection.getBlockSize().getY(), moveSpeed = 0.1)
		self.mainFontSize = 50
		self.secondFontSize = 30
		self.thirdFontSize = 18
		self.mainFont = pygame.font.Font(self.assetDir + "Universe.ttf", self.mainFontSize)
		self.secondFont = pygame.font.Font(self.assetDir + "Universe.ttf", self.secondFontSize)
		self.thirdFont = pygame.font.Font(self.assetDir + "Universe.ttf", self.thirdFontSize)
		self.numberOfDeath = 0


	def render(self):

		#sent player into map for order of rendering purpose
		self.mapCollection.renderCurrentMap(self.display, camPos = self.cam.getPos(), player = self.player)


		self.renderGUI()

		pygame.display.flip()

	def renderGUI(self):

		levelText = str(self.mapCollection.getCurrentMapIndex())	#Level
		renderlevelText = self.thirdFont.render( levelText, 1, (255,255,255))
		self.display.blit(renderlevelText, (self.WINDOW_SIZE.getX()/2 - len(levelText) * self.thirdFontSize/2 + 5, self.WINDOW_SIZE.getY()*8.3/20))		

		deathCountText = str(self.numberOfDeath)	#Death
		renderDeathCountText = self.mainFont.render( deathCountText, 1, (0,0,0))
		self.display.blit(renderDeathCountText, (self.WINDOW_SIZE.getX()/2 - len(deathCountText) * self.mainFontSize/2 + 10, self.WINDOW_SIZE.getY()/9))

		bombCountText = str(self.player.getBomb())	#Bomb
		renderBombCountText = self.secondFont.render( bombCountText, 1, (127,100,0))
		self.display.blit(renderBombCountText, (self.WINDOW_SIZE.getX()*9/20 - len(deathCountText) * self.secondFontSize/2 + 10, self.WINDOW_SIZE.getY()*17/20))

		bulletCountText = str(self.player.getBullet()) #Bullet
		renderBulletCountText = self.secondFont.render( bulletCountText, 1, (127,100,0))
		self.display.blit(renderBulletCountText, (self.WINDOW_SIZE.getX()*11/20 - len(deathCountText) * self.secondFontSize/2 + 10, self.WINDOW_SIZE.getY()*17/20))

	def update(self):

		self.inputs()

		self.player.update(isoBlocks = self.mapCollection.getCurrentMapObject().getBlocks())

		self.player_revealver.setPos(self.player.getScreenPos())
		self.player_revealver.reveal(isoBlocks = self.mapCollection.getCurrentMapObject().getBlocks())

		self.checkPlayerFall()
		self.checkPlayerFallOut()
#.........这里部分代码省略.........
开发者ID:takkasila,项目名称:OOP_WhatABlock,代码行数:103,代码来源:WhatABlock.py

示例10: handle_player_input

# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import update [as 别名]
while not quit_game:

    # Get the time in milliseconds.
    start_frame_time = pygame.time.get_ticks()

    # Get all events that were triggered and process them.
    for event in pygame.event.get():

        if event.type == pygame.QUIT:
            quit_game = True

        handle_player_input(event)

    keys = pygame.key.get_pressed()

    camera.update(delta_time)
    control_player_motion(keys, delta_time)

    # Make the player shoot.
    if pygame.mouse.get_pressed()[0] and player_firing_timer >= player_firing_interval:
        fire_bullet()
        player_firing_timer = 0.0
    player_firing_timer += delta_time

    # Do background rendering first.
    screen.fill((0, 0, 0))
    for i in range(0, len(backgrounds)):
        screen.blit(backgrounds[i], (i*backgrounds[i].get_width()-camera.boundingBox.x, 0-camera.boundingBox.y))

    if do_flash_effect:
        flash_effect_timer += delta_time
开发者ID:ACM-Gamedev,项目名称:2DShooter,代码行数:33,代码来源:main.py


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