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


Python Player.draw方法代码示例

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


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

示例1: TestPlayer

# 需要导入模块: import Player [as 别名]
# 或者: from Player import draw [as 别名]
class TestPlayer(unittest.TestCase):
    def setUp(self):
        self.player = Player(0)

    def test_draw2_disc2(self):
        footman = Card.get_card('Footman')
        peasant = Card.get_card('Peasant')
        self.player.set_deck([footman, peasant])

        self.player.draw()
        self.player.draw()
        self.assertEqual(self.player.hand[0], footman)
        self.assertEqual(self.player.hand[1], peasant)

        self.player.discard(peasant)
        self.player.discard(footman)
        self.assertEqual(self.player.discard_pile[0], peasant)
        self.assertEqual(self.player.discard_pile[1], footman)

    def test_buy(self):
        test_card = "Footman"
        self.player.set_gold(Card.get_card(test_card).buy_cost)
        self.player.buy(test_card)
        self.assertEqual(self.player.gold, 0)
        self.assertEqual(self.player.discard_pile[0].name, test_card)
        self.assertEqual(self.player.grimoire.library[test_card], 3)

    def test_grimoire_properties(self):
        self.assertEqual(self.player.grimoire.cards["Footman"].name, "Footman")
        self.assertEqual(self.player.grimoire.cards["Peasant"].buy_cost, 25)

    def test_draw_and_recycle_deck(self):
        footman = Card.get_card('Footman')
        self.player.set_deck([footman])
        self.player.draw()
        self.player.discard(footman)
        self.assertEqual(self.player.discard_pile[0], footman)
        self.assertEqual(len(self.player.hand), 0)
        self.player.draw()
        self.assertEqual(self.player.hand[0], footman)
开发者ID:dustice,项目名称:grimwar,代码行数:42,代码来源:TestPlayer.py

示例2: World

# 需要导入模块: import Player [as 别名]
# 或者: from Player import draw [as 别名]
class World(object):
    def __init__(self):
        self.gravity = 1
        self.floors = []

        # Background debe pertenecer a mapa? opinar
        self.backGround = Sprite()
        self.backGround.src = None
        self.backGround.dst = None

        self.floor = Sprite()
        self.floor.src = None
        self.floor.setDstSize(800, 128)
        self.floor.setDstPos(0, 600 - 128)
        self.floors.append(self.floor)

        self.wallA = Sprite()
        self.wallA.src = None
        self.wallA.setDstSize(128, 64)
        self.wallA.setDstPos(250, 600 - 225)
        self.floors.append(self.wallA)

        self.wallB = Sprite()
        self.wallB.src = None
        self.wallB.setDstSize(256, 64)
        self.wallB.setDstPos(512, 600 - 400)
        self.floors.append(self.wallB)

        self.player = Player(10, 26, 0)  # <-- (velocidad x) (velocidad y) (velocidad en el aire x sin implementar)
        self.player.setSrcSize(64, 64)
        self.player.setSrcPos(0, 0)
        self.player.setDstSize(64, 64)
        self.player.setDstPos(100, 100)

    def update(self):
        updating = True
        i = 0
        # print self.floors
        while updating and i < len(self.floors):  # <-- evitando el break de carlos
            # print i
            if not self.player.collide(self.floors[i]):
                self.player.src.y = 64
                self.player.onAir = True
                if self.player.goTo.y < 64:
                    self.player.goTo.y += self.gravity
            else:
                self.player.src.y = 0
                self.player.onAir = False
                self.player.goTo.y = 0
                self.player.dst.y = self.floors[i].dst.y - self.player.dst.h + 1
                updating = False

            i = i + 1

        self.player.move()

    def draw(self, renderer, images):  # el orden en que se dibuja todo:
        self.backGround.draw(renderer, images.getImage("background"))
        self.floor.draw(renderer, images.getImage("floor"))
        self.wallA.draw(renderer, images.getImage("wall"))
        self.wallB.draw(renderer, images.getImage("wall"))
        self.player.draw(renderer, images.getImage("player"))
开发者ID:zebus3d,项目名称:Juego_Pysdl2_Carlos,代码行数:64,代码来源:World.py

示例3: quit

