Browse Source

Reorder layers, tweak slides, fix anim stopping

master
Macoy Madson 5 months ago
parent
commit
41c0736f43
  1. 4
      data/DrivingCodeWithData.cakedata
  2. 70
      src/Presentation.cake

4
data/DrivingCodeWithData.cakedata

@ -6,7 +6,7 @@
(slide-data :heading "Setting the stage" :trigger "enter-wizard")
(slide-data :heading "Setting the stage" :trigger "enter-boar")
(slide-data :heading "Setting the stage"
:body "(Art by Pixel-boy. Creative Commons Zero license.)")
:body "(Art by Pixel-boy)")
(slide-data :heading "First pass"
:is-code true
:body "if shouldShootFireball():
@ -24,7 +24,7 @@ for each fireball:
{
makeFireball();
}
else if shouldShootIceStore():
else if shouldShootIceStorm():
{
makeIceStorm();
}

70
src/Presentation.cake

@ -459,13 +459,15 @@
(when (keybind-tapped (addr s-toggle-debug-overlay-keybind) (addr s-key-states))
(set s-enable-debug-overlay (not s-enable-debug-overlay)))
(when (keybind-tapped (addr s-attack-keybind) (addr s-key-states))
(when (and
(!= current-wizard-animation (addr anim-wizard-fast-attack))
(keybind-tapped (addr s-attack-keybind) (addr s-key-states)))
(set wizard-animation-start-ticks (SDL_GetPerformanceCounter))
(set current-wizard-animation (addr anim-wizard-fast-attack))
(set boar-animation-start-ticks (SDL_GetPerformanceCounter))
(set current-boar-animation (addr anim-boar-jump-in)))
(SDL_SetRenderDrawColor renderer 17 17 17 255)
(SDL_SetRenderDrawColor renderer 11 19 40 255)
(SDL_RenderClear renderer)
(when s-draw-atlases
@ -502,6 +504,20 @@
(var slide (* slide-data) (addr (at current-slide-index (field presentation slides))))
(when should-render-ground
(var source-rectangle SDL_Rect
(array 0 0
ground-width
ground-height))
(var destination-rectangle SDL_Rect
(array 0 (- window-height ground-height)
window-width
ground-height))
(unless (= 0 (SDL_RenderCopy renderer ground-texture
(addr source-rectangle) (addr destination-rectangle)))
(sdl-print-error)
(set exit-reason "SDL failed to render ground")))
(render-string
renderer (addr ubuntu-regular-large-font-atlas) ubuntu-regular-large-texture
(+ text-x (/ window-width 8)) (/ window-height 8)
@ -517,6 +533,24 @@
(+ text-x (/ window-width 7)) (/ window-height 4)
(path slide > body)))
(when should-render-wizard
(unless wizard-animation-start-ticks
(set wizard-animation-start-ticks (SDL_GetPerformanceCounter)))
(render-animation
renderer (addr spritesheet-wizard) (addr current-wizard-animation)
wizard-animation-start-ticks c-animation-frame-rate
(type-cast (* window-width 0.08f) int)
(- window-height (/ ground-height 2) wizard-ground-height)))
(when should-render-boar
(unless boar-animation-start-ticks
(set boar-animation-start-ticks (SDL_GetPerformanceCounter)))
(render-animation
renderer (addr spritesheet-boar) (addr current-boar-animation)
boar-animation-start-ticks c-animation-frame-rate
(type-cast (* window-width 0.70f) int)
(- window-height (/ ground-height 2) boar-ground-height)))
(when s-enable-debug-overlay
(var buffer ([] 256 char) (array 0))
(var mouse-x int 0)
@ -538,38 +572,6 @@
;; return 1;
;; }#"#)
(when should-render-ground
(var source-rectangle SDL_Rect
(array 0 0
ground-width
ground-height))
(var destination-rectangle SDL_Rect
(array 0 (- window-height ground-height)
window-width
ground-height))
(unless (= 0 (SDL_RenderCopy renderer ground-texture
(addr source-rectangle) (addr destination-rectangle)))
(sdl-print-error)
(set exit-reason "SDL failed to render ground")))
(when should-render-wizard
(unless wizard-animation-start-ticks
(set wizard-animation-start-ticks (SDL_GetPerformanceCounter)))
(render-animation
renderer (addr spritesheet-wizard) (addr current-wizard-animation)
wizard-animation-start-ticks c-animation-frame-rate
(type-cast (* window-width 0.08f) int)
(- window-height (/ ground-height 2) wizard-ground-height)))
(when should-render-boar
(unless boar-animation-start-ticks
(set boar-animation-start-ticks (SDL_GetPerformanceCounter)))
(render-animation
renderer (addr spritesheet-boar) (addr current-boar-animation)
boar-animation-start-ticks c-animation-frame-rate
(type-cast (* window-width 0.70f) int)
(- window-height (/ ground-height 2) boar-ground-height)))
(SDL_RenderPresent renderer)
(SDL_UpdateWindowSurface window)

Loading…
Cancel
Save