]> Skullheadx's Git Forge - Pygame-Jam.git/commitdiff
wip
authorSkullheadx <704277@pdsb.net>
Thu, 7 Jul 2022 23:53:13 +0000 (19:53 -0400)
committerSkullheadx <704277@pdsb.net>
Thu, 7 Jul 2022 23:53:13 +0000 (19:53 -0400)
Actors.py
Enemy.py
Game.py
PhysicsBody.py
Player.py

index bf4edb77b21046bb73882eec57dc2f1a7fb7c58d..b5cb6a85575844107948ad6ae21355064a731eb7 100644 (file)
--- 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
index 1b253da311b5079e97c55fb058b76113064062b6..0eb663db4a070fa22a5556f5a7cc80f7c17833c9 100644 (file)
--- 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 6c80399596016a07df8c90250d1de3622d2ce9d1..e25fc47f9a84fc321105aadc175dab912263027f 100644 (file)
--- 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):
index 6dbb26933a44fecf8dc24cfa28579dcbbc38929b..53e93faab8c00f0e495151d40c82f6d35c170789 100644 (file)
@@ -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
index 77785009415db2f4811c8e9ee418b3caba728c0b..437e20de9f770245c29c79fb297b109e673b7495 100644 (file)
--- 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)