diff options
author | David Thompson <dthompson2@worcester.edu> | 2024-04-20 08:07:00 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2024-04-20 08:07:14 -0400 |
commit | 9a19f12c464468427a4b4526c354c0934e93ea87 (patch) | |
tree | 22367e981ce76c630ecb3516c4491fcbf053f372 | |
parent | e83d8bc5f53076280e3e6bf1a9512272dc68e6da (diff) |
examples: model: Pause rotation with space key.
-rw-r--r-- | examples/model.scm | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/examples/model.scm b/examples/model.scm index 4fa42c7..357a7c7 100644 --- a/examples/model.scm +++ b/examples/model.scm @@ -17,6 +17,7 @@ (define text-position (vec2 4.0 464.0)) (define text "") (define y-rotation 0.0) +(define rotate-paused? #f) (define (reset-position) (set-vec3! position 0.0 0.0 -4.0)) @@ -56,15 +57,18 @@ (vec3 0.0 1.0 0.0)) ;; Rotate the model about the y-axis - (set! y-rotation (+ y-rotation 0.03)) - (matrix4-rotate-y! model-matrix y-rotation)) + (unless rotate-paused? + (set! y-rotation (+ y-rotation 0.03)) + (matrix4-rotate-y! model-matrix y-rotation))) (define (key-press key modifiers repeat?) - (cond - ((eq? key 'q) + (case key + ((q) (abort-game)) - ((eq? key 'r) - (reset-position)))) + ((r) + (reset-position)) + ((space) + (set! rotate-paused? (not rotate-paused?))))) (run-game #:window-title "3D!" #:load load |