Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added __pycache__/end.cpython-313.pyc
Binary file not shown.
Binary file modified __pycache__/intro_scene.cpython-313.pyc
Binary file not shown.
Binary file modified __pycache__/level_data.cpython-313.pyc
Binary file not shown.
Binary file modified __pycache__/scenes.cpython-313.pyc
Binary file not shown.
Binary file modified __pycache__/tiles.cpython-313.pyc
Binary file not shown.
Binary file added assets/audio/ambient_loop.mpeg
Binary file not shown.
Binary file added assets/audio/collect.mpeg
Binary file not shown.
Binary file added assets/audio/win.mpeg
Binary file not shown.
Binary file added assets/end/dodo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/fundal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
66 changes: 66 additions & 0 deletions end.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import pygame
from pathlib import Path


class EndScene:
def __init__(self, manager, assets, on_exit, collected_count: int, required_count: int):
self.manager = manager
self.assets = assets
self.on_exit = on_exit
self.collected_count = collected_count
self.required_count = required_count

self.big_font = pygame.font.SysFont(None, 72)
self.mid_font = pygame.font.SysFont(None, 36)
self.small_font = pygame.font.SysFont(None, 28)

self.end_art = None
art_path = Path(__file__).resolve().parent / "assets/end/dodo.png"
try:
self.end_art = pygame.image.load(str(art_path)).convert_alpha()
except Exception:
self.end_art = None

try:
pygame.mixer.music.set_volume(0.08)
except Exception:
pass


def handle_event(self, event):
if event.type == pygame.KEYDOWN and event.key in (pygame.K_RETURN, pygame.K_SPACE, pygame.K_ESCAPE):
self.on_exit()

def update(self, dt):
pass

def draw(self, screen):
if self.end_art is not None:
bg = pygame.transform.smoothscale(self.end_art, screen.get_size())
screen.blit(bg, (0, 0))
elif getattr(self.assets, "background_img", None):
bg = pygame.transform.smoothscale(self.assets.background_img, screen.get_size())
screen.blit(bg, (0, 0))
else:
screen.fill((12, 12, 18))

overlay = pygame.Surface(screen.get_size(), pygame.SRCALPHA)
overlay.fill((0, 0, 0, 145))
screen.blit(overlay, (0, 0))

title = self.big_font.render("THE END", True, (120, 240, 140))
line1 = self.mid_font.render("You entered the green portal.", True, (235, 235, 235))
line2 = self.small_font.render("Press ENTER / SPACE / ESC to return to HUB", True, (200, 200, 200))
count = self.small_font.render(
f"Collected: {self.collected_count}/{self.required_count}",
True,
(120, 240, 220),
)

cx = screen.get_width() // 2
cy = screen.get_height() // 2

