Restructure into themed screens with flag card backs, real font, flip animation and sound
- Replace the bogus DroidSansJapanese.ttf (an HTML page) with M PLUS Rounded 1c, loaded with LoadFontEx and explicit kana codepoints - Theme struct per language with flag-based card backs (Hinomaru, Taegukgi, Trairong) - Card art rendered to textures so the flip squashes the whole card - Synthesized flip/match/mismatch/win/click sounds (new audio package) - Shared ui package for text and buttons; Screen enum replaces i32 ids - Kana <-> romaji pairs drawn from all 46 basic hiragana Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5557de62a3
commit
5806f0498c
11 files changed
+1046
-425
No files matched your search
@@ -1,56 +1,77 @@
|
||||
package main
|
||||
|
||||
import raylib "vendor:raylib"
|
||||
import themes "src/themes"
|
||||
import screens "src/screens"
|
||||
import memory "src/memory"
|
||||
import assets "src/assets"
|
||||
import audio "src/audio"
|
||||
import card "src/card"
|
||||
import memory "src/memory"
|
||||
import screens "src/screens"
|
||||
import themes "src/themes"
|
||||
import ui "src/ui"
|
||||
|
||||
current_screen: i32 = themes.MAIN_MENU
|
||||
mouse_x: i32
|
||||
mouse_y: i32
|
||||
// Where Escape takes you from each screen (nil = quit)
|
||||
parent_screen :: proc(screen: themes.Screen) -> Maybe(themes.Screen) {
|
||||
switch screen {
|
||||
case .MAIN_MENU: return nil
|
||||
case .JAPANESE_MEMORY: return .JAPANESE_MENU
|
||||
case .JAPANESE_MENU, .KOREAN_MENU, .THAI_MENU: return .MAIN_MENU
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
main :: proc() {
|
||||
raylib.InitWindow(themes.SCREEN_WIDTH, themes.SCREEN_HEIGHT, cstring("HanjaKanaMun"))
|
||||
raylib.SetConfigFlags({.MSAA_4X_HINT, .VSYNC_HINT})
|
||||
raylib.InitWindow(themes.SCREEN_WIDTH, themes.SCREEN_HEIGHT, "HanjaKanaMun")
|
||||
defer raylib.CloseWindow()
|
||||
raylib.SetExitKey(raylib.KeyboardKey.KEY_NULL)
|
||||
|
||||
raylib.SetExitKey(.KEY_NULL)
|
||||
raylib.SetTargetFPS(60)
|
||||
|
||||
raylib.InitAudioDevice()
|
||||
defer raylib.CloseAudioDevice()
|
||||
audio.load()
|
||||
defer audio.unload()
|
||||
|
||||
assets.load_fonts()
|
||||
defer assets.unload_fonts()
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
memory.init_memory_game()
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
mouse_x = raylib.GetMouseX()
|
||||
mouse_y = raylib.GetMouseY()
|
||||
|
||||
if raylib.IsKeyPressed(raylib.KeyboardKey.ESCAPE) {
|
||||
current_screen = themes.MAIN_MENU
|
||||
}
|
||||
|
||||
if current_screen == themes.JAPANESE_MEMORY {
|
||||
delta_time := raylib.GetFrameTime()
|
||||
memory.update_memory_game(delta_time, mouse_x, mouse_y)
|
||||
}
|
||||
|
||||
raylib.BeginDrawing()
|
||||
|
||||
if current_screen == themes.MAIN_MENU {
|
||||
current_screen = screens.draw_main_menu(mouse_x, mouse_y)
|
||||
} else if current_screen == themes.JAPANESE_SCREEN {
|
||||
current_screen = screens.draw_japanese_screen(mouse_x, mouse_y)
|
||||
if current_screen == themes.JAPANESE_MEMORY {
|
||||
memory.init_memory_game()
|
||||
card.load_art()
|
||||
defer card.unload_art()
|
||||
defer memory.unload()
|
||||
|
||||
screen := themes.Screen.MAIN_MENU
|
||||
running := true
|
||||
for running && !raylib.WindowShouldClose() {
|
||||
dt := raylib.GetFrameTime()
|
||||
|
||||
if raylib.IsKeyPressed(.ESCAPE) {
|
||||
if parent, ok := parent_screen(screen).?; ok {
|
||||
screen = parent
|
||||
} else {
|
||||
running = false
|
||||
}
|
||||
} else if current_screen == themes.JAPANESE_MEMORY {
|
||||
current_screen = memory.draw_memory_game(mouse_x, mouse_y)
|
||||
} else if current_screen == themes.KOREAN_SCREEN {
|
||||
current_screen = screens.draw_korean_screen(mouse_x, mouse_y)
|
||||
} else if current_screen == themes.THAI_SCREEN {
|
||||
current_screen = screens.draw_thai_screen(mouse_x, mouse_y)
|
||||
}
|
||||
|
||||
|
||||
if screen == .JAPANESE_MEMORY {
|
||||
memory.update(dt)
|
||||
}
|
||||
|
||||
raylib.BeginDrawing()
|
||||
ui.begin_frame()
|
||||
next := screen
|
||||
switch screen {
|
||||
case .MAIN_MENU: next = screens.main_menu()
|
||||
case .JAPANESE_MENU: next = screens.japanese_menu()
|
||||
case .JAPANESE_MEMORY: next = memory.draw()
|
||||
case .KOREAN_MENU: next = screens.korean_menu()
|
||||
case .THAI_MENU: next = screens.thai_menu()
|
||||
}
|
||||
ui.end_frame()
|
||||
raylib.EndDrawing()
|
||||
|
||||
// Start a fresh game when entering the memory screen (outside of drawing,
|
||||
// because building card faces renders into textures)
|
||||
if next == .JAPANESE_MEMORY && screen != .JAPANESE_MEMORY {
|
||||
memory.start(themes.JAPAN)
|
||||
}
|
||||
screen = next
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user