本文整理汇总了Python中Player.rotate方法的典型用法代码示例。如果您正苦于以下问题:Python Player.rotate方法的具体用法?Python Player.rotate怎么用?Python Player.rotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player.rotate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Scene
# 需要导入模块: import Player [as 别名]
# 或者: from Player import rotate [as 别名]
class Scene(State):
def __init__(self):
super(Scene, self).__init__()
self.all_object_list = pygame.sprite.Group()
self.troll_list = pygame.sprite.Group()
self.bullet_list = pygame.sprite.Group()
self.player = Player()
self.background = Object()
self.hud = HUD()
self.score = 0
self.game_over = False
def init(self):
self.read_scene()
# Scale background to screen size
self.background.image = pygame.transform.scale(self.background.image, (SCREEN_WIDTH, SCREEN_HEIGHT))
def process_events(self, event):
if event.type == pygame.MOUSEBUTTONDOWN:
return
#self.player.change_color(BLUE)
elif event.type == pygame.KEYDOWN:
if (event.ket == pygame.K_p):
self.pause()
def update(self):
if (not self.is_running):
return
# TEST
pos = pygame.mouse.get_pos()
self.player.rect.x = pos[0]
self.player.rect.y = pos[1]
def draw(self, screen):
screen.fill(WHITE)
#screen.blit(self.background.image, self.background.rect)
self.background.draw(screen)
self.all_object_list.draw(screen)
def read_scene(self):
with open(ResourceManager.scene_path_list[0]) as file:
self.read_background(file)
self.read_player(file)
def read_background(self, file):
file.readline()
image_id = int(file.readline().strip().split(' ')[1])
self.background.init('Image', None, file_name = ResourceManager.image_path_list[image_id])
def read_player(self, file):
file.readline()
image_id = int(file.readline().strip().split(' ')[1])
self.player.init('Image', None, file_name = ResourceManager.image_path_list[image_id], alpha = True)
self.player.move(*map(int, file.readline().strip().split(' ')[1:]))
self.player.rotate(float(file.readline().strip().split(' ')[1]))
self.player.scale(*map(int, file.readline().strip().split(' ')[1:]))
self.all_object_list.add(self.player)
示例2: Scene
# 需要导入模块: import Player [as 别名]
# 或者: from Player import rotate [as 别名]
#.........这里部分代码省略.........
self.read_field(file)
self.read_red_team(file)
self.read_blue_team(file)
self.read_selection_circle(file)
self.read_ball(file)
self.read_effect(file)
self.read_sound(file)
def read_hud(self, file):
file.readline()
hud_id = int(file.readline().strip().split(' ')[1])
self.hud.init(ResourceManager.instance().hud_path_list[hud_id])
def read_field(self, file):
# Read field
file.readline()
image_id = int(file.readline().strip().split(' ')[1])
self.field.init('Image', file_name = ResourceManager.instance().image_path_list[image_id])
self.field.scale_to(SCREEN_WIDTH, SCREEN_HEIGHT)
self.all_object_list.add(self.field)
# Read goal
file.readline()
image_id_1, image_id_2 = list(map(int, file.readline().strip().split(' ')[1:]))
self.goal.append(Object())
self.goal[-1].init('Image', file_name = ResourceManager.instance().image_path_list[image_id_1])
self.goal[-1].scale_to(SCREEN_WIDTH, SCREEN_HEIGHT)
self.goal[-1].set_layer(-1)
self.goal.append(Object())
self.goal[-1].init('Image', file_name = ResourceManager.instance().image_path_list[image_id_2])
self.goal[-1].scale_to(SCREEN_WIDTH, SCREEN_HEIGHT)
self.goal[-1].set_layer(-1)
self.all_object_list.add(self.goal)
def read_red_team(self, file):
self.teams[Team_side.LEFT] = dict()
file.readline()
image_id = int(file.readline().strip().split(' ')[1])
# Prototype
self.left_player.init('Image', file_name = ResourceManager.instance().image_path_list[image_id])
self.left_player.rotate(float(file.readline().strip().split(' ')[1]))
self.left_player.scale(*map(float, file.readline().strip().split(' ')[1:]))
self.left_player.translate(*map(int, file.readline().strip().split(' ')[1:]))
def read_blue_team(self, file):
self.teams[Team_side.RIGHT] = dict()
file.readline()
image_id = int(file.readline().strip().split(' ')[1])
# Prototype
self.right_player.init('Image', file_name = ResourceManager.instance().image_path_list[image_id])
self.right_player.rotate(float(file.readline().strip().split(' ')[1]))
self.right_player.scale(*map(float, file.readline().strip().split(' ')[1:]))
self.right_player.translate(*map(int, file.readline().strip().split(' ')[1:]))
def read_selection_circle(self, file):
file.readline()
image_id = list(map(int, (file.readline().strip().split(' ')[1:])))
image_id_green = image_id[0]
image_id_red = image_id[1]
# Green circle
self.selection_circle.append(Object())
self.selection_circle[-1].init('Image', file_name = ResourceManager.instance().image_path_list[image_id_green], alpha = True)
self.selection_circle[-1].rotate(float(file.readline().strip().split(' ')[1]))
self.selection_circle[-1].scale(*map(float, file.readline().strip().split(' ')[1:]))
self.selection_circle[-1].translate(*map(int, file.readline().strip().split(' ')[1:]))
# Red circle
self.selection_circle.append(self.selection_circle[-1].clone())
self.selection_circle[-1].setImage(ResourceManager.instance().image_path_list[image_id_red])
def read_ball(self, file):
file.readline()
image_id = int(file.readline().strip().split(' ')[1])
self.ball.init('Image', file_name = ResourceManager.instance().image_path_list[image_id], alpha = True)
self.ball.rotate(float(file.readline().strip().split(' ')[1]))
self.ball.scale(*map(float, file.readline().strip().split(' ')[1:]))
self.ball.translate(*map(int, file.readline().strip().split(' ')[1:]))
self.ball.set_radius()
self.all_object_list.add(self.ball)
def read_effect(self, file):
file.readline()
image_id = int(file.readline().strip().split(' ')[1])
self.goal_image.init('Image', file_name = ResourceManager.instance().image_path_list[image_id], alpha = True)
self.goal_image.rotate(float(file.readline().strip().split(' ')[1]))
self.goal_image.scale(*map(float, file.readline().strip().split(' ')[1:]))
self.goal_image.translate(*map(int, file.readline().strip().split(' ')[1:]))
self.goal_image.set_layer(5)
def read_sound(self, file):
sound_num = int(file.readline().strip().split(' ')[1])
for i in range(sound_num):
sound_type = file.readline().strip().replace('#', '')
sound_id = int(file.readline().strip().split(' ')[1])
sound = pygame.mixer.Sound(ResourceManager.instance().sound_path_list[sound_id])
self.sound_list.update({sound_type: sound})
示例3: Scene
# 需要导入模块: import Player [as 别名]
# 或者: from Player import rotate [as 别名]
#.........这里部分代码省略.........
# Reset timer
self.time = pygame.time.get_ticks()
def process_raycast(self):
mouse_pos = pygame.mouse.get_pos()
hit_zombie = next((zombie for zombie in self.zombie_list.sprites() if zombie.collide_point(list(map(operator.sub, mouse_pos, zombie.get_pos())))), None)
if (hit_zombie is not None):
# Play zombie's death sound
self.sound_list['dying_scream'].play()
# Update hit count
self.hud.update_hit()
# Splash blood
blood = deepcopy(self.blood_splash)
blood.move_to(*self.player.get_pos())
blood.set_layer(self.all_object_list.get_top_layer() + 1)
blood.show()
self.all_object_list.add(blood)
hit_zombie.kill()
#----------------------------------------READ FILE SECTION-----------------------------------------------------
def read_scene(self):
with open(ResourceManager.scene_path_list[0]) as file:
self.read_hud(file)
self.read_background(file)
self.read_player(file)
self.read_grave(file)
self.read_zombie(file)
self.read_blood_splash(file)
self.read_sound(file)
def read_hud(self, file):
file.readline()
hud_id = int(file.readline().strip().split(' ')[1])
self.hud.init(ResourceManager.hud_path_list[hud_id])
def read_background(self, file):
file.readline()
image_id = int(file.readline().strip().split(' ')[1])
self.background.init('Image', file_name = ResourceManager.image_path_list[image_id])
self.all_object_list.add(self.background)
def read_player(self, file):
file.readline()
image_id = int(file.readline().strip().split(' ')[1])
self.player.init('Image', file_name = ResourceManager.image_path_list[image_id], alpha = True)
self.player.translate(*map(int, file.readline().strip().split(' ')[1:]))
self.player.rotate(float(file.readline().strip().split(' ')[1]))
self.player.scale(*map(float, file.readline().strip().split(' ')[1:]))
self.all_object_list.add(self.player)
def read_grave(self, file):
file.readline()
image_id = int(file.readline().strip().split(' ')[1])
grave = Object()
grave.init('Image', file_name = ResourceManager.image_path_list[image_id], alpha = True)
grave.translate(*map(int, file.readline().strip().split(' ')[1:]))
grave.rotate(float(file.readline().strip().split(' ')[1]))
grave.scale(*map(float, file.readline().strip().split(' ')[1:]))
for i in range(3):
for j in range(3):
self.grave_list.append(deepcopy(grave))
self.grave_list[-1].translate(200 * j, 100 * i)
self.grave_list[-1].set_layer(2 * (i + 1))
self.all_object_list.add(self.grave_list)
def read_zombie(self, file):
zombie_num = int(file.readline().strip().split(' ')[1])
for i in range(zombie_num):
image_id = int(file.readline().strip().split(' ')[1])
self.zombie_sprite.append(Zombie())
self.zombie_sprite[-1].init('Image', file_name = ResourceManager.image_path_list[image_id], alpha = True)
self.zombie_sprite[-1].translate(*map(int, file.readline().strip().split(' ')[1:]))
self.zombie_sprite[-1].rotate(float(file.readline().strip().split(' ')[1]))
self.zombie_sprite[-1].scale(*map(float, file.readline().strip().split(' ')[1:]))
def read_blood_splash(self, file):
file.readline()
blood_id = int(file.readline().strip().split(' ')[1])
self.blood_splash.init('Image', file_name = ResourceManager.image_path_list[blood_id], alpha = True)
self.blood_splash.translate(*map(int, file.readline().strip().split(' ')[1:]))
self.blood_splash.rotate(float(file.readline().strip().split(' ')[1]))
self.blood_splash.scale(*map(float, file.readline().strip().split(' ')[1:]))
def read_sound(self, file):
sound_num = int(file.readline().strip().split(' ')[1])
for i in range(sound_num):
sound_type = file.readline().strip().replace('#', '')
sound_id = int(file.readline().strip().split(' ')[1])
sound = pygame.mixer.Sound(ResourceManager.sound_path_list[sound_id])
self.sound_list.update({sound_type: sound})