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

+10
View File
@@ -13,6 +13,8 @@ import screens "src/screens"
import themes "src/themes"
import ui "src/ui"
TRANSITION_SPEED :: 4 // screen fade-ins per second
// Where Escape takes you from each screen (nil = quit)
parent_screen :: proc(screen: themes.Screen) -> Maybe(themes.Screen) {
switch screen {
@@ -53,6 +55,7 @@ main :: proc() {
if saved, ok := reflect.enum_from_name(memory.Difficulty, profile.data.difficulty); ok {
difficulty = saved
}
transition_t: f32 = 1 // fades the screen in from the background color
running := true
for running && !raylib.WindowShouldClose() {
dt := raylib.GetFrameTime()
@@ -60,6 +63,7 @@ main :: proc() {
if raylib.IsKeyPressed(.ESCAPE) {
if parent, ok := parent_screen(screen).?; ok {
screen = parent
transition_t = 1
} else {
running = false
}
@@ -90,6 +94,11 @@ main :: proc() {
case .MEMORY:
next = memory.draw()
}
if transition_t > 0 {
alpha := transition_t * transition_t
raylib.DrawRectangle(0, 0, themes.SCREEN_WIDTH, themes.SCREEN_HEIGHT, raylib.Fade(themes.MENU_BACKGROUND, alpha))
transition_t = max(transition_t - dt * TRANSITION_SPEED, 0)
}
ui.end_frame()
raylib.EndDrawing()
free_all(context.temp_allocator)
@@ -99,6 +108,7 @@ main :: proc() {
if deck, ok := start_deck.?; ok {
memory.start(deck, difficulty)
}
if next != screen { transition_t = 1 }
screen = next
}
}