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