(use-modules (chickadee graphics sprite) (chickadee) (chickadee graphics viewport) (ice-9 pretty-print)) (define lane-height 65) (define lane-length 200) (define road (load-tileset "road.png" lane-length lane-height)) (define road-top (texture-atlas-ref road 2)) (define road-bottom (texture-atlas-ref road 0)) (define road-lane (texture-atlas-ref road 1)) (define road-start-y 80) (define (draw-lanes x y num-lanes) (if (> num-lanes 0) (begin (draw-sprite road-lane (vec2 x y)) (draw-lanes x (+ lane-height y) (- num-lanes 1))))) (define (draw-road-section startx starty num-lanes) (draw-sprite road-bottom (vec2 startx starty)) (draw-lanes startx (+ lane-height starty) (- num-lanes 2)) (draw-sprite road-top (vec2 startx (+ starty (* lane-height (- num-lanes 1)))))) (define (draw-road startx starty num-lanes) (if (< startx (window-width (current-window))) (begin (draw-road-section startx starty num-lanes) (draw-road (+ startx lane-length) starty num-lanes)))) (define (lane-y num-lane) (+ road-start-y (* lane-height (- num-lane 1)))) (define vehicle-height 45) (define vehicle-length 100) (define vehicles (load-tileset "vehicles.png" vehicle-length vehicle-height)) (define the-car (texture-atlas-ref vehicles 0)) (define car-ref 0) (define car-pos-x 0.0) (define car-speed 4.0) (define car-steering 4.0) (define player-initial-position (vec2 (/ (- (window-width (current-window)) vehicle-length) 2) (+ (lane-y 3) (/ (- lane-height vehicle-height) 2)))) (define (draw alpha) ;; Draw the road (draw-road 0 road-start-y 5) (draw-text "Turbo Racers!" (vec2 260.0 (- (window-height (current-window)) 25))) (draw-sprite the-car player-initial-position) )