basic camera movement
This commit is contained in:
parent
86c1a85534
commit
eba4fd5d5e
25
outrun.rkt
25
outrun.rkt
|
@ -5,11 +5,11 @@
|
|||
"noise.rkt")
|
||||
|
||||
(struct scene-state
|
||||
(done? dx dy dsun)
|
||||
(done? dx dy dz dsun)
|
||||
#:transparent)
|
||||
|
||||
(define init-scene-state
|
||||
(scene-state #f 0 0 0))
|
||||
(scene-state #f 0 0 0 0))
|
||||
|
||||
(current-material (material #:ambient 0.1
|
||||
#:diffuse 0.6
|
||||
|
@ -61,13 +61,20 @@
|
|||
(angles->dir -30 (* 10 dsun))
|
||||
(emitted "white" 1/2)))
|
||||
|
||||
;; Calculate camera position based on the state
|
||||
(define (camera-position s)
|
||||
(pos 0 (+ 4 (scene-state-dy s)) (- (scene-state-dz s) 4)))
|
||||
;; Calculate camera direction based on the state
|
||||
(define (camera-direction s)
|
||||
(angles->dir -90 55))
|
||||
|
||||
(define (on-draw s n t)
|
||||
(combine (basis 'camera
|
||||
(point-at (pos 0 4 -6) origin))
|
||||
(point-at (camera-position s)
|
||||
(camera-direction s)))
|
||||
(make-sunlight (scene-state-dsun s))
|
||||
(mesh t)
|
||||
;; (move-y (rotate-x scene (/ t 20)) 2)
|
||||
))
|
||||
(move-y (scene t) 2)))
|
||||
|
||||
(define (on-key s n t k)
|
||||
(case k
|
||||
|
@ -76,6 +83,14 @@
|
|||
[dsun (add1 (scene-state-dsun s))])]
|
||||
[("left") (struct-copy scene-state s
|
||||
[dsun (sub1 (scene-state-dsun s))])]
|
||||
[("up") (struct-copy scene-state s
|
||||
[dy (+ (scene-state-dy s) 0.1)])]
|
||||
[("down") (struct-copy scene-state s
|
||||
[dy (- (scene-state-dy s) 0.1)])]
|
||||
[("w") (struct-copy scene-state s
|
||||
[dz (+ (scene-state-dz s) 0.1)])]
|
||||
[("s") (struct-copy scene-state s
|
||||
[dz (- (scene-state-dz s) 0.1)])]
|
||||
[else s]))
|
||||
|
||||
(define (stop-state? s n t) (scene-state-done? s))
|
||||
|
|
Loading…
Reference in New Issue