Example #1
0
 def MoveRightBy(self, speed):
     self.realX += speed
     col = collisions.CheckSolidCollisionsForMovement(self)
     if hasattr(col, "realX"):
         while self.CollidesWith(
                 col
         ):  ##might break if collision adjustment moves from one object to the next
             self.realX -= 1
     else:
         while collisions.CheckSolidCollisionsForMovement(self):
             self.realX -= 1
     return col
Example #2
0
    def Jump(self):
        if hasattr(
                self, "DropBlock"
        ):  #should only be for anything where a collision is meaningful
            self.DropBlock()
        self.realY -= self.GetJumpStrength()
        collides = collisions.CheckSolidCollisionsForMovement(self)

        if collides or not self.IsFalling():
            while collisions.CheckSolidCollisionsForMovement(self):
                self.realY += 1  #move down incrementally to get head out of ceiling
            self.RemoveState(
                'Jump'
            )  #remove the state so that verticle propultion is 0 (ie. so it can just start falling)
Example #3
0
 def MoveRight(self):
     self.realX += self.moveSpeed
     if hasattr(
             self, "collidesWithBlock"
     ):  #should only be for anything where a collision is meaningful
         self.collidesWithBlock = collisions.CheckCollisionsBlocks(self)
     col = collisions.CheckSolidCollisionsForMovement(self)
     if hasattr(col, "realX"):
         while self.CollidesWith(
                 col
         ):  ##might break if collision adjustment moves from one object to the next
             self.realX -= 1
     else:
         while collisions.CheckSolidCollisionsForMovement(self):
             self.realX -= 1
Example #4
0
 def MoveLeft(self):
     self.realX -= self.moveSpeed
     if hasattr(
             self, "collidesWithBlock"
     ):  #should only be for anything where a collision is meaningful. ie. Block won't use this
         self.collidesWithBlock = collisions.CheckCollisionsBlocks(
             self)  ##maybe change to just not block... o
     col = collisions.CheckSolidCollisionsForMovement(self)
     if hasattr(col, "realX"):
         while self.CollidesWith(
                 col
         ):  ##might break if collision adjustment moves from one object to the next
             self.realX += 1
     else:
         while collisions.CheckSolidCollisionsForMovement(self):
             self.realX += 1