Add screen fade-in and card deal-in animations

Cards slide in one after another when a game starts and can't be picked
until they have landed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SansanandClaude Opus 5.5 committed 2026-10-01 21:36:54 +02:00
1 parent 83ff9511ec
commit 3794a9e2e9
4 files changed
+1751 -1159

No files matched your search

+9 -3
View File
@@ -106,6 +106,7 @@ deal :: proc(deck_id: decks.Deck_Id, game_difficulty: Difficulty) {
start_x := (themes.SCREEN_WIDTH - total_w) / 2
start_y := themes.GRID_TOP + (themes.SCREEN_HEIGHT - 16 - themes.GRID_TOP - total_h) / 2
for &c, i in active_cards() {
card.start_deal(&c, i)
c.rect = {
start_x + f32(i % layout.cols) * step_x,
start_y + f32(i / layout.cols) * step_y,
@@ -134,6 +135,11 @@ unload :: proc() {
for &c in cards { card.unload_face(&c) }
}
// Whether the player can click or press on card i right now (it must have finished being dealt)
can_interact :: proc(i: int) -> bool {
return can_pick(i) && cards[i].deal_t == 0
}
can_pick :: proc(i: int) -> bool {
if i < 0 || i >= card_count { return false }
c := &cards[i]
@@ -190,7 +196,7 @@ handle_keyboard :: proc() {
}
if raylib.IsKeyPressed(.ENTER) || raylib.IsKeyPressed(.SPACE) {
keyboard_active = true
select_card(focus)
if can_interact(focus) { select_card(focus) }
}
}
@@ -236,7 +242,7 @@ update :: proc(dt: f32) {
elapsed += dt
if raylib.IsMouseButtonPressed(.LEFT) {
for &c, i in active_cards() {
if card.is_hovered(&c) && select_card(i) {
if card.is_hovered(&c) && can_interact(i) && select_card(i) {
break
}
}
@@ -271,7 +277,7 @@ draw :: proc() -> themes.Screen {
}
for &c, i in active_cards() {
card.draw(&c, theme, can_pick(i), focused = keyboard_active && i == focus && state != .OVER)
card.draw(&c, theme, can_interact(i), focused = keyboard_active && i == focus && state != .OVER && c.deal_t == 0)
}
if state == .OVER {