# 需要导入模块: import Player [as 别名]
# 或者: from Player import draw [as 别名]
                    if s.rect.colliderect(b.rect):
                        s.active = False
    
        for h in shards:
            h.draw()
            if h.rect.colliderect(snb.rect):
                finish.play()
                LevelComplete = True

    
        if snb.alive == False:
            time = 0 
            snb.respawn(pstart[0], pstart[1])
    
        snb.update(pressed, screenDimensions)
        snb.draw()
    
        pygame.display.flip()

        for event in pygame.event.get():
            if event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    quit()
                if event.key == K_LEFT:
                    pressed['Left'] = True
                elif event.key == K_RIGHT:
                    pressed['Right'] = True
                elif event.key == K_LSHIFT:
                    pressed['Shift'] = True
                elif event.key == K_SPACE:
                    pressed['Space'] = True
开发者ID:nchen24,项目名称:superninjaboy,代码行数:33,代码来源:game.py

示例4: ord

# 需要导入模块: import Player [as 别名]
# 或者: from Player import draw [as 别名]
            if event.key == K_UP or event.key == ord('w'):
                player.moveUp(False)
            if event.key == K_DOWN or event.key == ord('s'):
                player.moveDown(False)
            if event.key == ord('m'):
                if musicPlaying:
                    pygame.mixer.music.stop()
                else:
                    pygame.mixer.music.play(-1, 0.0)
                musicPlaying = not musicPlaying
    
    windowSurface.fill(BLACK)    

    # draw the player
    player.update(pygame.time.get_ticks())
    player.draw(windowSurface)
	#make the player explode if he dies
    if player.lives <= 0:
        player.explode()
        if player.sprite.done:
            quit()

    # draw the asteroids
    addAsteroid()   
    for asteroid in asteroids:
        asteroid.update(pygame.time.get_ticks())
        asteroid.draw(windowSurface)

    # draw the lasers
    for laser in lasers:
        laser.draw(windowSurface)
开发者ID:erhs-53-hackers,项目名称:Asteroid-Colliders,代码行数:33,代码来源:Main.py

示例5: Hurdle

# 需要导入模块: import Player [as 别名]
# 或者: from Player import draw [as 别名]
                score = 0
                game_over = False
                # reinitialize the hurdle and the player
                hurdle = Hurdle(screen)
                player = Player(screen)

    if not game_over:
        hurdle.update()
        player.update()
        score += 10

    if player.collides_with(hurdle):
        game_over = True

    screen.fill(WHITE)
    hurdle.draw()
    player.draw()
    if game_over:
        game_over_label = game_over_font.render("Game Over!", 1, RED)
        screen.blit(game_over_label, GAME_OVER_POS)
        restart_label = font.render("press 'r' to restart", 1, GRAY)
        screen.blit(restart_label, RESTART_POS)

    score_label = font.render("Score: " + str(score), 1, BLACK)
    screen.blit(score_label, SCORE_LABEL_POS)

    clock.tick(FPS)
    pygame.display.flip()


pygame.quit()
开发者ID:jshin92,项目名称:block-hurdler,代码行数:33,代码来源:game.py

示例6: main

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

示例7: GameState

# 需要导入模块: import Player [as 别名]
# 或者: from Player import draw [as 别名]
class GameState(siren.State):
   def __init__(self):
      siren.State.__init__(self)
      self.ignoreMouseMove = True
      self.fps = 0.0
      self.numFrames = 0
      self.frameTime = 0.0

      # Initialize the input controls
      self.initInput()

      self.camera = Camera()

      # Create the player
      self.player = Player('Ben', 'John')
      self.player.pos = gmtl.Point3f(0, 0, -5)

      rot = gmtl.Quatf()
