]> Skullheadx's Git Forge - Pygame-Jam.git/commitdiff
particles
authorSkullheadx <704277@pdsb.net>
Tue, 12 Jul 2022 00:41:58 +0000 (20:41 -0400)
committerSkullheadx <704277@pdsb.net>
Tue, 12 Jul 2022 00:41:58 +0000 (20:41 -0400)
Actors.py
Assets/enemy/Goon_Run.gif [new file with mode: 0644]
Assets/enemy/Pirate_Goon.png [new file with mode: 0644]
Assets/skeleton/skele_ATTAK.gif [new file with mode: 0644]
Enemy.py
Game.py
Levels/Level5.txt
Particle.py [new file with mode: 0644]
Player.py
Setup.py
main.py

index 27634b08d11d6fef25c2c829fe881acc474e9223..49dd46a97a04f4aea07be78de4b91240d171fa75 100644 (file)
--- a/Actors.py
+++ b/Actors.py
@@ -2,6 +2,7 @@ from datetime import datetime, timedelta
 import threading
 
 from Setup import *
+from Particle import Dust
 # from PhysicsBody import PhysicsBody
 from Block import Block
 
@@ -19,6 +20,7 @@ class Actor:
     terminal_velocity = 15
     invincibility_time = 150
 
+
     def __init__(self, pos, collision_layer, collision_mask):
         self.position = pg.Vector2(pos)
         self.velocity = pg.Vector2(0, 0)
@@ -39,7 +41,7 @@ class Actor:
         self.jumping = False
         self.coyote_time = datetime.utcnow()
         self.hold_jump = datetime.utcnow()
-        self.stun_time = 750
+        self.stun_time = 1000
         self.attacked = False
         self.invincibility_frames = 0
 
@@ -47,6 +49,7 @@ class Actor:
         if self.jumping:
             if self.on_ground:
                 self.jumping = False
+                Dust(pg.Vector2(self.get_collision_rect().midbottom) + pg.Vector2(-16,-15), 32, 0)
 
         self.stun_time -= delta
         self.stun_time = max(self.stun_time, 0)
diff --git a/Assets/enemy/Goon_Run.gif b/Assets/enemy/Goon_Run.gif
new file mode 100644 (file)
index 0000000..3377434
Binary files /dev/null and b/Assets/enemy/Goon_Run.gif differ
diff --git a/Assets/enemy/Pirate_Goon.png b/Assets/enemy/Pirate_Goon.png
new file mode 100644 (file)
index 0000000..6211e08
Binary files /dev/null and b/Assets/enemy/Pirate_Goon.png differ
diff --git a/Assets/skeleton/skele_ATTAK.gif b/Assets/skeleton/skele_ATTAK.gif
new file mode 100644 (file)
index 0000000..21f3bf3
Binary files /dev/null and b/Assets/skeleton/skele_ATTAK.gif differ
index 045d77785832fe7d34e28f9c02b00a49a3f96da2..4b43d64176efc1bf70fe4473f3a6975d01f74df9 100644 (file)
--- a/Enemy.py
+++ b/Enemy.py
@@ -2,18 +2,18 @@ from argparse import Action
 from Setup import *
 from Player import Player
 from Actors import Actor
-from Weapon import Melee
-
+from Weapon import Sword
+from Particle import Dust
 
 class Enemy(Actor):
     speed = Actor.speed * 0.33
     jump_strength = Actor.jump_strength * 0.5
     colour = (235, 64, 52)
     friction = 0.9
-    run_gif = Image.open("Assets/skeleton/skeleton_run.gif")
+    run_gif = Image.open("Assets/enemy/Goon_Run.gif")
     run_frames = []
     for i in range(run_gif.n_frames):
-        run_frames.append(pg.transform.scale(pil_to_game(get_gif_frame(run_gif, i)), (125, 125)))
+        run_frames.append(pg.transform.scale(pil_to_game(get_gif_frame(run_gif, i)), (180, 180)))
     def __init__(self, pos, collision_layer, collision_mask):
         super().__init__(pos, collision_layer, collision_mask)
 
@@ -26,8 +26,8 @@ class Enemy(Actor):
 
         # self.health = 0 # for debugging without getting killed
 
-        self.weapon = Melee(self.position, (-Melee.width / 2 + 7, Melee.height / 2 + self.height / 3 - 8),
-                            (-5, Melee.height), self.width, -1, -10)
+        self.weapon = Sword(self.position, (0, 0), self.width, -1)
+
 
         self.buffer = []
 
@@ -40,11 +40,10 @@ class Enemy(Actor):
     def update(self, delta, target=None):
         super().update(delta)
         if not self.attacked and target is not None and self.stun_time == 0:
-            # print('a')
-            self.follow_target(target)
-            # if random.random() < 2/fps and not self.weapon.attacking and self.weapon.get_collision_rect().colliderect(target.get_collision_rect()):
-            #     target.attack(self, self.weapon, self.direction)
-            #     print('attack')
+            self.follow_target(target, stop_dist=target.width/2+self.weapon.width)
+            if not target.attacked and get_display_rect(self.weapon.get_collision_rect()).colliderect(
+                    get_display_rect(target.get_collision_rect())):
+                target.attack(self, self.weapon, self.direction)
 
         # Deals with collision and applying velocity
         self.position, self.velocity = self.move_and_collide(self.position.copy(), self.velocity.copy(), delta)
@@ -59,11 +58,12 @@ class Enemy(Actor):
             frame = math.floor(self.current_frame)
             if self.velocity.x > 0:
                 self.display = self.run_frames[math.floor(frame)]
-                self.display_offsets["enemy"] = pg.Vector2(-40, -35)
+                self.display_offsets["enemy"] = pg.Vector2(-60, -35)
             elif self.velocity.x <= 0:
                 self.display = pg.transform.flip(self.run_frames[math.floor(frame)], True, False)
-                self.display_offsets["enemy"] = pg.Vector2(-55, -35)
-
+                self.display_offsets["enemy"] = pg.Vector2(-60, -35)
+            if frame % 4 == 0 and self.on_ground:
+                Dust(pg.Vector2(self.get_collision_rect().midbottom) + pg.Vector2(math.copysign(1, self.velocity.x) * -self.width/2,-15), 16, self.direction)
             self.current_frame = (self.current_frame + 0.5) % self.run_gif.n_frames
             
 
@@ -78,7 +78,7 @@ class Enemy(Actor):
 
     def draw(self, surf):
         self.weapon.draw(surf)
-        super(Enemy, self).draw(surf)
+        super(Enemy, self).draw(surf)
         surf.blit(self.display, get_display_rect(self.get_collision_rect()).topleft + self.display_offsets["enemy"])
 
         # for b in self.buffer:
diff --git a/Game.py b/Game.py
index 3eaee72d9b21e2275969fb327eeeb92f62a2e83d..a5ff4f358116ee0d30acaa73ec7deacd961622ef 100644 (file)
--- a/Game.py
+++ b/Game.py
@@ -67,6 +67,9 @@ class Game:
                 self.collision_layer["enemy"].remove(enemy)
                 self.collision_layer["body"].add(self.enemies[i])
 
+        for particle in particles:
+            particle.update(delta)
+
         self.world.update(delta)
         self.fade = self.Transition.fade
 
@@ -90,6 +93,10 @@ class Game:
             pass;
 
         self.world.draw(surf)
+
+        for particle in particles:
+            particle.draw(surf)
+
         for enemy in self.enemies:
             enemy.draw(surf)
 
