本文整理汇总了Python中ship.Ship.reverse_direction方法的典型用法代码示例。如果您正苦于以下问题:Python Ship.reverse_direction方法的具体用法?Python Ship.reverse_direction怎么用?Python Ship.reverse_direction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ship.Ship
的用法示例。
在下文中一共展示了Ship.reverse_direction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import reverse_direction [as 别名]
#.........这里部分代码省略.........
libtcod.console_blit(self.console, 0, 0, self.screen_width, self.screen_height, 0, 0, 0)
# Galaxy Map Border/Frame
libtcod.console_print_frame(self.galaxy_map_console, 0, 0, self.screen_width, self.screen_height,
clear=False, flag=libtcod.BKGND_SET, fmt=0)
# Title in the center of the top border
top_title = "[ Galaxy Map ]"
libtcod.console_print_ex(self.galaxy_map_console,
(self.screen_width/2) - (len(top_title)/2),
0, libtcod.BKGND_SET, libtcod.LEFT, top_title)
# Title in the center of the bottom border
bottom_title = "[ Seed: {0} ]".format( self.galaxy.seed )
libtcod.console_print_ex(self.galaxy_map_console,
(self.screen_width/2) - (len(bottom_title)/2),
self.screen_height-1, libtcod.BKGND_SET, libtcod.LEFT, bottom_title)
# Extra info in upper right
info = ("Current Sector: {0}\n"
"Target Sector: {1}\n").format(
self.galaxy.sectors[self.galaxy.current_sector].name,
self.galaxy.sectors[ self.galaxy.sectors[self.galaxy.current_sector].neighbors[self.galaxy.targeted_sector_index] ].name
)
libtcod.console_print_ex(self.galaxy_map_console,
1, 1, libtcod.BKGND_SET, libtcod.LEFT, info)
libtcod.console_blit(self.galaxy_map_console, 0, 0, self.screen_width, self.screen_height, 0, 0, 0, 1.0, 0.25)
libtcod.console_flush()
self.buffer.clear(self.sector.background[0], self.sector.background[1], self.sector.background[2])
player_action = self.handle_keys()
if player_action == 1:
done = True
self.current_screen = 'flight'
def landed_loop(self, planet_index):
self.current_screen = 'landed'
done = False
planet = self.sector.planets[planet_index]
while not done:
libtcod.sys_check_for_event(libtcod.KEY_PRESSED|libtcod.KEY_RELEASED|libtcod.EVENT_MOUSE, self.key, self.mouse)
self.starfield.draw()
self.nebula.draw()
planet.render_detail()
self.buffer.blit(self.console)
libtcod.console_blit(self.console, 0, 0, self.screen_width, self.screen_height, 0, 0, 0)
libtcod.console_print_frame(self.landing_console, 0, 0, self.landing_screen_width, self.landing_screen_height, clear=True, flag=libtcod.BKGND_SET, fmt=0)
title = "[ Landed at {0} ]".format(planet.name)
libtcod.console_print_ex(self.landing_console,
(self.landing_screen_width/2) - (len(title)/2),
0, libtcod.BKGND_SET, libtcod.LEFT, title)
libtcod.console_print_ex(self.landing_console,
2, 2, libtcod.BKGND_SET, libtcod.LEFT,
"Class: {0}".format(planet.planet_class.title()))
libtcod.console_print_ex(self.landing_console,
2, 3, libtcod.BKGND_SET, libtcod.LEFT,
"Diameter: {0}".format(planet.width))
libtcod.console_print_ex(self.landing_console,
2, 4, libtcod.BKGND_SET, libtcod.LEFT,
"Seed: {0}".format(planet.seed))
libtcod.console_blit(self.landing_console, 0, 0, self.landing_screen_width, self.landing_screen_height, 0, self.screen_width/2, 2, 1.0, 0.25)
libtcod.console_flush()
self.buffer.clear(self.sector.background[0], self.sector.background[1], self.sector.background[2])
player_action = self.handle_keys()
if player_action == 1:
self.add_message("Taking off from {0}".format(planet.name))
self.current_screen = 'flight'
done = True
def main_loop(self):
while not libtcod.console_is_window_closed():
libtcod.sys_check_for_event(libtcod.KEY_PRESSED|libtcod.KEY_RELEASED|libtcod.EVENT_MOUSE, self.key, self.mouse)
self.render_all()
player_action = self.handle_keys()
if player_action == 1:
break
if self.player_ship.throttle_open:
self.player_ship.apply_thrust()
if self.player_ship.laser_firing:
self.player_ship.fire_laser()
if self.player_ship.reversing:
self.player_ship.reverse_direction()
elif self.player_ship.turning_left:
self.player_ship.turn_left()
elif self.player_ship.turning_right:
self.player_ship.turn_right()