Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

Commit

Permalink
Add fullscreen, fix game_end screen
Browse files Browse the repository at this point in the history
  • Loading branch information
ShelkovkinaM committed Feb 20, 2024
1 parent 2701e9e commit dc5c063
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion danmaku/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def get_settings() -> dict:
value = int(setting.value)
possible_values = list(map(int, setting.possible_values.split(";")))
case "bool":
value = bool(setting.value)
value = setting.value == "True"
possible_values = [True, False]
case "str":
value = setting.value
Expand Down
2 changes: 1 addition & 1 deletion danmaku/game/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Game(vgame.Scene):
new_game: bool = True

def load(self):
self.game_border = self.width * 2 // 3
self.game_border = self.width // 4 * 3
STAGE1 = Stage([Enemy((150, 15), "basic enemy")])
STAGE2 = Stage(
[Enemy((50, -25), "basic enemy"), Enemy((200, -50), "basic enemy")]
Expand Down
15 changes: 11 additions & 4 deletions danmaku/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from danmaku.ui.history import History
from danmaku.ui.settings import Settings
from danmaku.ui.game_end import GameEnd
from danmaku.database import get_settings

WIDTH, HEIGHT = 500, 500
TICKRATE = 120
Expand All @@ -17,7 +18,8 @@

def run_game(is_new: bool):
"Game exit handling"
game = Game(width=WIDTH, height=HEIGHT, title="Danmaku | Game", tickrate=TICKRATE)
game = Game(width=WIDTH, height=HEIGHT, title="Danmaku | Game", tickrate=TICKRATE,
fullscreen=get_settings()["fullscreen"]["value"])
game.new_game = is_new
runner.run(game)

Expand All @@ -28,6 +30,7 @@ def run_game(is_new: bool):
height=HEIGHT,
title="Danmaku | Game Over",
tickrate=TICKRATE,
fullscreen=get_settings()["fullscreen"]["value"]
)
end.set("You win", (30, 157, 214), "sounds/win.wav")
runner.run(end)
Expand All @@ -37,20 +40,24 @@ def run_game(is_new: bool):
height=HEIGHT,
title="Danmaku | Game Over",
tickrate=TICKRATE,
fullscreen=get_settings()["fullscreen"]["value"]
)
end.set("Game over", (30, 157, 214), "sounds/lose.wav")
runner.run(end)


while runner.running:
menu = Menu(width=WIDTH, height=HEIGHT, title="Danmaku | Menu")
menu = Menu(width=WIDTH, height=HEIGHT, title="Danmaku | Menu",
fullscreen=get_settings()["fullscreen"]["value"])
runner.run(menu)
match menu.exit_status:
case "game", new_game:
run_game(new_game)
case "settings":
settings = Settings(width=WIDTH, height=HEIGHT, title="Danmaku | Settings")
settings = Settings(width=WIDTH, height=HEIGHT, title="Danmaku | Settings",
fullscreen=get_settings()["fullscreen"]["value"])
runner.run(settings)
case "history":
history = History(width=WIDTH, height=HEIGHT, title="Danmaku | History")
history = History(width=WIDTH, height=HEIGHT, title="Danmaku | History",
fullscreen=get_settings()["fullscreen"]["value"])
runner.run(history)
6 changes: 3 additions & 3 deletions danmaku/ui/game_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ def set(self, text: str, background: tuple[int, int, int], music: str):
self.delta_color = 0
self.background_color = background
self.text_color: list[int] = list(background)
self.v = (255 - self.text_color[self.delta_color]) // 500
self.v = (255 - self.text_color[self.delta_color]) / 500
self.music = music

def update(self):
for i in range(3):
if i == self.delta_color:
self.text_color[i] += self.v
else:
if self.text_color[i] - 50 > 0:
self.text_color[i] -= 50
if self.text_color[i] - self.v > 0:
self.text_color[i] -= self.v
if self.text_color[self.delta_color] + self.v >= 255:
pygame.time.wait(1000)
self.stop()
Expand Down

0 comments on commit dc5c063

Please sign in to comment.