index 0e324a73dcefd7b8ad3fe1087489c506e78a2120..1695f1cae754e7750758c13412b4c8c837e07c92 100644 (file)
@@ -1,6 +1,6 @@
-none|none|none|none|none|none|none|none|none|none|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world
-1250.0,750.0|1200.0,750.0|1350.0,750.0|1350.0,700.0|1450.0,750.0|1450.0,700.0|1450.0,650.0|1450.0,600.0|1450.0,550.0|1250.0,700.0|50.0,800.0|100.0,800.0|150.0,800.0|200.0,800.0|250.0,800.0|300.0,800.0|350.0,800.0|400.0,800.0|450.0,800.0|500.0,800.0|550.0,800.0|600.0,800.0|650.0,800.0|700.0,800.0|750.0,800.0|800.0,800.0|850.0,800.0|900.0,800.0|950.0,800.0|1000.0,800.0|1050.0,800.0|1100.0,800.0|1150.0,800.0|1200.0,800.0|1250.0,800.0|1300.0,800.0|1350.0,800.0|1400.0,800.0|1450.0,800.0|1500.0,800.0|1550.0,800.0|1600.0,800.0|1650.0,800.0|1700.0,800.0|1750.0,800.0|1800.0,800.0|1850.0,800.0|1900.0,800.0|1950.0,800.0|2000.0,800.0|2050.0,800.0|2100.0,800.0|2150.0,850.0|2100.0,850.0|2050.0,850.0|2000.0,850.0|1950.0,850.0|1900.0,850.0|1850.0,850.0|1800.0,850.0|1750.0,850.0|1700.0,850.0|1650.0,850.0|1600.0,850.0|1550.0,850.0|1500.0,850.0|1450.0,850.0|1400.0,850.0|1350.0,850.0|1300.0,850.0|1250.0,850.0|1200.0,850.0|1150.0,850.0|1100.0,850.0|1050.0,850.0|1000.0,850.0|950.0,850.0|900.0,850.0|850.0,850.0|800.0,850.0|750.0,850.0|700.0,850.0|650.0,850.0|600.0,850.0|550.0,850.0|500.0,850.0|450.0,850.0|400.0,850.0|350.0,850.0|300.0,850.0|250.0,850.0|200.0,850.0|150.0,850.0|100.0,850.0|50.0,850.0|0.0,850.0|0.0,800.0|0.0,750.0|0.0,700.0|0.0,650.0|0.0,600.0|0.0,550.0|0.0,400.0|0.0,350.0|0.0,300.0|0.0,250.0|0.0,200.0|0.0,150.0|0.0,100.0|0.0,50.0|0.0,0.0|2200.0,850.0|2200.0,800.0|2200.0,750.0|2200.0,700.0|2200.0,650.0|2200.0,600.0|2150.0,400.0|2200.0,200.0|2200.0,150.0|2200.0,100.0|2200.0,50.0|2200.0,0.0|2150.0,0.0|2150.0,50.0|2150.0,100.0|2150.0,150.0|2150.0,200.0|2150.0,250.0|2150.0,350.0|2150.0,300.0|2200.0,250.0|2200.0,300.0|2200.0,350.0|2200.0,400.0|2200.0,550.0|2150.0,550.0|2150.0,600.0|2150.0,650.0|2150.0,700.0|2150.0,750.0|2150.0,800.0|300.0,600.0|0.0,450.0|2200.0,450.0|2150.0,450.0|2150.0,500.0|2200.0,500.0|0.0,500.0|1900.0,550.0|1900.0,600.0|1900.0,650.0|1900.0,700.0|1900.0,750.0|2050.0,700.0
-GOLDCOIN|BRONZECOIN|PEDESTAL|INTERDIMENSIONALPOWDER|PILLAR_|PILLAR_|PILLAR_|PILLAR_|PILLAR_|SILVERCOIN|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLAYER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|ENEMY
+none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world
+1250.0,750.0|1200.0,750.0|1350.0,750.0|1350.0,700.0|1450.0,750.0|1450.0,700.0|1450.0,650.0|1450.0,600.0|1450.0,550.0|1250.0,700.0|1900.0,550.0|1900.0,600.0|1900.0,650.0|1900.0,700.0|1900.0,750.0|50.0,800.0|100.0,800.0|150.0,800.0|200.0,800.0|250.0,800.0|300.0,800.0|350.0,800.0|400.0,800.0|450.0,800.0|500.0,800.0|550.0,800.0|600.0,800.0|650.0,800.0|700.0,800.0|750.0,800.0|800.0,800.0|850.0,800.0|900.0,800.0|950.0,800.0|1000.0,800.0|1050.0,800.0|1100.0,800.0|1150.0,800.0|1200.0,800.0|1250.0,800.0|1300.0,800.0|1350.0,800.0|1400.0,800.0|1450.0,800.0|1500.0,800.0|1550.0,800.0|1600.0,800.0|1650.0,800.0|1700.0,800.0|1750.0,800.0|1800.0,800.0|1850.0,800.0|1900.0,800.0|1950.0,800.0|2000.0,800.0|2050.0,800.0|2100.0,800.0|2150.0,850.0|2100.0,850.0|2050.0,850.0|2000.0,850.0|1950.0,850.0|1900.0,850.0|1850.0,850.0|1800.0,850.0|1750.0,850.0|1700.0,850.0|1650.0,850.0|1600.0,850.0|1550.0,850.0|1500.0,850.0|1450.0,850.0|1400.0,850.0|1350.0,850.0|1300.0,850.0|1250.0,850.0|1200.0,850.0|1150.0,850.0|1100.0,850.0|1050.0,850.0|1000.0,850.0|950.0,850.0|900.0,850.0|850.0,850.0|800.0,850.0|750.0,850.0|700.0,850.0|650.0,850.0|600.0,850.0|550.0,850.0|500.0,850.0|450.0,850.0|400.0,850.0|350.0,850.0|300.0,850.0|250.0,850.0|200.0,850.0|150.0,850.0|100.0,850.0|50.0,850.0|0.0,850.0|0.0,800.0|0.0,750.0|0.0,700.0|0.0,650.0|0.0,600.0|0.0,550.0|0.0,400.0|0.0,350.0|0.0,300.0|0.0,250.0|0.0,200.0|0.0,150.0|0.0,100.0|0.0,50.0|0.0,0.0|2200.0,850.0|2200.0,800.0|2200.0,750.0|2200.0,700.0|2200.0,650.0|2200.0,600.0|2150.0,400.0|2200.0,200.0|2200.0,150.0|2200.0,100.0|2200.0,50.0|2200.0,0.0|2150.0,0.0|2150.0,50.0|2150.0,100.0|2150.0,150.0|2150.0,200.0|2150.0,250.0|2150.0,350.0|2150.0,300.0|2200.0,250.0|2200.0,300.0|2200.0,350.0|2200.0,400.0|2200.0,550.0|2150.0,550.0|2150.0,600.0|2150.0,650.0|2150.0,700.0|2150.0,750.0|2150.0,800.0|300.0,600.0|0.0,450.0|2200.0,450.0|2150.0,450.0|2150.0,500.0|2200.0,500.0|0.0,500.0|2050.0,700.0
+GOLDCOIN|BRONZECOIN|PEDESTAL|INTERDIMENSIONALPOWDER|PILLAR_|PILLAR_|PILLAR_|PILLAR_|PILLAR_|SILVERCOIN|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLAYER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|ENEMY
 
 
 