screen.blit(title, (cx - title.get_width() // 2, cy - 96))
screen.blit(line1, (cx - line1.get_width() // 2, cy - 22))
screen.blit(count, (cx - count.get_width() // 2, cy + 20))
screen.blit(line2, (cx - line2.get_width() // 2, cy + 72))
59 changes: 54 additions & 5 deletions intro_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,26 @@
TEXT_PADDING = 20

FONT_SIZE = 32
TYPING_SPEED_FRAMES = 6
TYPING_SPEED_FRAMES = 8
SFX_CHAR_INTERVAL = 1


class TypewriterText:
def __init__(self, full_text: str, font: pygame.font.Font, max_width: int, speed_frames: int):
def __init__(self, full_text: str, font: pygame.font.Font, max_width: int, speed_frames: int, typing_sfx: pygame.mixer.Sound | None = None):
self.full_text = full_text or ""
self.font = font
self.max_width = max_width
self.speed = max(1, speed_frames)
self.typing_sfx = typing_sfx

self.frame_counter = 0
self.done = (self.full_text == "")

self.lines = self._wrap_text(self.full_text)
self.flat_text = "".join(self.lines)
self.visible_chars = 0
self.total_chars = sum(len(line) for line in self.lines)
self.total_chars = len(self.flat_text)
self.sfx_counter = 0

def _wrap_text(self, text: str):
if not text:
Expand All @@ -54,7 +58,17 @@ def update(self):
self.frame_counter += 1
if self.frame_counter >= self.speed:
self.frame_counter = 0
self.visible_chars += 1
if self.visible_chars < self.total_chars:
ch = self.flat_text[self.visible_chars]
self.visible_chars += 1
if self.typing_sfx is not None:
self.sfx_counter += 1
if self.sfx_counter >= SFX_CHAR_INTERVAL:
self.sfx_counter = 0
try:
self.typing_sfx.play()
except Exception:
pass
if self.visible_chars >= self.total_chars:
self.visible_chars = self.total_chars
self.done = True
Expand Down Expand Up @@ -197,6 +211,7 @@ def __init__(self, manager, game_assets, hub_scene_ctor, intro_dir: Path):
pygame.font.init()
self.font = pygame.font.SysFont("monospace", FONT_SIZE)
self.prompt_font = pygame.font.SysFont("monospace", 18)
self.typing_sfx = self._load_typing_sfx()

self.script = [
("frame1.jpg", "The Dodo was always a suspicious bird, so the caveman wanted to follow it"),
Expand All @@ -209,11 +224,45 @@ def __init__(self, manager, game_assets, hub_scene_ctor, intro_dir: Path):
self.frames = []
for fname, text in self.script:
bg = _load_and_fit_bg(self.intro_dir / fname)
tw = TypewriterText(text, self.font, TEXT_BOX_W - TEXT_PADDING * 2, TYPING_SPEED_FRAMES)
tw = TypewriterText(text, self.font, TEXT_BOX_W - TEXT_PADDING * 2, TYPING_SPEED_FRAMES, self.typing_sfx)
self.frames.append({"bg": bg, "tw": tw, "is_last": (fname == "frame5.jpg")})

self.index = 0


def _load_typing_sfx(self):
audio_dir = self.intro_dir.parent / "audio"
project_dir = self.intro_dir.parent.parent

candidates = [
project_dir / "mixkit-hard-typewriter-click-1119.wav",
self.intro_dir / "mixkit-hard-typewriter-click-1119.wav",
audio_dir / "mixkit-hard-typewriter-click-1119.wav",
]

for path in candidates:
if not path.exists():
continue
try:
s = pygame.mixer.Sound(str(path))
s.set_volume(0.35)
return s
except Exception:
continue

for stem in ("typewriter", "typing", "keyboard", "keys", "collect"):
for ext in (".wav", ".ogg", ".mp3", ".mpeg"):
path = audio_dir / f"{stem}{ext}"
if not path.exists():
continue
try:
s = pygame.mixer.Sound(str(path))
s.set_volume(0.35)
return s
except Exception:
continue
return None

def _cur(self):
return self.frames[self.index]

Expand Down
88 changes: 46 additions & 42 deletions level_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""
Maps generated directly from HARTI.xlsx.
Each string is exactly 80 chars wide, and each map has 45 rows.
Updated cave maps for Finding Dodo.
HUB adjusted to match the cave layout request:
- left shaft filled with solid rock
- HUB spikes removed
- portal to LEVEL1 moved to upper corridor
- portal to LEVEL2 moved to middle-right corridor
"""

WIDTH = 80
Expand Down Expand Up @@ -33,24 +37,24 @@
"################################################################################",
"################################################################################",
"...............................................#################################",
".......P.......................................#################################",
"...............................................#################################",
"...PPPPP.................................111111#################################",
"...PPPPP.................................111111#################################",
"...PPPPP.................................111111#################################",
".........................................11....#################################",
".........................................11....#################################",
"....############....############################################################",
"....############...................................................#############",
"....############...................................................#############",
"....############...................................................#############",
"....####################...........................................#############",
"....####################.....................................222222#############",
"....####################.....................................222222#############",
"....####################.....................................222222#############",
"....###~~~~~~~~~#######################....#####################################",
"....###~~~~~~~~~~######################.......................^^^^............##",
"....#~~~~~~~~~~~~######################.........................^.........FFFF##",
"....#~~~~~~~~~~########################...................................FFFF##",
"....###############################################~~~~#########################",
"....################################################~###########################",
"################...................................................#############",
"################...................................................#############",
"################...................................................#############",
"########################...........................................#############",
"########################...........................................#############",
"########################......................................22...#############",
"########################......................................22...#############",
"#######################################....#####################################",
"#######################################.......................................##",
"#######################################...................................FFFF##",
"#######################################...................................FFFF##",
"################################################################################",
"################################################################################",
"....############################################################################",
"....############################################################################",
"....############################################################################",
Expand All @@ -72,8 +76,8 @@
"###############################################################################.",
"###############################################################################.",
"############################################.......##############^^############.",
"..#############....^^^^#####################.......############..^^############.",
"..#############.....^^.#####################.......############...^.###########.",
"..#############......^^#####################.......############..^^..##########.",
"..#############........#####################.......############...^..##########.",
"..#############........#####...................CCC.###..........................",
"..#############........#####...................CCC.###..........................",
"..#######..............#####...................CCC.###.............######....RR.",
Expand Down Expand Up @@ -118,30 +122,30 @@

LEVEL2 = [
"################################################################################",
"############################################################..........##########",
"###########.......##########################################..........##########",
"..............................^^^^^.........................................####",
"....PP.........................^^^.......................................CC.####",
"....PP...................................#############.........####......CC.####",
"....########~~~~###########..............####################~~~~~~~~###########",
"....#########~#############.........##########################~~~~~~############",
"....#######################.........###########################~~~##############",
"....##############..................############################################",
"....##############...........############^^^##########....................######",
"....#######..................############^^^##########....................######",
"....#######.................#############.^.##########....................######",
"....####...........######################...####..........................######",
"############~~~~###########..............####################~~~~~~~~###########",
"#############~#############.........##########################~~~~~~############",
"###########################.........###########################~~~##############",
"##################..................############################################",
"##################...........############^^^##########....................######",
"###########..................############^^^##########....................######",
"###########.................#############.^.##########....................######",
"########...........######################...####..........................######",
"....####...........##########...............####........................CC######",
"....##......#################...........................................CC######",
"....##....#########.................................................#~~#########",
"....##....########..................#############################...#~~#########",
"....##....########..................##############################..#~~~########",
"....##....########.................###############################..###~########",
"....##....########..............##############^^.........#########..############",
"....##....########..............#########.....^^.............#####..############",
"....##....########..............#########..CC.^...............####..############",
"....##....########..............##############...........#########..############",
"....##....########..............#########....................#####..############",
"....##....########..............#########..CC.................####..############",
"....##....####.................##########..CC.....#~~~##......####..############",
"....##....####...............#################..###~~~#####...####..########^^..",
"....##....##.................#################..#~~~#######..####...########^^..",
"....##....##.................#################..#~~~######...####...########^^..",
"....##....##................##################.##~~###.......####...########^...",
"....##....##................##########################......#####...............",
"....##....##................#######################.......#######...............",
Expand All @@ -150,16 +154,16 @@
"....##....##.......#######..........#######............#.......##...............",
"....##....##.......#######..........#####...........######.....##.............RR",
"....##.....#.......#######..........#####...........######.....##.............RR",
"....##..........##############..............##~~~~##########...........#~~~#####",
"....##..........########.#####..............###~############...........##~######",
"....##..........##############..............##~~~~##########...........###~#####",
"....##..........########.#####..............###~############...........#########",
"....##..........########.#####..............####~###########.........###########",
"....##..........######...#####......#############################....###########",
"....####..############...#####......#############################.....##########",
"....####..############CC.^^#######..#############################.....##########",
"....##....############CC.^.#######..#############################.....##########",
"....##..vv############.......#####..###########################.......##########",
"....##..vv###############....#####..###########################.......##########",
"....##vvvv###############.........................................vv..##########",
"....##..........######....####......#############################....###########",
"....####..############....####......#############################.....##########",
"....####..############.....#######..#############################.....##########",
"....##....############CC....######..#############################.....##########",
"....##..vv############cc......####..###########################.......##########",
"....##..vv###############.......##..###########################.......##########",
"....##vvvv###############.............................................##########",
"....##vvvv###############..###...................................vvvv.##########",
"....##vvvv######################################################################",
]
Expand Down
Loading