本文整理汇总了Python中Character.Character.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Character.draw方法的具体用法?Python Character.draw怎么用?Python Character.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Character.Character
的用法示例。
在下文中一共展示了Character.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import draw [as 别名]
def draw(self, screen, camera):
Character.draw(self, screen, camera)
if self.damageCooldown > 0:
damageRect = pygame.Rect(0, 0, self.sheetCoord[self.posIndex][self.posImageIndex][2], self.sheetCoord[self.posIndex][self.posImageIndex][3])
damageSurface = pygame.Surface((damageRect.w, damageRect.h))
damageSurface.fill((255, 0, 0))
damageSurface.set_alpha(self.damageCooldown)
mask = pygame.transform.flip(pygame.transform.rotate(\
self.sheet.subsurface(self.sheetCoord[self.posIndex][self.posImageIndex]), self.angle), \
self.flipH, self.flipV).copy()
mask = mask.convert_alpha(screen)
blit_mask(damageSurface, screen, (self.rect.x + camera.state.x, self.rect.y + camera.state.y), mask, damageRect)
示例2: reset_game
# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import draw [as 别名]
def reset_game(screen):
"""
Reset the game variables & map
:param screen: pygame screen
"""
global all_sprite_list
global wall_list
global screen_width
global screen_height
global luci
global michael
global time_since_last_powerup
global lucis_shots
global michaels_shots
global luci_group
global michael_group
global powerups
global played_death_music
played_death_music = False
all_sprite_list = pygame.sprite.Group()
wall_list = pygame.sprite.Group()
BLACK = pygame.Color(0, 0, 0)
# top wall
wall = Wall(10, 0, screen_width, 10, BLACK)
wall_list.add(wall)
all_sprite_list.add(wall)
# bottom wall
wall = Wall(0, screen_height - 10, screen_width, 10, BLACK)
wall_list.add(wall)
all_sprite_list.add(wall)
# left wall
wall = Wall(0, 0, 10, screen_height, BLACK)
wall_list.add(wall)
all_sprite_list.add(wall)
# right wall
wall = Wall(screen_width - 10, 0, 10, screen_height, BLACK)
wall_list.add(wall)
all_sprite_list.add(wall)
for i in range(20):
# (x, y, width, height, color)
rand_x = random.randrange(0, screen_width-60)
rand_y = random.randrange(0, screen_height-60)
rock = Rock(rand_x, rand_y)
wall_list.add(rock)
all_sprite_list.add(rock)
# create Lucifer Morningstar character
rand_x = random.randrange(0, screen_width/2)
rand_y = random.randrange(0, screen_height-300)
luci = Character("Luci", rand_x, rand_y, wall_list, screen)
luci.draw(screen)
# create Archangel Michael character
rand_x = random.randrange(screen_width/2, screen_width-200)
rand_y = random.randrange(0, screen_height-300)
michael = Character("Michael", rand_x, rand_y, wall_list, screen)
michael.draw(screen)
all_sprite_list.add(luci)
all_sprite_list.add(michael)
# to check if a shot hits a player
luci_group = pygame.sprite.Group()
michael_group = pygame.sprite.Group()
luci_group.add(luci)
michael_group.add(michael)
lucis_shots = pygame.sprite.Group()
michaels_shots = pygame.sprite.Group()
# powerups
powerups = pygame.sprite.Group()
time_since_last_powerup = [0]