This repository has been archived by the owner on Feb 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
143 additions
and
56 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
""" | ||
Game contains levels | ||
Level contains stages | ||
Stage contains enemies and/or boss | ||
""" | ||
|
||
import pygame | ||
|
||
from danmaku.enemy import Enemy | ||
|
||
|
||
class Stage: | ||
enemies: list[Enemy] | ||
|
||
start_time: int | ||
# appearance of enemies can be bound to time | ||
|
||
def __init__(self, enemies: list[Enemy]) -> None: | ||
self.enemies = list(enemies) | ||
|
||
self.start_time = pygame.time.get_ticks() | ||
|
||
|
||
class BossStage(Stage): | ||
# +enemies: list[Enemy] | ||
boss: Enemy | ||
|
||
## Boss actions ## | ||
# Boss actions are bound to time passed from stage start | ||
# Actions are being stored in tuples in format: | ||
# (time in milliseconds, action, args) | ||
|
||
# ( 1000, "move_to", (10, 20) ) | ||
# ( 2000, "shoot_radial", () ) | ||
|
||
|
||
class Level: | ||
stages: list[Stage] | ||
current_stage: int | ||
|
||
enemies: list # enemies from current stage | ||
|
||
def __init__(self, stages: list[Stage]) -> None: | ||
self.stages = list(stages) | ||
self.current_stage = 0 | ||
self.enemies = list(self.stages[self.current_stage].enemies) | ||
|
||
def __len__(self) -> int: | ||
return len(self.stages) | ||
|
||
def __getitem__(self, index: int) -> Stage: | ||
return self.stages[index] | ||
|
||
def next_stage(self) -> bool: | ||
if len(self.stages) > self.current_stage + 1: | ||
self.current_stage += 1 | ||
self.enemies = list(self.stages[self.current_stage].enemies) | ||
return True | ||
return False | ||
|
||
def set_stage(self, index: int) -> None: | ||
self.current_stage = index | ||
self.enemies = list(self.stages[self.current_stage].enemies) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters