Exemple #1
0
 def __init__(self):
     PhysicsObject.__init__(self)
     self.source_image = '.\Images\grating.png'
     self.height = 0.2
     self.render_layer = 99
     self.screen_bounded = True
     self.get_size()
Exemple #2
0
 def __init__(self, window, playercoords, playerangle, speed=400):
     PhysicsObject.__init__(self, window, (0, 100, 255))
     self.velocity = self.get_vector(playerangle)
     self.x = playercoords[0]
     self.y = playercoords[1]
     self.height = 12
     self.width = 12
     self.velocity = (self.velocity[0] * speed, self.velocity[1] * speed)
Exemple #3
0
 def __init__(self, window, x=40, vel=1):
     PhysicsObject.__init__(self, window, (0, 255, 0))
     self.x = x
     self.y = 0
     self.height = 30
     self.width = 30
     self.fall = False
     self.allowOffscreen = False
     self.velocity = (1 * vel, 0)
Exemple #4
0
 def __init__(self, window, x):
     PhysicsObject.__init__(self, window, (0, 255, 0))
     self.x = x
     self.y = 0
     self.height = 30
     self.width = 10
     self.fall = False
     self.allowOffscreen = False
     self.velocity = (1, 0)
     self.color = kColor
    def update(self):
        PhysicsObject.update(self)
        pressedKeys = pygame.key.get_pressed()


        self.blocking = pressedKeys[K_s]

        #Only allow the player to move if they're not blocking
        if not self.blocking: 
            if pressedKeys[K_LEFT]:
                self.setPosition(self.getPosition() - (Constants.KNIGHT_SPEED, 0.0))
            if pressedKeys[K_RIGHT]:
                self.setPosition(self.getPosition() + (Constants.KNIGHT_SPEED, 0.0))

        if self.getPosition().y < 600:
            self.state = Player.JUMPING
            self.setAcceleration((0.0, Constants.GRAVITY))
        else:
            self.state = Player.STANDING
            self.setVelocity((0.0, 0.0))
            self.setAcceleration((0.0, 0.0))
Exemple #6
0
 def handleWall(self):
     PhysicsObject.handleWall(self)
     self.velocity = (-1 * self.velocity[0], self.velocity[1])
     self.y += self.height * 2
 def draw(self, surface):
     PhysicsObject.draw(self, surface) 
     if self.blocking:
         shieldPos = (self.getBox().topleft[0] + self.getBox().width,  self.getBox().topleft[1])
         surface.blit(self.shieldImg, shieldPos)
 def __init__(self, img, position):
     PhysicsObject.__init__(self, img, position)
     self.state = Player.JUMPING
     self.shieldImg = pygame.image.load('rightShield.png').convert()
     self.blocking = False 
 def __init__(self):
     PhysicsObject.__init__(self)
     self.height = 0.5
     self.screen_bounded = True
     self.source_image = '.\Images\download.jpg'
     self.get_size()
Exemple #10
0
 def __init__(self, window, x, y):
     PhysicsObject.__init__(self, window)
     self.x = 500
     self.y = 400
     self.velocity = (0, 0)
     self.angle = 0