#      gmtl.set(rot, gmtl.AxisAnglef(gmtl.deg2Rad(180), 0,1,0))
      self.player.rot = rot

      # Big hack to get player rotation control to work
      self.vel_change = gmtl.Vec3f()

      self.npcs = []
      for i in range(4):
         av = siren.Avatar.create('John')
         av.setWCS(gmtl.EulerAngleXYZf(gmtl.deg2Rad(-90.0), 0, 0))
         av.setPos(gmtl.Vec3f(4.0*i, 0, -10))
         av.triggerAnimationCycle('DANCE')
         self.npcs.append(av)

      self.curAnim = 0
      self.anims = ['WALK',
                    'RUN',
                    'DANCE',
                    'IDLE',
                    'TYPE',
                    'SIT',
                    'WORK1',
                    'WORK2']

      # Create the texture to hold the motion blur
      self.blurTexture = siren.Texture(512, 512, 3, GL_RGB)

      # Inite the GL state
      glEnable(GL_DEPTH_TEST)
      glEnable(GL_TEXTURE_2D)
      glClearColor(0,0,0,1)


   def initInput(self):
      '''
      Initializes the input system, setting up all the appropriate bindings.
      '''
      # Load in the input bindings
      self.inputMgr = siren.InputManager()
      self.inputMgr.loadMappings('data/inputbindings.txt')

      # Movement
      self.actionForward         = self.inputMgr.getAction('FORWARD')
      self.actionBackward        = self.inputMgr.getAction('BACKWARD')
      self.actionStrafeLeft      = self.inputMgr.getAction('STRAFE_LEFT')
      self.actionStrafeRight     = self.inputMgr.getAction('STRAFE_RIGHT')

      # Camera control (for debugging)
      self.actionCameraZoomIn    = self.inputMgr.getAction('CAMERA_ZOOM_IN')
      self.actionCameraZoomOut   = self.inputMgr.getAction('CAMERA_ZOOM_OUT')
      self.actionCameraPitchUp   = self.inputMgr.getAction('CAMERA_PITCH_UP')
      self.actionCameraPitchDown = self.inputMgr.getAction('CAMERA_PITCH_DOWN')

      # Application control
      self.actionQuit            = self.inputMgr.getAction('QUIT')


   def draw(self):
      '''
      Renders a visualization of the current state of the game simulation.
      '''
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

      glMatrixMode(GL_PROJECTION)
      glLoadIdentity()
      gluPerspective(80.0, float(self.getWidth()) / self.getHeight(),
                     0.01, 500.0)

      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
#.........这里部分代码省略.........
开发者ID:chadaustin,项目名称:isugamedev,代码行数:103,代码来源:GameState.py

示例8: Game

# 需要导入模块: import Player [as 别名]
# 或者: from Player import draw [as 别名]
class Game(pyglet.window.Window):
  def __init__(self):
    super(Game, self).__init__()
    self.map = Map(data)
    self.pathfinding = AStar(self.map)
    pyglet.clock.schedule_interval(self.update, 1/120.0)
    self.pause = False
    self.message = Message(["Well hello there, you sexy beast. This is long text...", "You bastard"]);
    self.player = Player(self, self.map.grid[2,1], 0, 0)
    self.npc = NPC(self, self.map.grid[2,1], self.map.get_tile(7,5))
    self.player.create_animations()
    self.npc.create_animations()
    self.enemy = Enemy(self, self.map.grid[2,1], self.map.get_tile(1,5))
    self.enemy.create_animations()

    #little hack to get the viewport centered and then to follow the player
    temp_size = self.get_size()
    self.viewport_x = temp_size[0]/2
    self.viewport_y = 0

    self.offset_x = 0
    self.offset_y = 0
    
    self.update_viewport(temp_size[0]/2, 0)
    self.viewport_y = temp_size[1]/2
 
  def update(self, dt):
    self.clear()
    self.map.draw()
    self.player.draw()
    self.enemy.draw()
    self.npc.draw()
    self.player.inventory.update(self.offset_x, self.offset_y)

    if not self.message.finished:
      self.pause = True
      self.message.show()
    else:
      self.pause = False
    if self.pause:
      return  
    self.player.update(dt)
    if self.enemy.is_alive():
      if not self.enemy.tasks.has_tasks(): 
        self.enemy.calculate_next_move()
        if self.enemy.next_move != self.enemy.tile:
          self.enemy.tasks.add_task(self.enemy.next_move, TASK_WALK)
    self.enemy.update(dt)

  def update_viewport(self, x = -1, y = -1):
    x_pos, y_pos = x, y
    if x == -1:
      x_pos = -self.player.x + self.viewport_x
    if y == -1:
      y_pos = -self.player.y + self.viewport_y

    self.offset_x = x_pos
    self.offset_y = y_pos
    
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    glTranslatef(x_pos, y_pos, 1.0)
    glPushMatrix()
    glPopMatrix()
    

  def on_mouse_press(self, x, y, button, modifiers):
    x_pos = x - self.offset_x
    y_pos = y - self.offset_y

    
    if button == LEFT_CLICK:
      if self.message:
        self.message.next()
    if self.pause:
      return
    if button == RIGHT_CLICK:
      for tile in self.map.tiles:
        if(tile.contains(tile.image, x_pos, y_pos) == True):
          if tile.is_passable():
            move_loc = tile.get_move_loc()
            tasks = self.pathfinding.calcShortest(self.map.get_tile(self.player.grid_x, self.player.grid_y), self.map.get_tile(move_loc[0], move_loc[1]))
            if tasks:
              if len(tasks) > 1:
                self.player.tasks.clear_tasks()
                tasks.reverse()
                tasks.pop(0)
                index = len(tasks) - 1
                for task in tasks:
                  self.player.tasks.add_task(task, TASK_WALK)

                if type(tasks[index].person) == NPC:
                  action = self.player.tasks.add_task(tasks[index].person, TASK_SPEAK)
                if type(tasks[index].person) == Enemy:
                  tasks[index].person.under_attack = True
                  self.player.tasks = TaskQueue()
                  self.player.tasks.add_task(tasks[index].person, TASK_GOTO)
                  print "Task Attack"
                  self.player.tasks.add_task(tasks[index].person, TASK_ATTACK)
                  
