本文整理汇总了Python中level.Level.get_player方法的典型用法代码示例。如果您正苦于以下问题:Python Level.get_player方法的具体用法?Python Level.get_player怎么用?Python Level.get_player使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类level.Level
的用法示例。
在下文中一共展示了Level.get_player方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import get_player [as 别名]
def run(screen, level_name = "w0-l0", score_mod = 0, score = None, joystick = None):
if (Variables.vdict["devmode"]):
edit_utils = Edit_utils()
done = False
objects = []
particles = []
if score == None:
score = Score(0)
#try:
level = Level(screen, level_name)
#except:
# error_message("Couldn't open level '" + level_name + "'")
# return END_QUIT
objects = level.get_objects()
player = level.get_player()
objects.append(player)
player.life = score.life
clock = pygame.time.Clock()
end_trigger = END_NONE
scripted_event_on = False
#There's no music at the moment:
#pygame.mixer.music.load( data.filepath(os.path.join("music", "music.ogg")) )
#pygame.mixer.music.play(-1)
scripted_events = level.get_scripted_events()
current_scripted_event = None
scripted_event_trigger = TRIGGER_LEVEL_BEGIN
flip_wait = -1
keys_released["K_z"] = True
keys_released["K_p"] = True
keys_released["K_s"] = True
keys_released["K_DOWN"] = True
keys_released["K_LEFT"] = True
keys_released["K_RIGHT"] = True
keys_released["K_UP"] = True
keys_released["J_B0"] = True
keys_released["J_B1"] = True
fading = True
fade_target = FADE_STATE_NONE
Util.fade_state = FADE_STATE_BLACK
flip_trigger_position = (0, 0)
changing_level = False
paused = False
#Main game loop
while (end_trigger == END_NONE or fading):
# Pygame event and keyboard input processing
for event in pygame.event.get():
if event.type == QUIT:
end_trigger = END_HARD_QUIT
if (event.type == KEYDOWN and event.key == K_ESCAPE):
end_trigger = END_QUIT
if fading == False:
fading = True
fade_target = FADE_STATE_HALF
inputs = parse_inputs(joystick)
trigger = None
if scripted_event_on:
if inputs.has_key("JUMP") or inputs.has_key("DOWN"):
cleared = True
moved = False
add_time = False #The ingame time counter toggle - this is False when the player can't control the character
if not scripted_event_on and not level.flipping and not fading and not paused \
and player.current_animation != "dying" and player.current_animation != "exit":
#There isn't anything special going on: player can control the character
#Translates input to commands to the player object
add_time = True
if inputs.has_key("LEFT"):
player.move((-PLAYER_MAX_ACC, 0))
moved = True
if inputs.has_key("RIGHT"):
player.move((PLAYER_MAX_ACC, 0))
moved = True
if inputs.has_key("JUMP"):
#.........这里部分代码省略.........
示例2: run
# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import get_player [as 别名]
def run(screen, level_number = 0, score = None, joystick = None):
done = False
objects = []
particles = []
if score == None:
score = Score(0)
level = Level(screen, str(level_number))
objects = level.get_objects()
player = level.get_player()
objects.append(player)
player.life = score.life
clock = pygame.time.Clock()
end_trigger = END_NONE
scripted_event_on = False
#There's no music at the moment:
#pygame.mixer.music.load( data.filepath(os.path.join("music", "music.ogg")) )
#pygame.mixer.music.play(-1)
scripted_events = level.get_scripted_events()
current_scripted_event = None
scripted_event_trigger = TRIGGER_LEVEL_BEGIN
''' for ev in scripted_events:
if ev.trigger_type == "level_begin":
scripted_event_on = True
current_scripted_event = ev
current_scripted_event_element = None
text = None
phase = 0
cleared = False # Clearing dialog boxes'''
flip_wait = -1
pygame.mixer.init()
keys_released = {}
keys_released["K_z"] = True
keys_released["K_DOWN"] = True
keys_released["K_UP"] = True
keys_released["J_B0"] = True
keys_released["J_B1"] = True
while (end_trigger == END_NONE):
# Pygame event and keyboard input processing
for event in pygame.event.get():
if event.type == QUIT:
end_trigger = END_HARD_QUIT
if (event.type == KEYDOWN and event.key == K_ESCAPE):
end_trigger = END_QUIT
keys = pygame.key.get_pressed()
inputs = [False, False, False, False, False, False, 0.0]
trigger = TRIGGER_NONE
if keys[K_LEFT]:
inputs[LEFT] = True
if keys[K_RIGHT]:
inputs[RIGHT] = True
if keys[K_DOWN]:
if keys_released["K_DOWN"]:
inputs[DOWN] = True
keys_released["K_DOWN"] = False
else:
keys_released["K_DOWN"] = True
if keys[K_z]:
inputs[UP] = True
if keys_released["K_z"]:
inputs[JUMP] = True
keys_released["K_z"] = False
else:
keys_released["K_z"] = True
if keys[K_UP]:
inputs[UP] = True
if keys_released["K_UP"]:
inputs[JUMP] = True
keys_released["K_UP"] = False
else:
keys_released["K_UP"] = True
if keys[K_F10]:
inputs[SPECIAL] = True
if joystick != None: # Parse joystick input
#.........这里部分代码省略.........