From: Skullheadx <704277@pdsb.net> Date: Thu, 7 Jul 2022 23:53:13 +0000 (-0400) Subject: wip X-Git-Url: http://git.skullheadx.com/index.css?a=commitdiff_plain;h=5cb881aa93b5a7bb57e3c53b2f9b3509a29ec91d;p=Pygame-Jam.git wip --- diff --git a/Actors.py b/Actors.py index bf4edb7..b5cb6a8 100644 --- a/Actors.py +++ b/Actors.py @@ -74,8 +74,20 @@ class Actor: 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 @@ -89,6 +101,7 @@ class Actor: 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 @@ -96,6 +109,24 @@ class Actor: 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 diff --git a/Enemy.py b/Enemy.py index 1b253da..0eb663d 100644 --- a/Enemy.py +++ b/Enemy.py @@ -31,6 +31,8 @@ class Enemy(Actor): 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) diff --git a/Game.py b/Game.py index 6c80399..e25fc47 100644 --- a/Game.py +++ b/Game.py @@ -16,8 +16,8 @@ class Game: # 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): diff --git a/PhysicsBody.py b/PhysicsBody.py index 6dbb269..53e93fa 100644 --- a/PhysicsBody.py +++ b/PhysicsBody.py @@ -41,8 +41,9 @@ class PhysicsBody: 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) @@ -58,8 +59,9 @@ class PhysicsBody: 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 diff --git a/Player.py b/Player.py index 7778500..437e20d 100644 --- a/Player.py +++ b/Player.py @@ -34,6 +34,26 @@ class Player(Actor): 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)