本文整理汇总了Python中Ship.moveUp方法的典型用法代码示例。如果您正苦于以下问题:Python Ship.moveUp方法的具体用法?Python Ship.moveUp怎么用?Python Ship.moveUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ship
的用法示例。
在下文中一共展示了Ship.moveUp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: import Ship [as 别名]
# 或者: from Ship import moveUp [as 别名]
moveLeft = False
if event.key == K_RIGHT:
moveRight = False
if event.type == KEYDOWN:
if event.key == K_DOWN:
moveDown = True
if event.key == K_UP:
moveUp = True
if event.key == K_LEFT:
moveLeft = True
if event.key == K_RIGHT:
moveRight = True
if moveUp:
ship.moveUp(5,1)
if moveDown:
ship.moveDown(5,1)
if moveLeft:
ship.moveLeft(5,1)
if moveRight:
ship.moveRight(5,1)
ship.update()
windowSurface.fill(WHITE) # colors over everything in window in white
''' Nothing is actually drawn to the screen unless you call blit or a draw command. After you blit everything is put into a buffer.
Once you call update the buffer is displayed on the screen'''
pygame.draw.rect(tempSurface,RED,ship.playerRect) # draws a red rectangle at the top corner of the screen
示例2: update
# 需要导入模块: import Ship [as 别名]
# 或者: from Ship import moveUp [as 别名]
update()
if level==6:
text=font.render("You Win!", 1, (255, 255, 0))
textpos = text.get_rect()
textpos.centerx = 400
screen.blit(text, textpos)
pygame.display.update()
for event in pygame.event.get():
if event.type==QUIT or (event.type==KEYUP and event.key==K_ESCAPE):
pygame.quit()
sys.exit()
elif event.type==KEYDOWN:
if event.key==K_UP:
ship.moveUp()
elif event.key==K_DOWN:
ship.moveDown()
elif event.key==K_LEFT:
ship.moveLeft()
elif event.key==K_RIGHT:
ship.moveRight()
elif event.key==K_SPACE:
#bullets.addNew(ship.x,ship.y)
if pygame.time.get_ticks()>lastShootTime+500 and wait==False:
bullets.addNew(ship.x+34,ship.y-30)
lastShootTime=pygame.time.get_ticks()
elif event.key==K_m and len(enemies.enemies)>0:
enemies.enemies.pop(0)
pygame.time.wait(100)