#.........这里部分代码省略.........
开发者ID:edbrown,项目名称:LD24,代码行数:103,代码来源:main.py

示例9: attack_castle

# 需要导入模块: import Player [as 别名]
# 或者: from Player import draw [as 别名]
        badguy[0]-=7
        attacked = attack_castle(index)
        if not attacked:
            kill_badguys(index)
        index+=1

def draw_badguys() :
    for badguy in badguys:
        screen.blit(badguyimg,badguy)



while running:
    screen.fill(0)
    draw_scene()
    player.draw(screen)
    draw_arrows()
    move_badguys(badtimer)
    draw_badguys()   
    draw_clock(screen)
    draw_healthbar(screen)
    
    pygame.display.flip()
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            exit(0)
        if event.type == pygame.KEYDOWN:
            key_switch(True)
        if event.type == pygame.KEYUP:
            key_switch(False)
开发者ID:aniksa,项目名称:pythonStudy,代码行数:33,代码来源:test.py

示例10: __init__

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

#.........这里部分代码省略.........
        #Restart the game and spawn some stuff
        self.oldCars.append(GhostCar())
    
        for track in self.oldTracks:
            track.reset_count()
    
        self.startGame()

        
    
    def startGame(self):
        self.currentOffset = random.random() * math.pi * 2
        self.currentTrack = GhostTrack()

        self.player.resetCar();
        self.player.setAng(self.currentOffset);

        self.currentFrame = 0

        self.state = STATE_COUNTDOWN
        self.startTime = time.time()
        
        self.waves += 1

        self.coin = Coin()
    
    
    def main(self):
        while 1:
            self.screen.fill(self.black)

            for event in pygame.event.get():
                if event.type == pygame.QUIT: sys.exit()
                
                self.inputManager.onEvent(event);
        
            if self.state == STATE_GAME:
                self.player.update(self.inputManager);
        
                self.currentTrack.add_pos(self.player.getAng(), self.player.getRad())

                self.currentFrame += 1
        
                if self.currentFrame >= self.framesToRun:
                    self.restartGame()
        
                for i in range(0, len(self.oldCars)):
                    oldPos = self.oldTracks[i].get_next_pos()

                    self.oldCars[i].setAng(oldPos[0])
                    self.oldCars[i].setRad(oldPos[1] + self.oldOffsets[i])
                    self.oldCars[i].update()
                    self.oldCars[i].setFuture(self.oldTracks[i].get_future_pos(60))

                    if self.oldCars[i].checkCollision(self.player):
                        self.player.shakeSound.stop()

                        score = self.player.score
                        
                        self.explosionSound.play()

                        print "You died, final score: {}".format(score)

                        pygame.display.quit()

                        if(score >= highScore.getLowest()):
                            name = raw_input("New high score, what's your name?\n")

                            highScore.addScore(name, score)

                        highScore.save()
                        return


                self.coin.update(self.player)

            elif self.state == STATE_COUNTDOWN:
                if(time.time() > self.startTime + 1): 
                    self.state = STATE_GAME

                for car in self.oldCars:
                    car.updateGraphics()

                self.player.updateGraphics()
                self.coin.updateGraphics()

        
            #self.screen.blit(self.roundaboutImage, screenshaker.offset.getTuple(), self.roundaboutRect)
            self.screen.blit(self.roundaboutImage, screenshaker.offset.getTuple(), self.roundaboutRect)
            self.player.draw(self.screen);

            for car in self.oldCars:
                car.draw(self.screen)

            self.coin.draw(self.screen)

            if self.state == STATE_COUNTDOWN:
                self.screen.blit(self.readyImg, self.readyBox)

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

