(use-modules (chickadee graphics sprite) (chickadee) (chickadee graphics viewport)) (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 (draw-lanes startx starty num-lanes) (if (> num-lanes 0) (begin (draw-sprite road-lane (vec2 startx starty)) (draw-lanes startx (+ lane-height starty) (- 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 vehicles (load-tileset "vehicles.png" 100 45)) (define the-car (texture-atlas-ref vehicles 0)) (define car-ref 0) (define car-pos-x 0.0) (define car-speed 4.0) (define (draw alpha) ; Draw the road (draw-road 0 90 5) (draw-sprite (texture-atlas-ref vehicles car-ref) (vec2 car-pos-x 100)) (draw-text "Turbo racers!" (vec2 260.0 240.0)) (set! car-pos-x (+ car-speed car-pos-x)) (if (> car-pos-x (window-width (current-window))) (begin (set! car-pos-x 0.0) (if (= car-ref 8) (set! car-ref 0) (set! car-ref (+ 1 car-ref))))))