本文整理汇总了Python中ship.Ship.apply_thrust方法的典型用法代码示例。如果您正苦于以下问题:Python Ship.apply_thrust方法的具体用法?Python Ship.apply_thrust怎么用?Python Ship.apply_thrust使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ship.Ship
的用法示例。
在下文中一共展示了Ship.apply_thrust方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import apply_thrust [as 别名]
#.........这里部分代码省略.........
del(self.ships)
return int(galaxy_starting_seed), ship_value
def set_minimap(self, size):
self.minimap_width = size+3
self.minimap_height = size+3
self.minimap_buffer = libtcod.ConsoleBuffer(self.minimap_width, self.minimap_height)
self.minimap_console = libtcod.console_new(self.minimap_width, self.minimap_height)
libtcod.console_set_default_foreground(self.minimap_console, libtcod.white)
libtcod.console_set_default_background(self.minimap_console, libtcod.black)
def new_sector(self):
index, distance = self.sector.closest_planet(self.player_ship)
# if self.sector.distance_from_center(self.player_ship) > 500:
if distance > 500:
fade_speed = 10
# Fade out
for fade in range(255,0,-1*fade_speed):
libtcod.console_set_fade(fade,libtcod.black)
libtcod.console_flush()
self.sector.clear_selected_planet()
self.galaxy.current_sector = self.galaxy.sectors[self.galaxy.current_sector].neighbors[self.galaxy.targeted_sector_index]
self.galaxy.targeted_sector_index = 0
self.sector, self.starfield, self.nebula = self.galaxy.sectors[self.galaxy.current_sector].load_sector(self.console, self.buffer)
self.player_ship.sector = self.sector
self.player_ship.dead_stop()
self.player_ship.velocity = int(self.player_ship.speed_limit / 2)
self.player_ship.face_system_center()
self.player_ship.about_face()
self.player_ship.velocity_angle = self.player_ship.heading
self.player_ship.apply_thrust()
self.clear_messages()
self.add_message("Arriving in {0}".format(self.galaxy.sectors[self.galaxy.current_sector].name))
# self.add_message("Nebula Colors: r:{0} g:{1} b:{2}".format(
# round(self.nebula.r_factor,2),
# round(self.nebula.g_factor,2),
# round(self.nebula.b_factor,2)))
# Fade in
libtcod.console_set_fade(0,libtcod.black)
self.render_all()
for fade in range(0,255,fade_speed):
libtcod.console_set_fade(fade,libtcod.black)
libtcod.console_flush()
else:
self.add_message("You are not far enough from the nearest planet to jump")
def check_for_collisions(self):
asteroid_to_delete = None
for index, asteroid in enumerate(self.sector.asteroids):
for p in self.sector.particles:
if p.bullet:
if asteroid.sector_position_x < p.sector_position_x < asteroid.sector_position_x+asteroid.width and \
asteroid.sector_position_y+1 < p.sector_position_y < asteroid.sector_position_y+1+asteroid.width:
asteroid.hp -= p.damage
if asteroid.hp < 0:
for a in range(0, 60):
self.sector.add_particle(
ExplosionFireBall(
starting_index = a/10,
sector = self.sector,