- decks package: Hiragana, Katakana, Hangul jamo and Thai consonants (Thai readings carry the letter's name word, since sounds repeat) - Per-script fonts: Jua for Hangul, Mali for Thai (both OFL) - Memory game works with any deck; Easy 3x4, Normal 4x6, Hard 4x8 - Language menus pick a deck and difficulty, with number/arrow key shortcuts - Tests cover every deck, difficulty, and font glyph coverage Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
93 lines
2.5 KiB
Odin
93 lines
2.5 KiB
Odin
package main
|
|
|
|
import raylib "vendor:raylib"
|
|
import assets "src/assets"
|
|
import audio "src/audio"
|
|
import card "src/card"
|
|
import decks "src/decks"
|
|
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 .LANGUAGE_MENU: return .MAIN_MENU
|
|
case .MEMORY: return .LANGUAGE_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)
|
|
// Assets are loaded relative to the executable, so it can be started from anywhere
|
|
raylib.ChangeDirectory(raylib.GetApplicationDirectory())
|
|
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
|
|
language := decks.Language.JAPANESE
|
|
difficulty := memory.Difficulty.NORMAL
|
|
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 == .MEMORY {
|
|
memory.update(dt)
|
|
}
|
|
|
|
raylib.BeginDrawing()
|
|
ui.begin_frame()
|
|
next := screen
|
|
start_deck: Maybe(decks.Deck_Id)
|
|
switch screen {
|
|
case .MAIN_MENU:
|
|
if picked, ok := screens.main_menu().?; ok {
|
|
language = picked
|
|
next = .LANGUAGE_MENU
|
|
}
|
|
case .LANGUAGE_MENU:
|
|
switch result in screens.language_menu(language, &difficulty) {
|
|
case decks.Deck_Id:
|
|
start_deck = result
|
|
next = .MEMORY
|
|
case themes.Screen:
|
|
next = result
|
|
}
|
|
case .MEMORY:
|
|
next = memory.draw()
|
|
}
|
|
ui.end_frame()
|
|
raylib.EndDrawing()
|
|
|
|
// Building card faces renders into textures, so do it outside of drawing
|
|
if deck, ok := start_deck.?; ok {
|
|
memory.start(deck, difficulty)
|
|
}
|
|
screen = next
|
|
}
|
|
}
|