- 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>
78 lines
2.2 KiB
Odin
78 lines
2.2 KiB
Odin
package main
|
|
|
|
import raylib "vendor:raylib"
|
|
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"
|
|
|
|
// 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.SetConfigFlags({.MSAA_4X_HINT, .VSYNC_HINT})
|
|
raylib.InitWindow(themes.SCREEN_WIDTH, themes.SCREEN_HEIGHT, "HanjaKanaMun")
|
|
defer raylib.CloseWindow()
|
|
raylib.SetExitKey(.KEY_NULL)
|
|
raylib.SetTargetFPS(60)
|
|
|
|
raylib.InitAudioDevice()
|
|
defer raylib.CloseAudioDevice()
|
|
audio.load()
|
|
defer audio.unload()
|
|
|
|
assets.load_fonts()
|
|
defer assets.unload_fonts()
|
|
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
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|