Skip to content

Commit

Permalink
make storm snowballs fall slower
Browse files Browse the repository at this point in the history
  • Loading branch information
DaNubCoding committed Nov 10, 2024
1 parent f926001 commit ec609ca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ def add_snowball(self, size: int) -> None:
self.snowball_queue.append(size)
self.dig_progress.snowballs_displays.append(self.dig_progress.SnowballDisplay(self.scene, self, size))

def spawn_snowball(self, size: int, pos: tuple[int, int], vel: tuple[int, int], follow: bool = True) -> None:
sb = Snowball(self.scene, VEC(vel), size, pos=pos, follow=follow)
def spawn_snowball(self, size: int, pos: tuple[int, int], vel: tuple[int, int], follow: bool = True, is_storm: bool = False) -> None:
sb = Snowball(self.scene, VEC(vel), size, pos=pos, follow=follow, is_storm=is_storm)
self.snowballs[sb.id] = sb

def pop_snowball(self) -> int:
Expand Down
7 changes: 4 additions & 3 deletions src/snowball.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from . import assets

class Snowball(VisibleSprite):
def __init__(self, scene: Scene, vel: tuple[float, float], sb_type: int, pos: VEC = None, follow: bool = True) -> None:
def __init__(self, scene: Scene, vel: tuple[float, float], sb_type: int, pos: VEC = None, follow: bool = True, is_storm: bool = False) -> None:
super().__init__(scene, Layers.SNOWBALL)
self.id = uuid4().hex

Expand All @@ -43,6 +43,7 @@ def __init__(self, scene: Scene, vel: tuple[float, float], sb_type: int, pos: VE
self.rot_speed = choice([randint(-400, -100), randint(100, 400)])
self.hit_player = None
self.follow = follow
self.is_storm = is_storm

if self.type == 2:
self.swirl = Swirl(self.scene, Layers.SNOWBALL, 64)
Expand All @@ -64,8 +65,8 @@ def update(self) -> None:
self.rotation += self.rot_speed * self.manager.dt
self.image = pygame.transform.rotate(self.frames[self.frame], self.rotation)

self.acc = VEC(0, GRAVITY)
self.acc += self.scene.wind_vel
self.acc = VEC(0, GRAVITY) * (0.4 if self.is_storm else 1)
self.acc += self.scene.wind_vel * (0.1 if self.is_storm else 1)

self.vel += self.acc * self.manager.dt
self.pos += self.vel * self.manager.dt
Expand Down
2 changes: 1 addition & 1 deletion src/storm.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def update(self) -> None:
if self.alpha >= 255:
if time.time() - self.snowball_timer > 0.18:
offset = VEC(choice(self.offsets)) * PIXEL_SIZE
self.scene.player.spawn_snowball(0, self.pos + offset, VEC(0, 0), follow=False)
self.scene.player.spawn_snowball(0, self.pos + offset, VEC(0, 0), follow=False, is_storm=True)
self.snowball_timer = time.time()

if time.time() - self.lifetime_timer > self.lifetime:
Expand Down

0 comments on commit ec609ca

Please sign in to comment.