diff --git a/outrun.rkt b/outrun.rkt index 0f04d5e..a778b74 100644 --- a/outrun.rkt +++ b/outrun.rkt @@ -145,17 +145,30 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; the lights -(define (make-sunlight dsun) - (sunlight - (angles->dir -30 (* 10 dsun)) - (emitted-hex "fffb96" 1/2))) +(define (make-sunlight i) + (define cx (cos (degrees->radians i))) + (define sx (sin (degrees->radians i))) + (define cx2 (cos (* 8 (degrees->radians i)))) + (define sx2 (sin (* 5 (degrees->radians i)))) + (define light-pos + (pos (* 2 cx2) (* 3 sx2) (* 2 sx2))) + (combine + (with-emitted (emitted-hex "fffb96" 1/2) + (sphere light-pos 0.1)) + (light light-pos (emitted-hex "fffb96" 10)) + (sunlight + (angles->dir -30 30) + (emitted "white" 1)))) -;; Calculate camera position based on the state +;; Calculate camera position based on the state. Returns a `pos`. (define (camera-position s) - (pos 0 (+ 4 (scene-state-dy s)) (- (scene-state-dz s) 4))) -;; Calculate camera direction based on the state + (pos (scene-state-dx s) (+ 4 (scene-state-dy s)) (- (scene-state-dz s) 4))) + +;; Calculate camera direction based on the state. Returns a `dir` or a `pos`. (define (camera-direction s) - (angles->dir -90 55)) + (angles->dir -90 55) + ;;origin +) (define (on-draw s n t) (combine (basis 'camera @@ -163,8 +176,8 @@ (camera-direction s))) (make-sunlight (scene-state-dsun s)) ;; (move-y (road t) -1) - ;; (spheres t) - ;; (scene t) + (spheres t) + (scene t) frozen-sspheres (mesh t) )) @@ -184,6 +197,10 @@ [dz (+ (scene-state-dz s) 0.1)])] [("s") (struct-copy scene-state s [dz (- (scene-state-dz s) 0.1)])] + [("a") (struct-copy scene-state s + [dx (+ (scene-state-dx s) 0.5)])] + [("d") (struct-copy scene-state s + [dx (- (scene-state-dx s) 0.5)])] [else s])) (define (stop-state? s n t) (scene-state-done? s))