本文整理汇总了Python中module.Module.collide方法的典型用法代码示例。如果您正苦于以下问题:Python Module.collide方法的具体用法?Python Module.collide怎么用?Python Module.collide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module.Module
的用法示例。
在下文中一共展示了Module.collide方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: JumpGame
# 需要导入模块: from module import Module [as 别名]
# 或者: from module.Module import collide [as 别名]
#.........这里部分代码省略.........
elif (self.mode == "instructions"):
JumpGame.instructionsRedrawAll(self)
elif (self.mode == "instructionstwo"):
JumpGame.instructionstwoRedrawAll(self)
elif (self.mode == "training"):
JumpGame.trainingRedrawAll(self)
elif (self.mode == "race"):
JumpGame.raceRedrawAll(self)
###### main menu ######
def mainmenuMousePressed(self,event):
# if click is in range, then change mode.
if event.x > self.width//2-30 and event.x < self.width//2+30 and\
event.y > self.height//2-15 and event.y < self.height//2+15:
self.mode = "spacejump"
elif event.x > self.width//2-45 and event.x < self.width//2+45 and\
event.y>self.height//2+30 and event.y<self.height//2+60:
self.mode = "instructions"
elif event.x >= self.width//2-40 and event.x <= self.width//2+40 and\
event.y>=self.height//2+75 and event.y<=self.height//2+105:
self.mode = "training"
elif event.x >= self.width//2-30 and event.x <= self.width//2+30 and\
event.y>=self.height//2+120 and event.y<=self.height//2+150:
self.mode = "race"
def mainmenuKeyPressed(self,event):
pass
def mainmenuTimerFired(self):
#for decoration, aesthetics
if self.startplatform.collide(self.startmodule.x,self.startmodule.x\
+self.startmodule.width,self.startmodule.y+self.startmodule.height):
self.startmodule.jump(self.startmodule.y+self.startmodule.height)
self.startmodule.update(self.width,self.height)
def mainmenuRedrawAll(self):
self.canvas.create_image(0,0,anchor="nw",image=self.background)
self.canvas.create_text(self.width//2,75,text="Space Jump",font=\
"Arial 54",fill="white")
self.canvas.create_rectangle(self.width//2-30,self.height//2-15,\
self.width//2+30,self.height//2+15,fill="brown")
self.canvas.create_text(self.width//2,self.height//2,text="Play")
self.canvas.create_rectangle(self.width//2-45,self.height//2+30,\
self.width//2+45,self.height//2+60,fill="brown")
self.canvas.create_text(self.width//2,self.height//2+45,text=\
"Instructions")
self.canvas.create_rectangle(self.width//2-40,self.height//2+75,\
self.width//2+40,self.height//2+105,fill="brown")
self.canvas.create_text(self.width//2,self.height//2+90,\
text="Training")
self.canvas.create_rectangle(self.width//2-30,self.height//2+120,\
self.width//2+30,self.height//2+150,fill="brown")
self.canvas.create_text(self.width//2,self.height//2+135,\
text="Race")
self.startplatform.draw(self.canvas)
self.startmodule.draw(self.canvas)
####### SPACE JUMP ##########
def spacejumpMousePressed(self,event):
#calculate slope