Пример #1
0
    def physics(self):
        self.pos = self.canvas.coords(self.id[0])
        self.gravity()
        self.motion()
        #collision
        self.momentum, self.y=physics.collider(self.pos, self.static, self.momentum, self.y)

        #calculates player velocity
        self.decceleration()
        self.motion()
        #Placed at the end of the of the function to stop it going through walls
        self.momentum, self.y=physics.collision(self.pos, self.momentum, self.y)
        #moves the player.
        #print(self.momentum)
        self.canvas.move(self.id[0], int(self.momentum), int(self.y) )
        self.canvas.move(self.id[1], int(self.momentum), int(self.y) )
        self.canvas.move(self.id[2], int(self.momentum), int(self.y) )
        self.canvas.move(self.id[3], int(self.momentum), int(self.y) )
Пример #2
0
 def staticCollision(self):
     self.player.xVelocity, self.player.yVelocity = physics.collider(self.player.pos, self.static, self.player.xVelocity, self.player.yVelocity)
     if len(self.dynamic)>0:
         for i in self.dynamic:
             i.xVelocity, i.yVelocity = physics.collider(i.pos, self.static, i.xVelocity, i.yVelocity)