if collision_rect.colliderect(thing.get_collision_rect()):
if vel.y > 0:
pos.y = thing.position.y - self.height
- vel.y = min(vel.y + thing.velocity.y, 0)
+ vel.y = min(vel.y, 0)
self.on_ground = True
elif vel.y < 0:
pos.y = thing.position.y + thing.height
- vel.y = max(vel.y + thing.velocity.y, 0)
+ vel.y = max(vel.y, 0)
collision_rect = self.get_collision_rect(pos)
return pos, vel
def update(self, delta):
- Setup.camera_offset += self.player.update(delta)
+ Setup.camera_offset = self.player.update(delta)
for i,enemy in enumerate(self.enemies):
enemy.update(delta, self.player)
def __init__(self, pos, collision_layer, collision_mask):
super().__init__(pos, collision_layer, collision_mask)
+ self.initial_position = pg.Vector2(pos)
# self.areas = {"body":Area(self.position, pg.Vector2(0, self.height/2),self.width, self.height/2,Actor)}
def update(self, delta):
# Deals with collision and applying velocity
self.position, self.velocity = self.move_and_collide(self.position.copy(), self.velocity.copy(), delta)
- return self.velocity * delta
+ return self.position - self.initial_position
def handle_input(self):
pressed = pygame.key.get_pressed()