diff --git a/Particle.py b/Particle.py
new file mode 100644 (file)
index 0000000..ba16287
--- /dev/null
@@ -0,0 +1,28 @@
+import Setup
+from Setup import *
+
+class Dust:
+    dust_gif = Image.open("Assets/player/DUSTCLOUD.gif")
+    dust_frames = []
+    for i in range(dust_gif.n_frames):
+        dust_frames.append(pil_to_game(get_gif_frame(dust_gif, i)))
+
+    def __init__(self, pos, dust_size, direction):
+        self.position = pg.Vector2(pos)
+        self.dust_size = dust_size
+        self.velocity = pg.Vector2(0,0)
+        self.direction = -direction
+        self.current_frame = 0
+        self.display = self.dust_frames[math.floor(self.current_frame)]
+        Setup.particles.append(self)
+
+    def update(self, delta):
+        self.position += self.velocity
+        self.velocity = pg.Vector2(self.direction * delta / 64, -self.current_frame * delta / 256)
+        self.display = pg.transform.scale(self.dust_frames[math.floor(self.current_frame)], (self.dust_size, self.dust_size))
+        self.current_frame = (self.current_frame + 0.25)
+        if math.floor(self.current_frame) >= self.dust_gif.n_frames-1:
+            del Setup.particles[Setup.particles.index(self)]
+
+    def draw(self, surf):
+        surf.blit(self.display, get_display_point(self.position))
index d945aaf92f7e20bf5e6f34e43ffc877e4880ab96..a104df1ba88a6c4cd1db1af7324bf4c0ea58a2e3 100644 (file)
--- a/Player.py
+++ b/Player.py
@@ -7,9 +7,11 @@ from Actors import Actor
 from datetime import datetime, timedelta
 from Potion import Potion
 from Weapon import Sword