示例11: Mgame

# 需要导入模块: import Player [as 别名]
# 或者: from Player import draw [as 别名]
class Mgame(object):
    """
    object representing the game/level.
    allows for clean restart functionality.
    """
    def __init__(self):
        self.screen, self.clock = init_game()

        self.bg_img = pygame.image.load('../images/mario_bg_scaled_superCleared.png').convert_alpha()

        self.view_rect = None  # helps keeps mario from moving backwards :(

        self.is_running = True
        self.is_stage_complete = False
        self.is_game_over = False
        self.remaining_time_mario_sec = 400
        # TODO: TRANSFER SCORING TO PLAYER CLASS; better for multiplayer
        self.score = 0
        self.num_coins = 0
        self.num_lives = 3

        self.text_sprites = pygame.sprite.Group()
        screen_w, screen_h = GameSpecs.SCREEN_SIZE

        #self.bg_song = pygame.mixer.Song('/home/daxterix/Desktop/mario_theme.wav')
        pygame.mixer.music.load('../sounds/mario_theme2_converted.mp3')

        self.font = pygame.font.Font('../fonts/SuperMario256.ttf', 26)
        coin_img = pygame.image.load('../images/coin.png').convert_alpha()
        PermanentText("MARIO", (20, 20), self)
        self.score_text = PermanentText(str(self.score).zfill(6), (20, 40), self)
        self.num_coins_text = PermanentText("x" + str(self.num_coins).zfill(2), (screen_w / 3 + 20, 40), self)
        PictureLabel(self.num_coins_text, coin_img, self)
        PermanentText("WORLD", (2 * screen_w / 3 - 40, 20), self)
        PermanentText("1-1", (2 * screen_w / 3 - 10, 40), self)
        self.time_text = PermanentText("TIME", (screen_w - 100, 20), self)
        self.time_text = PermanentText(str(int(self.remaining_time_mario_sec)).zfill(3), (screen_w - 100, 40), self)

        self.player = None
        self.moving_left_wall = None   #set by create obstacles
        self.player_sprites = pygame.sprite.Group()
        self.block_sprites = pygame.sprite.Group()
        # contains moving invisible wall that affects mario only
        self.player_block_sprites = pygame.sprite.Group()
        self.enemy_sprites = pygame.sprite.Group()
        self.coin_sprites = pygame.sprite.Group()
        self.redmushroom_sprites = pygame.sprite.Group()
        self.greenmushroom_sprites = pygame.sprite.Group()
        self.flower_sprites = pygame.sprite.Group()
        self.fireball_sprites = pygame.sprite.Group()
        self.star_sprites = pygame.sprite.Group()
        self.flag_and_pole_sprites = pygame.sprite.Group()

    def increment_num_coins(self):
        self.num_coins += 1
        self.num_coins_text.set_text("x" + str(self.num_coins).zfill(2))

    def increase_score_by(self, amt, pos):
        self.score += amt
        PopupText(str(amt), pos, self)
        self.score_text.set_text(str(self.score).zfill(6))

    def increment_num_lives(self, pos):
        self.num_lives += 1
        PopupText("1-UP", pos, self)

    def decrement_num_lives(self, pos):
        self.num_lives -= 1
        if self.num_lives <= 0:
            self.player.init_game_over()
            #self.game_over()

    def run(self):
        """
        main game loop; creates sprites then
        constantly updates and draws them onto the screen.
        """
        pygame.mixer.music.stop()
        self.show_title_screen()
        pygame.mixer.music.play(-1)

        frames_acc, time_acc, fps = 0, 0, 0
        create_obstacles(self)
        create_enemies(self)

        self.player = Player((0, 0), self)

        while (not self.is_game_over) and (not self.is_stage_complete):
            dt = self.clock.tick(GameSpecs.FPS)  # how long it took to run the loop
            time_acc += dt
            frames_acc += 1
            if time_acc >= 500:
                fps = frames_acc / (time_acc / 500.0)
                # print fps
                time_acc = 0
                frames_acc = 0
                self.remaining_time_mario_sec -= 1
                if self.remaining_time_mario_sec < 0:
                    self.player.init_game_over()
                else:
