Add justfile, ols/odinfmt config, tests and Gitea workflows; drop odin.json
- justfile with build/run/check/test/release/package/fmt/clean recipes - ols.json and odinfmt.json for neovim (ols) - Tests for memory game rules and card animation; memory.deal and memory.select_card split out so logic is testable without a window - Gitea workflows: build+test on main/develop, package and upload to the generic package registry on version branches - Game changes to the executable's directory so packaged builds find assets Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
148570a4e6
commit
9ee2eabe9a
12 files changed
+428
-23
No files matched your search
+12
-6
@@ -51,7 +51,14 @@ resolve_timer: f32
|
||||
win_t: f32 // fades in the win panel
|
||||
restart_requested: bool
|
||||
|
||||
// Deals a new game and renders the card faces. Needs the window to exist.
|
||||
start :: proc(game_theme: themes.Theme) {
|
||||
deal(game_theme)
|
||||
for &c in cards { card.build_face(&c, theme) }
|
||||
}
|
||||
|
||||
// Shuffles, lays out and resets the game state without touching the GPU
|
||||
deal :: proc(game_theme: themes.Theme) {
|
||||
theme = game_theme
|
||||
|
||||
deck := HIRAGANA
|
||||
@@ -75,7 +82,6 @@ start :: proc(game_theme: themes.Theme) {
|
||||
themes.CARD_WIDTH,
|
||||
themes.CARD_HEIGHT,
|
||||
}
|
||||
card.build_face(&c, theme)
|
||||
}
|
||||
|
||||
state = .WAITING
|
||||
@@ -93,14 +99,14 @@ unload :: proc() {
|
||||
for &c in cards { card.unload_face(&c) }
|
||||
}
|
||||
|
||||
@(private)
|
||||
can_pick :: proc(i: int) -> bool {
|
||||
c := &cards[i]
|
||||
return (state == .WAITING || state == .FIRST) && !c.face_up && !c.matched
|
||||
}
|
||||
|
||||
@(private)
|
||||
pick :: proc(i: int) {
|
||||
// Turns card i face up if it can be picked. Returns false when the pick is not allowed.
|
||||
select_card :: proc(i: int) -> bool {
|
||||
if !can_pick(i) { return false }
|
||||
cards[i].face_up = true
|
||||
audio.play(.FLIP)
|
||||
if state == .WAITING {
|
||||
@@ -113,6 +119,7 @@ pick :: proc(i: int) {
|
||||
resolve_timer = is_match ? MATCH_DELAY : MISMATCH_DELAY
|
||||
state = .RESOLVING
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@(private)
|
||||
@@ -155,8 +162,7 @@ update :: proc(dt: f32) {
|
||||
elapsed += dt
|
||||
if raylib.IsMouseButtonPressed(.LEFT) {
|
||||
for &c, i in cards {
|
||||
if can_pick(i) && card.is_hovered(&c) {
|
||||
pick(i)
|
||||
if card.is_hovered(&c) && select_card(i) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user