Compare commits
3 commits
b4958d535f
...
18c392d822
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18c392d822 | ||
|
|
bb9cdacae2 | ||
|
|
58aea455e9 |
3 changed files with 39 additions and 2 deletions
4
game.py
4
game.py
|
|
@ -40,14 +40,17 @@ class Game:
|
|||
"player/jump": Animation(load_images("entities/player/jump")),
|
||||
"player/slide": Animation(load_images("entities/player/slide")),
|
||||
"player/wall_slide": Animation(load_images("entities/player/wall_slide")),
|
||||
"particles/leaf": Animation(load_images("particles/leaf"), image_duration=20, loop=False),
|
||||
}
|
||||
self.player: Player = Player(self, (50, 50), (8, 15))
|
||||
|
||||
self.tilemap: Tilemap = Tilemap(self, 16)
|
||||
|
||||
try:
|
||||
self.tilemap.load("map.json")
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
self.clouds: Clouds = Clouds(self.assets["clouds"], count=16)
|
||||
self.isJumping: bool = False
|
||||
self.scroll: list[float] = [0, 0]
|
||||
|
|
@ -109,5 +112,4 @@ class Game:
|
|||
game = Game()
|
||||
|
||||
|
||||
|
||||
game.run()
|
||||
|
|
|
|||
35
scripts/particle.py
Normal file
35
scripts/particle.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import pygame
|
||||
|
||||
from scripts.animation import Animation
|
||||
|
||||
|
||||
class Particle:
|
||||
def __init__(self, game, p_type, pos: tuple, velocity=[0, 0], frame=0):
|
||||
self.game = game
|
||||
self.p_type = p_type
|
||||
self.pos = list(pos)
|
||||
self.velocity = list(velocity)
|
||||
self.frame = frame
|
||||
|
||||
self.animation: Animation = self.game.assets["particles/" + self.p_type].copy()
|
||||
self.animation.frame = frame
|
||||
|
||||
def update(self) -> bool:
|
||||
|
||||
kill = False
|
||||
|
||||
if self.animation.done:
|
||||
kill = True
|
||||
|
||||
self.pos[0] += self.velocity[0]
|
||||
self.pos[1] += self.velocity[1]
|
||||
self.animation.update()
|
||||
|
||||
return kill
|
||||
|
||||
def render(self, surface: pygame.Surface, offset: tuple[float, float]=(0, 0)):
|
||||
img = self.animation.img()
|
||||
surface.blit(img, (
|
||||
self.pos[0] - offset[0] - img.get_width() // 2,
|
||||
self.pos[1] - offset[1] - img.get_height() // 2,
|
||||
))
|
||||
Loading…
Reference in a new issue