当前位置: 首页>>代码示例>>Python>>正文


Python Ship.moveUp方法代码示例

本文整理汇总了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
开发者ID:bjsmith01,项目名称:Hark-Upon-The-Gale,代码行数:32,代码来源:Main.py

示例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)
开发者ID:cswhite2000,项目名称:Space-Gataca,代码行数:33,代码来源:Main.py


注:本文中的Ship.moveUp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。