Sanftes Schweben der Blätter über Sinuswelle
This commit is contained in:
parent
261cc92897
commit
e1b5a42137
1 changed files with 27 additions and 20 deletions
17
game.py
17
game.py
|
|
@ -1,6 +1,7 @@
|
|||
import pygame # ty: ignore[unresolved-import]
|
||||
import sys
|
||||
import random
|
||||
import math
|
||||
from scripts.entities import Player
|
||||
from scripts.utils import load_image
|
||||
from scripts.utils import load_images
|
||||
|
|
@ -66,15 +67,12 @@ class Game:
|
|||
|
||||
self.leaf_spawners: list[pygame.Rect] = []
|
||||
|
||||
|
||||
for tree in self.tilemap.extract([("large_decor", 2)], keep=True):
|
||||
self.leaf_spawners.append(
|
||||
pygame.Rect(
|
||||
4 + tree["pos"][0], 4 + tree["pos"][1], 23, 13
|
||||
)
|
||||
pygame.Rect(4 + tree["pos"][0], 4 + tree["pos"][1], 23, 13)
|
||||
)
|
||||
|
||||
self.particles = []
|
||||
self.particles: list[Particle] = []
|
||||
|
||||
self.clouds: Clouds = Clouds(cloud_images=self.assets["clouds"], count=16)
|
||||
self.isJumping: bool = False
|
||||
|
|
@ -122,6 +120,15 @@ class Game:
|
|||
# print(int(self.player.pos[0]))
|
||||
# print(int(self.player.pos[1]))
|
||||
# print(self.tilemap.tiles_around(self.player.pos))
|
||||
for particle in self.particles.copy():
|
||||
kill: bool = particle.update()
|
||||
particle.render(self.display, offset=render_scroll)
|
||||
if particle.type == 'leaf':
|
||||
particle.pos[0] += math.sin(particle.animation.frame * 0.035) * 0.3
|
||||
if kill:
|
||||
self.particles.remove(particle)
|
||||
|
||||
|
||||
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
|
|
|
|||
Loading…
Reference in a new issue