Browse Source

Get animation working

master
Macoy Madson 1 year ago
parent
commit
505a532d30
  1. 25
      src/Presentation.cake

25
src/Presentation.cake

@ -239,6 +239,8 @@
(var current-slide-index int 0)
(var slide-start-ticks Uint64 0)
(var animation-start-ticks Uint64 (SDL_GetPerformanceCounter))
(var exit-reason (* (const char)) null)
(while true
(var event SDL_Event)
@ -334,16 +336,29 @@
;; return 1;
;; }#"#)
(var wizard-width int 161)
(var wizard-height int 106)
(var animation-time-seconds float
(/ (- (SDL_GetPerformanceCounter) animation-start-ticks)
(type-cast (SDL_GetPerformanceFrequency) float)))
(var loop-rate float 0.7f)
(var num-frames int 6)
(var-cast-to current-frame int
(interpolate-range
0.f (type-cast num-frames float)
0.f loop-rate
(- animation-time-seconds
(* loop-rate (truncf (/ animation-time-seconds loop-rate))))))
(when (> current-slide-index 0)
(var source-rectangle SDL_Rect
(array 38 0
106
107))
(array (* current-frame wizard-width) 0
wizard-width
wizard-height))
(var destination-rectangle SDL_Rect
(array (type-cast (* window-width 0.08f) int)
(type-cast (* window-height 0.77f) int)
(* 2 106)
(* 2 107)))
(* 2 wizard-width)
(* 2 wizard-height)))
(unless (= 0 (SDL_RenderCopyEx renderer wizard-texture
(addr source-rectangle) (addr destination-rectangle)
0.f null ;; no rotation

Loading…
Cancel
Save