#.........这里部分代码省略.........
开发者ID:pibe2,项目名称:mario_000,代码行数:103,代码来源:mario1_1.py

示例12: playerCollision

# 需要导入模块: import Player [as 别名]
# 或者: from Player import draw [as 别名]
                    playerCollision(-1,0)
                else:
                    move_monsters()
                
        
    #clear the background
    backbuffer.fill((20,20,20))

    #draw the dungeon
    if draw_radius:
        dungeon.draw_radius(backbuffer, player.x, player.y, 6)
    else:
        dungeon.draw(backbuffer)

    #draw the player's little dude        
    player.draw(backbuffer,0)

    #draw the back buffer
    screen.blit(backbuffer, (0,0))

    print_text(font1, 0, 0, "Dungeon Level " + str(level))

    print_text(font1, 600, 0, player.name)

    #special message text
    print_text(font2, 30, 570, message_text, message_color)

    print_stats()
    pygame.display.update()

    
开发者ID:RonnieLMayberry,项目名称:PAP-CS,代码行数:31,代码来源:Game.py

示例13: __init__

# 需要导入模块: import Player [as 别名]
# 或者: from Player import draw [as 别名]
class Game:
    def __init__(self, controller, resolution):
        self.controller = controller
        self.current_frame = 0
        self.resolution = resolution
        self.font = pygame.font.SysFont("consolas", resolution[0]/20)

        self.world = World(resolution)
        self.player = Player(self)

        self.score = 0

    def draw(self, screen):
        self.world.draw(screen, self.resolution, self.player)
        self.player.draw(screen, self.resolution)

        # render text
        score_label = self.font.render("Score: " + str(self.score), 0, (0, 0, 0))
        screen.blit(score_label, (2, 0))

        bullets_label = self.font.render("Bullets: " + str(self.player.bullet_count), 0, (0, 0, 0))
        screen.blit(bullets_label, (0, self.resolution[1]/20))

        bullets_label = self.font.render("X: " + str(self.player.x) + " Y: " + str(self.player.y), 0, (0, 0, 0))
        screen.blit(bullets_label, (0, self.resolution[1]/10))

        bullets_label = self.font.render("Angle: " + str(self.player.angle), 0, (0, 0, 0))
        screen.blit(bullets_label, (0, 1.5*self.resolution[1]/10))

    def update(self, framerate):
        self.current_frame += framerate
        self.player.action()
        self.world.update(framerate, self.player)

    def kill(self, animal):
        self.score += animal.weight * animal.age
        self.world.animals.remove(animal)

    def end(self):
        self.controller.change_view('main_menu')
        return

    def key_press(self, key):
        #ARROWS
        if key == 275:
            self.player.add_move_direction('R')
        elif key == 273:
            self.player.add_move_direction('U')
        elif key == 276:
            self.player.add_move_direction('L')
        elif key == 274:
            self.player.add_move_direction('D')
        #Z
        elif key == 122:
            self.player.use('PRIMARY')
        #X
        elif key == 120:
            self.player.use('SECONDARY')
        #ENTER
        elif key == 13:
            return
        #SHIFT
        elif key == 303:
            return

    def key_release(self, key):
        if key == 275:
            self.player.remove_move_direction('R')
        elif key == 273:
            self.player.remove_move_direction('U')
        elif key == 276:
            self.player.remove_move_direction('L')
        elif key == 274:
            self.player.remove_move_direction('D')