+from Particle import Dust
 
 
 class Player(Actor):
+    friction = 0.2
     scale = 100
     factor = 640 / scale
     crop = pg.Rect(179, 169, 170, 401)
@@ -81,6 +83,12 @@ class Player(Actor):
     #     print('a')
 
     def update(self, delta):
+
+        if self.attacked:
+            self.friction = 0.9
+        else:
+            self.friction = 0.2
+
         super().update(delta)
 
         # Get and handle input
@@ -155,6 +163,9 @@ class Player(Actor):
                 self.display = pg.transform.flip(self.run_frames[math.floor(frame)], True, False)
                 self.display_offsets["player"] = pg.Vector2(-65, -35)
 
+            if frame % 2 == 0 and self.on_ground:
+                Dust(pg.Vector2(self.get_collision_rect().midbottom) + pg.Vector2(math.copysign(1, self.velocity.x) * -self.width/2,-15), 16, self.direction)
+
             self.current_frame = (self.current_frame + 0.5) % self.run_gif.n_frames
 
         if self.state == "RUN":
@@ -255,7 +266,11 @@ class Player(Actor):
                 surf.blit(pg.transform.flip(self.weapon.img, False, True),
                           get_display_rect(self.get_collision_rect()).topleft + pg.Vector2(0, 55) +
                           self.display_offsets["weapon"])
-        surf.blit(self.display, get_display_rect(self.get_collision_rect()).topleft + self.display_offsets["player"])
+
+        a = get_display_rect(self.get_collision_rect())
+        b = a.topleft + self.display_offsets["player"]
+        if pg.Rect(b,a.size).colliderect(screen_rect):
+            surf.blit(self.display, b)
         #
         # for b in self.buffer:
         #     pg.draw.rect(surf,(0,0,255),get_display_rect(b),3)
index a0bc8d88c1e0a2abd2421ef3d14fd97a9acc738f..c6ed120e158b5f9cc48a8fa9c8b8f9454c0f29ed 100644 (file)
--- a/Setup.py
+++ b/Setup.py
@@ -13,6 +13,8 @@ SCREEN_WIDTH, SCREEN_HEIGHT = 1080, 640
 dimensions = (SCREEN_WIDTH, SCREEN_HEIGHT)
 center = pg.Vector2(dimensions) / 2
 
+screen_rect = pg.Rect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT)
+
 pg.display.set_caption("Jam")
 # icon = pg.transform.scale(pg.image.load("logo.ico"), (32, 32))
 # pg.display.set_icon(icon)
@@ -59,3 +61,5 @@ def pil_to_game(img):
 def get_gif_frame(img, frame):
     img.seek(frame)
     return img.convert(FORMAT)
+
+particles = []
diff --git a/main.py b/main.py
index eda163a0957c1bb04d980a6201a68d405a5467d0..eb0597ebdc6e443947a0f7c62fc5bab2d54fb689 100644 (file)
--- a/main.py
+++ b/main.py
@@ -51,5 +51,6 @@ while is_running:
 
     pg.display.update()
     delta = clock.tick(fps)
+    print(clock.get_fps())
 
 pg.quit()