本文整理汇总了Python中ship.Ship.blitme方法的典型用法代码示例。如果您正苦于以下问题:Python Ship.blitme方法的具体用法?Python Ship.blitme怎么用?Python Ship.blitme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ship.Ship
的用法示例。
在下文中一共展示了Ship.blitme方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import blitme [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()
示例2: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import blitme [as 别名]
def run_game():
pygame.init() #make game
ai_settings = Settings() #make settings object which has settings
screen = pygame.display.set_mode((ai_settings.screen_width,ai_settings.screen_height)) #make window
pygame.display.set_caption("Alien Invasion") #title for window
ship = Ship(screen)
while True: #forever loop for the window
for event in pygame.event.get(): #wait for user to exit
if event.type == pygame.QUIT:
sys.exit()
screen.fill(ai_settings.bg_color)
ship.blitme()
pygame.display.flip() #redraw
示例3: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import blitme [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()
示例4: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import blitme [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(ai_settings.title)
ship = Ship(screen)
# 开始游戏的主循环
while True:
# 监视键盘和鼠标事件
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit(0)
screen.fill(ai_settings.bg_color)
ship.blitme()
# 让最近回执的屏幕可见
pygame.display.flip()
示例5: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import blitme [as 别名]
def run_game():
pygame.init() # 初始化背景,让游戏运行
sets = Setting() # 实例化Setting类
screen = pygame.display.set_mode((sets.screen_width, sets.screen_height)) # 创建一个显示窗口
pygame.display.set_caption('打飞机')
screen.fill(sets.bg_color)
ship = Ship(screen)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
screen.fill(sets.bg_color)
ship.blitme()
pygame.display.flip()
示例6: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import blitme [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(screen)
while True:
gf.check_events()
screen.fill(ai_settings.bg_color)
ship.blitme()
pygame.display.flip()
示例7: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import blitme [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(screen)
bg_color = (ai_settings.bg_color)
while True:
gf.check_events(ship)
ship.update()
gf.update_screen(ai_settings, screen, ship)
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
screen.fill(bg_color)
ship.blitme()
pygame.display.flip()
示例8: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import blitme [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()
while True:
gf.check_events(ai_settings, screen, ship, bullets)
ship.update()
bullets.update()
gf.update_screen(ai_settings, screen, ship, bullets)
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
screen.fill(ai_settings.bg_color)
ship.blitme()
pygame.display.flip()
bullets.update()
for bullet in bullets.copy():
if bullet.rect.bottom <= 0:
bullets.remove(bullet)
print(len(bullets))
示例9: run_game
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import blitme [as 别名]
def run_game():
pygame.init()
screen = pygame.display.set_mode((600, 600))
pygame.display.set_caption('Learn PyGame!')
#This is what will make a ship object:
ship = Ship(screen)
bg_color = (255,255,255)
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.fill(bg_color)
#Calling the ship object to appear on the screen. This line MUST come after the screen.fill line.
#If it does not come after then the background will cover up the image.
ship.blitme()
pygame.display.flip()