开发者ID:Emile-Filteau,项目名称:RedneckDeerHunting,代码行数:76,代码来源:Game.py

示例14: Game

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

#.........这里部分代码省略.........
                self.player.controls[self.keysdict[tkey]]+=1
            else:
                self.player.controls[self.keysdict[tkey]]=0

    def update(self):
        self.spawning()
        self.player.update()
        self.playerbullets.update()
        self.obstacles.update()
        self.enemies.update()
        self.bossparts.update()
        self.bossbody.update()
        self.particles.update()
        self.powerups.update()
        self.explosions.update()
        
        self.scrollind+=self.scrollspeed
        if self.scrollind%32==0 and self.scrollspeed!=0:
            self.hofflist[0]+=self.hscrollspeed
            if self.hofflist[0]>=len(self.tilelist)*32:
                self.hofflist[0]-=len(self.tilelist)*32
            if self.hofflist[0]<0:
                self.hofflist[0]+=len(self.tilelist)*32
            i=len(self.hofflist)-1
            while i>0:
                self.hofflist[i]=self.hofflist[i-1]
                i-=1
    def difficulty(self,level):
        self.diff=level
    def stopScrolling(self): #- for use with miniboss/main boss
        self.scrollspeed=0
    def resumeScrolling(self): #- for use with miniboss
        self.scrollspeed=2
    def draw(self):
        self.screen.fill((0,0,0))
        self.drawtiles()
        for obstacle in self.obstacles:
            obstacle.draw(self.screen)
        self.bar.draw(self.screen,self.player)
        for bossbody in self.bossbody:
            bossbody.draw(self.screen)
        for bullet in self.playerbullets:
            bullet.draw(self.screen)
        for enemy in self.enemies:
            enemy.draw(self.screen)
        for bosspart in self.bossparts:
            bosspart.draw(self.screen)
        if self.player.jumping==False:
            self.player.draw(self.screen)
        if self.player.jumping==True:
            self.player.draw(self.screen)
        for part in self.particles:
            part.draw(self.screen)
        for powerup in self.powerups:
            powerup.draw(self.screen)
        for explosion in self.explosions:
            explosion.draw(self.screen)
    def drawtiles(self):
        i=-1
        while(i<17):
            self.drawtilerow(-64+32*i+(self.scrollind%32),self.hofflist[i])
            i+=1
    def drawtilerow(self,y,hoff):
        trect=pygame.Rect(32+hoff%(len(self.tilelist)*32),0,12*32,32)
        tsurf=self.tilesurf.subsurface(trect)        
        self.screen.blit(tsurf,(32+32,y))
开发者ID:rEtSaMfF,项目名称:zenshiro,代码行数:70,代码来源:Game.py

示例15: min

# 需要导入模块: import Player [as 别名]
# 或者: from Player import draw [as 别名]
        if tigerwoods.rect.colliderect(player.rect):
            i_timer = pygame.time.get_ticks()
            player.hit = True
            health -=3
            if health >= 0:
                healthBar.image = pygame.image.load("health%d.png"%(health))
            if health < 0:
                health = 0
                playing = False 
                lose = True
    if i_timer + 2000 < pygame.time.get_ticks():
        player.hit = False
# draw phase
    screen.fill((0,0,0))
    background.blit(obstacles, obstacles.get_rect())
    player.draw(background)
    for enemy in enemy_list:
        enemy.draw(background)
    if tigerwoods.firing == True:
        tigerwoods.vomit(background)
    else:
        tigerwoods.draw(background)
    for x in shots:
        x.draw(background)
    for x in shots_e:
        x.draw(background)
    for x in shots_t:
        x.draw(background)
    vpCoordinate = min([vpCoordinate,player.rect.left - 100])
    viewport = background.subsurface((vpCoordinate, 0) + (1200, 720))
    screen.blit(viewport, vpRenderOffset)
开发者ID:LinkCable,项目名称:Spooned,代码行数:33,代码来源:main.py


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