if self.on_ground:
self.velocity.y = -self.jump_strength
+<<<<<<< Updated upstream
def move_left(self):
self.velocity.x = -self.speed
+=======
+ def push(self, vel):
+ if vel != pg.Vector2(0,0):
+ v = vel.normalize()
+ else:
+ v = vel
+ self.velocity += (math.copysign(2,v.x), v.y-1)
+
+ def move_left(self, customSpeed = speed):
+ self.velocity.x = -customSpeed
+>>>>>>> Stashed changes
def move_right(self):
self.velocity.x = self.speed
continue
if collision_rect.colliderect(thing.get_collision_rect()):
if thing.movable:
+<<<<<<< Updated upstream
thing.velocity.x = vel.x
if vel.x > 0:
pos.x = thing.position.x - self.width
elif vel.x < 0:
pos.x = thing.position.x + thing.width
vel.x = max(vel.x, 0)
+=======
+ if vel.x > 0:
+ thing.position.x = pos.x + self.width
+ pos.x = thing.position.x - self.width
+ vel.x = min(vel.x, 0)
+ elif vel.x < 0:
+ thing.position.x = pos.x - thing.width
+ pos.x = thing.position.x + thing.width
+ vel.x = max(vel.x, 0)
+ else:
+ if vel.x > 0:
+ pos.x = thing.position.x - self.width
+ vel.x = min(vel.x, 0)
+ elif vel.x < 0:
+ pos.x = thing.position.x + thing.width
+ vel.x = max(vel.x, 0)
+ print(thing, thing.movable, vel)
+>>>>>>> Stashed changes
collision_rect = self.get_collision_rect(pos)
self.on_ground = False
self.dizzy_time -= delta
self.dizzy_time = max(0,self.dizzy_time)
+ self.health = 0
+
# Deals with collision and applying velocity
self.position, self.velocity = self.move_and_collide(self.position, self.velocity, delta)
# self.pet = Pet(center, self.collision_layer["pet"], [self.collision_layer["world"]])
self.enemies = [Enemy((SCREEN_WIDTH * 3 /4, 0),self.collision_layer["enemy"], [self.collision_layer["player"], self.collision_layer["world"]])]
- self.blocks = [Block((0, SCREEN_HEIGHT * 3 / 4),self.collision_layer["world"]),
- Block((SCREEN_WIDTH, SCREEN_HEIGHT * 3 / 4 - 25),self.collision_layer["world"])]
+ self.blocks = [Block((0, SCREEN_HEIGHT * 3 / 4),self.collision_layer["world"]),]
+ # Block((SCREEN_WIDTH, SCREEN_HEIGHT * 3 / 4 - 25),self.collision_layer["world"])]
def update(self, delta):
if thing == self:
continue
if collision_rect.colliderect(thing.get_collision_rect()):
- if thing.movable:
- thing.velocity.x = vel.x
+ print(thing, "x")
+ # if thing.movable:
+ # thing.velocity.x = vel.x
if vel.x > 0:
pos.x = thing.position.x - self.width
vel.x = min(vel.x, 0)
if thing == self:
continue
if collision_rect.colliderect(thing.get_collision_rect()):
- if thing.movable:
- thing.velocity.y = vel.y
+ print(thing, "y")
+ # if thing.movable:
+ # thing.velocity.y = vel.y
if vel.y > 0:
pos.y = thing.position.y - self.height
self.move_left()
if pressed[pg.K_d] or pressed[pg.K_RIGHT]:
self.move_right()
+<<<<<<< Updated upstream
+=======
+ if(self.lastValueR == False):
+ timeSincePressed = datetime.utcnow() - self.lastPressedRight
+ timeSinceLastDash = datetime.utcnow() - self.lastDash
+ if(timeSinceLastDash >= self.dashCooldown): self.dashPossible = True
+ else: self.dashPossible = False
+ if(timeSincePressed < self.timeBetweenDoublePress and self.dashPossible == True):
+ self.lastDash = datetime.utcnow()
+ self.dashPossible = False
+ self.move_right(self.dashSpeed) # change this to change how the player dashes (maybe replace with a custom dash function)
+ self.lastPressedRight = datetime.utcnow()
+
+ self.lastValueL = pressed[pg.K_a] or pressed[pg.K_LEFT]
+ self.lastValueR = pressed[pg.K_d] or pressed[pg.K_RIGHT]
+
+ def attack(self, enemy, weapon):
+ self.modify_health(-10,"enemy")
+ self.push(enemy.velocity)
+>>>>>>> Stashed changes
def draw(self, surf):
super().draw(surf)