Compare commits
No commits in common. "18c392d822b437c1c937f68967e8dc065a4615a0" and "b4958d535fe85e20d21062fd56ca0201c9b94130" have entirely different histories.
18c392d822
...
b4958d535f
3 changed files with 2 additions and 39 deletions
4
game.py
4
game.py
|
|
@ -40,17 +40,14 @@ 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]
|
||||
|
|
@ -112,4 +109,5 @@ class Game:
|
|||
game = Game()
|
||||
|
||||
|
||||
|
||||
game.run()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Tile:
|
|||
def grid_key(self) -> str:
|
||||
"""Erzeugt den String-Key für die Tilemap."""
|
||||
return f"{self.pos[0]};{self.pos[1]}"
|
||||
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Konvertiert zurück in ein Dict (für JSON-Speicherung)."""
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
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