本文整理汇总了Python中module.Module.jump方法的典型用法代码示例。如果您正苦于以下问题:Python Module.jump方法的具体用法?Python Module.jump怎么用?Python Module.jump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module.Module
的用法示例。
在下文中一共展示了Module.jump方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: JumpGame
# 需要导入模块: from module import Module [as 别名]
# 或者: from module.Module import jump [as 别名]
class JumpGame(Animation):
def getplatforms(num,L,L2,width1,width2,height1,height2):
#beginning platforms
count,ok,newlist = 0,True,L2
while count < num:
check = Platforms(random.randint(width1,width2),\
random.randint(height1,height2))
for platform in L:
#go through every platform to check overlap
if platform.checkoverlap(check.x,check.y):
ok = False
break
#check other list to check overlap
if ok == True:
for platform in L2:
if platform.checkoverlap(check.x,check.y):
ok = False
break
#if no overlaps, add platform to list
if ok:
newlist.append(check)
count+=1
ok = True #reset, increment by one
return newlist
def latergetplatforms(L,L2,width1,width2,height):
#add platforms during the game
count,ok,newlist = 0,True,L2
while count < 1:
check = Platforms(random.randint(width1,width2),\
height)
#check platforms in list for overlap
for platform in L:
if platform.checkoverlap(check.x,check.y):
ok = False
break
if ok == True:
#check platforms in other list for overlap
for platform in L2:
if platform.checkoverlap(check.x,check.y):
ok = False
break
if ok:
newlist.append(check)
count+=1
ok = True #increment by one, reset
return newlist
def init(self):
self.mode = "mainmenu"
self.module = Module(self.width//2,self.height//2+10)
self.essentialplatforms = [Platforms(self.width//2,self.height-20),\
Platforms(random.randint(0,350),self.height-80),\
Platforms(random.randint(0,350),self.height-140),\
Platforms(random.randint(0,350),self.height-200),\
Platforms(random.randint(0,350),self.height-260),\
Platforms(random.randint(0,350),self.height-320),\
Platforms(random.randint(0,350),self.height-380)]
#essential platforms for prevention of getting "stuck"
self.platforms = []
self.platforms = JumpGame.getplatforms(10,self.essentialplatforms,\
self.platforms,0,350,20,370)
#additional platforms scattered around.
self.aliens = []
self.projectiles = []
self.enemyaircraft = []
self.enemyprojectiles = []
self.powerups = []
self.startmodule = MainMenuModule(self.width//2+self.width//4+7,\
self.height//2+50)
self.startplatform = Platforms(self.width//2+self.width//4-10,\
self.height - 30)
self.instructionsmodule = MainMenuModule(self.width//10,105)
self.instructionsalien = Alien(self.width//18,160)
self.instructionsaircraft = EnemyAircraft(self.width//15+30,100)
self.ground = 350
self.maxplatforms = 10
self.maxaliens = 2
self.maxenemyaircrafts = 1 #max is for overload prevention
self.maxenemyprojectiles = 7
self.maxpowerups = 2
self.deployable = True
self.hitcount = 5
self.aircrafthit = False
self.movejump = True
self.storage = None
self.background = \
PhotoImage(\
file="/Users/Edward/Desktop/TermProject/Images/background1.gif")
#https://media.giphy.com/media/8xK1CusSFTI0U/giphy.gif
self.score = 0
#.........这里部分代码省略.........