本文整理汇总了Python中ship.Ship.update方法的典型用法代码示例。如果您正苦于以下问题:Python Ship.update方法的具体用法?Python Ship.update怎么用?Python Ship.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ship.Ship
的用法示例。
在下文中一共展示了Ship.update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
# Initialize pygame, settings, and screen object.
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode(
(ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
# Make a ship, a group of bullets, and a group of aliens.
ship = Ship(ai_settings, screen)
bullets = Group()
aliens = Group()
# Create the fleet of aliens.
gf.create_fleet(ai_settings, screen, aliens)
# Start the main loop for the game.
while True:
gf.check_events(ai_settings, screen, ship, bullets)
ship.update()
gf.update_bullets(bullets)
gf.update_screen(ai_settings, screen, ship, aliens, bullets)
# Redraw the screen during each pass through the loop.
screen.fill(ai_settings.bg_color)
ship.blitme()
# Make the most recently drawn screen visible.
pygame.display.flip()
示例2: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
# Inicjalizacja pygame, ustawień i obiektu ekranu.
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode(
(ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Inwazja obcych")
# Utworzenie egzemplarza przeznaczonego do przechowywania
# danych statystycznych dotyczących gry.
stats = GameStats(ai_settings)
# Zdefiniowanie koloru tła.
bg_color = (230, 230, 230)
# Utworzenie statku, grupy pocisków oraz grupy obcych.
ship = Ship(ai_settings, screen)
bullets = Group()
aliens = Group()
# Utworzenie floty obcych.
gf.create_fleet(ai_settings, screen, ship, aliens)
# Rozpoczęcie pętli głównej gry.
while True:
gf.check_events(ai_settings, screen, ship, bullets)
if stats.game_active:
ship.update()
gf.update_bullets(ai_settings, screen, ship, aliens, bullets)
gf.update_aliens(ai_settings, stats, screen, ship, aliens, bullets)
gf.update_screen(ai_settings, screen, ship, aliens, bullets)
示例3: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
# make a ship
ship = Ship(ai_settings, screen)
bullets = Group()
aliens = Group()
alien = Alien(ai_settings, screen)
gf.create_fleet(ai_settings, screen, aliens)
while True:
gf.check_events(ai_settings, screen, ship, bullets)
ship.update()
gf.update_bullets(bullets)
gf.update_screen(ai_settings, screen, ship, aliens, bullets)
bullets.update()
# Get rid of bullets that have disappeared.
for bullet in bullets.copy():
if bullet.rect.bottom <= 0:
bullets.remove(bullet)
print(len(bullets))
示例4: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
pygame.init()
ai_settings = Settings()
""" Screen settings and such"""
screen = pygame.display.set_mode(
(ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
stats = GameStats(ai_settings)
bg_color = (230, 230, 230)
"""background screen color; grey"""
ship = Ship(ai_settings, screen)
bullets = Group()
aliens = Group()
gf.create_fleet(ai_settings, screen, ship, aliens)
while True:
gf.check_events(ai_settings, screen, ship, bullets)
ship.update()
gf.update_bullets(ai_settings, screen, ship, aliens, bullets)
gf.update_aliens(ai_settings, stats, screen, ship, aliens, bullets)
gf.update_screen(ai_settings, screen, ship, aliens, bullets)
for bullet in bullets.copy():
if bullet.rect.bottom <= 0:
bullets.remove(bullet)
print(len(bullets))
示例5: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
#Initialize pygame, settings, screen and screen object
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode(
(ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
#make ship
ship = Ship(ai_settings ,screen)
#Make a group to store bullets in
bullets = Group()
#Make an alien group
aliens = Group()
#Make play button
play_button = Button(ai_settings, screen, "Play")
#Create fleet of aliens
gf.create_fleet(ai_settings, screen, ship, aliens)
#Create instance to store game statistics and create scoreboard
stats = GameStats(ai_settings)
sb = Scoreboard(ai_settings, screen, stats)
#Start main loop for game
while True:
#Watch for keyboard/mouse events
gf.check_events(ai_settings, screen, stats, sb, play_button, ship, aliens, bullets)
if stats.game_active:
ship.update()
gf.update_bullets(ai_settings, screen, stats, sb, ship, aliens, bullets)
gf.update_aliens(ai_settings, stats, screen, ship, aliens, bullets)
#Redraw the screen during each pass through the loop
gf.update_screen(ai_settings, screen, stats, sb, ship, aliens, bullets, play_button)
示例6: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
#Initializes the settings needed for pygame to run properly
pygame.init()
aiSettings = Settings()
#Display mode called 'screen' is made, with 1200 x 800 dimensions
#Screen is where the game elements are shown
screen = pygame.display.set_mode(
(aiSettings.screen_width,aiSettings.screen_height))
pygame.display.set_caption("Alien Invasion")
#Sets background colour
stats = GameStats(aiSettings)
#Makes a ship on screen
ship = Ship(aiSettings,screen)
#Bullets! - make a group called bullets
bullets = Group()
#Aliens are made
aliens = Group()
#Calls on the createFleet function
gf.createFleet(aiSettings, screen, ship, aliens)
while True:
gf.check_events(aiSettings,screen,ship,bullets)
if stats.game_active:
ship.update()
gf.updateBullets(aiSettings, screen, ship, aliens, bullets)
gf.updateAliens(aiSettings, stats, screen, ship, aliens, bullets)
gf.update_screen(aiSettings, screen, ship, aliens, bullets)
示例7: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
# initialize game and create a screen object.
# initialize pygame, settings, and screen object>
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("alien ivasion")
# make a ship.
ship = Ship(ai_settings, screen)
# start the main loop for the game.
while True:
gf.check_events(ship)
ship.update()
gf.update_screen(ai_settings, screen, ship)
# redraw the screen during each pass through the loop.
screen.fill(ai_settings.bg_color)
ship.blitme()
# make the most recently drawn screen visible.
pygame.display.flip()
示例8: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
# Initialize pygame, settings and screen object.
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode(
(ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Snoopvasion")
# Create an instance to store game statistics.
stats = GameStats(ai_settings)
# Make a ship.
ship = Ship(ai_settings, screen)
# Make a group to store bullets in
bullets = Group()
aliens = Group()
# Create the fleet of aliens.
gf.create_fleet(ai_settings, screen, ship, aliens)
# Start the main loop for the game.
while True:
gf.check_events(ai_settings, screen, ship, bullets)
if stats.game_active:
ship.update()
gf.update_bullets(ai_settings, screen, ship, aliens, bullets)
gf.update_aliens(ai_settings, stats, screen, ship, aliens, bullets)
gf.update_screen(ai_settings, screen, ship, aliens, bullets)
示例9: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
#inits game and creates a screen object.
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
#Make the Play Button
play_button = Button(ai_settings, screen, "Play")
#Create an instance to store game stats and create a scoreboard
stats = GameStats(ai_settings)
sb = Scoreboard(ai_settings, screen, stats)
#make a ship
ship = Ship(ai_settings, screen)
#Make a group to store bullets in.
bullets = Group()
#make an alien.
aliens = Group()
#Creating a fleet of aliens
gf.create_fleet(ai_settings, screen, ship, aliens)
#Start the main loop for the game.
while True:
gf.check_events(ai_settings, screen, stats, sb, play_button, ship, aliens, bullets)
if stats.game_active:
ship.update()
gf.update_bullets(ai_settings, screen, stats, sb, ship, aliens, bullets)
gf.update_aliens(ai_settings, stats, screen, sb, ship, aliens, bullets)
gf.update_screen(ai_settings, screen, stats, sb, ship, aliens, bullets, play_button)
示例10: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
# Initilize game and create a screen object
pygame.init()
ai_settings = Settings()
# create a display window named screen
screen = pygame.display.set_mode(
(ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
# set background color
bg_color = (230, 230, 230)
# Make a ship
ship = Ship(ai_settings, screen)
# Make a group to store the bullets in.
bullets = Group()
# Start the main loop for the game
while True:
# Watch for keyboard and mouse events
gf.check_events(ai_settings, screen, ship, bullets)
ship.update()
gf.update_bullets(bullets)
gf.update_screen(ai_settings, screen, ship, bullets)
示例11: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
# Initialize pygame, settings, and screen object
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode(
(ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Mutha Fuckin' Alien Invasion")
# Set the background color.
# bg_color = (230,230,230)
# Make a ship, a group of bullets, and a group of aliens.
ship = Ship(ai_settings, screen)
bullets = Group()
aliens = Group()
# Create the fleet of aliens
gf.create_fleet(ai_settings, screen, ship, aliens)
# # A group to store super bullets in.
# super_bullets = Group()
# Start the main loop for the game.
while True:
gf.check_events(ai_settings, screen, ship, aliens, bullets)
ship.update()
gf.update_bullets(bullets)
gf.update_screen(ai_settings, screen, ship, aliens, bullets)
# Make the most recently drawn screen visible.
pygame.display.flip()
示例12: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
# Initialising game, setting and screen objects
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode((ai_settings.screen_width,ai_settings.screen_height))
pygame.display.set_caption("Space War")
# Make a ship
ship = Ship(ai_settings,screen)
# Make Bullet (Group)
bullets = Group()
# Make Alien
# alien = Alien(ai_settings,screen)
aliens = Group()
# Create an instance to store game statistics.
stats = GameStats(ai_settings)
# Fleet of aliens
gf.create_fleet(ai_settings,screen,ship,aliens)
# Game loop
while True:
# Check for events
gf.check_events(ai_settings,screen,ship,bullets)
if stats.game_active:
# Updates
ship.update()
gf.update_bullets(ai_settings,screen,ship,aliens,bullets)
gf.update_aliens(ai_settings, stats, screen, ship, aliens, bullets)
gf.update_screen(ai_settings,screen,ship,aliens,bullets)
示例13: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
# 初始化游戏并创建一个屏幕对象
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
# 创建一艘飞船
ship = Ship(ai_settings, screen)
# 创建一个用于存储子弹的编组
bullets = Group()
# 创建一个外星人编组
aliens = Group()
# 创建外星人群
gf.create_fleet(ai_settings, screen, aliens)
# 开始游戏的主循环
while True:
# 监视键盘和鼠标事件
gf.check_events(ai_settings, screen, ship, bullets)
ship.update()
gf.update_bullets(bullets)
gf.update_screen(ai_settings, screen, ship, aliens, bullets)
示例14: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
play_button = Button(ai_settings, screen, "Play")
stats = GameStats(ai_settings)
sb = Scoreboard(ai_settings, screen, stats)
ship = Ship(ai_settings, screen)
bullets = Group()
aliens = Group()
gf.create_fleet(ai_settings, screen, ship, aliens)
while True:
gf.check_events(ai_settings, screen, stats, sb, play_button, ship, aliens, bullets)
if stats.game_active:
ship.update()
gf.update_bullets(ai_settings, screen, stats, sb, ship, aliens,
bullets)
gf.update_aliens(ai_settings, screen, stats, sb, ship, aliens,
bullets)
gf.update_screen(ai_settings, screen, stats, sb, ship, aliens, bullets, play_button)
示例15: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import update [as 别名]
def run_game():
#初始化游戏并创建一个屏幕对象
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode( (ai_settings.screen_width, ai_settings.screen_height) )
pygame.display.set_caption("Alien Invasion")
#创建Play按钮
play_button = Button(ai_settings,screen, "Play")
#创建一个用于存储游戏统计信息的实例,并创建计分牌
stats = GameStats(ai_settings)
sb = Scoreboard(ai_settings,screen,stats)
#创建一艘飞船
ship = Ship(ai_settings, screen)
#创建一个用于存储子弹的编组
bullets = Group()
#创建一个用于存储外星人的编组
aliens = Group()
#创建外星人群
gf.create_fleet(ai_settings,screen,ship,aliens)
#开始游戏的主循环
while True:
#监视键盘和鼠标事件
gf.check_events(ai_settings,screen,stats,sb, play_button,ship,aliens,bullets)
#根据移动标志调整飞船的位置
if stats.game_active:
ship.update()
gf.update_bullets(ai_settings,screen,stats,sb,ship,aliens,bullets)
gf.update_aliens(ai_settings,stats,screen,sb,ship,aliens,bullets)#更新子弹后再更新外星人位置,因为稍后要检查子弹是否撞到外星人
#更新屏幕上的图像,并切换到新屏幕
gf.update_screen(ai_settings,screen,stats,sb,ship,aliens,bullets,play_button)