;; The first three lines of this file were inserted by DrScheme. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-reader.ss" "lang")((modname entry6) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp"))))) ; Purpose: To make a cartoon. ;Heres the world (start 1100 800) (draw-solid-rect (make-posn 0 128) 700 800 'brown) (define-struct disk (x y radius color)) ;(make-disk 90 90 20 'blue) (define (draw-a-disk a-disk) (draw-solid-disk (make-posn (disk-x a-disk) (disk-y a-disk)) (disk-radius a-disk) (disk-color a-disk))) (define-struct rect (x y width height color)) (define (draw-a-rect a-rect) (draw-solid-rect (make-posn (rect-x a-rect) (rect-y a-rect)) (rect-width a-rect) (rect-height a-rect) (rect-color a-rect))) (define (draw-car a-rect a-disk) (and (draw-solid-disk (make-posn (+ (rect-x a-rect) (disk-radius a-disk) 1) (+ (rect-y a-rect) (rect-height a-rect))) (disk-radius a-disk) (disk-color a-disk)) (draw-solid-disk (make-posn (- (+ (rect-x a-rect) (rect-width a-rect)) (disk-radius a-disk) 3) (+ (rect-y a-rect) (rect-height a-rect))) (disk-radius a-disk) (disk-color a-disk)) (draw-solid-rect (make-posn (+ (rect-x a-rect) (/ (rect-width a-rect) 4) -2) (- (rect-y a-rect) 15)) (/ (rect-width a-rect) 2) (/ (rect-height a-rect) 1.5) (rect-color a-rect)) (draw-solid-rect (make-posn (rect-x a-rect) (rect-y a-rect)) (rect-width a-rect) (rect-height a-rect) (rect-color a-rect)) (sleep-for-a-while .3) (clear-solid-disk (make-posn (+ (rect-x a-rect) (disk-radius a-disk) 1) (+ (rect-y a-rect) (rect-height a-rect))) (disk-radius a-disk)) (clear-solid-disk (make-posn (- (+ (rect-x a-rect) (rect-width a-rect)) (disk-radius a-disk) 3) (+ (rect-y a-rect) (rect-height a-rect))) (disk-radius a-disk)) (clear-solid-rect (make-posn (+ (rect-x a-rect) (/ (rect-width a-rect) 4) -2) (- (rect-y a-rect) 15)) (/ (rect-width a-rect) 2) (/ (rect-height a-rect) 1.5)) (clear-solid-rect (make-posn (rect-x a-rect) (rect-y a-rect)) (rect-width a-rect) (rect-height a-rect)) ) ) ;Heres the motion! (draw-car (make-rect 30 80 100 30 'red) (make-disk 0 0 16 'black)) (draw-car (make-rect 150 80 100 30 'red) (make-disk 0 0 16 'black)) (draw-car (make-rect 270 80 100 30 'red) (make-disk 0 0 16 'black)) (draw-car (make-rect 390 80 100 30 'red) (make-disk 0 0 16 'black)) (draw-car (make-rect 510 80 100 30 'red) (make-disk 0 0 16 'black)) (draw-car (make-rect 630 80 100 30 'red) (make-disk 0 0 16 'black)) (draw-car (make-rect 710 100 100 30 'red) (make-disk 0 0 16 'black)) (draw-car (make-rect 750 250 100 30 'red) (make-disk 0 0 16 'black)) (draw-car (make-rect 770 400 100 30 'red) (make-disk 0 0 16 'black)) (draw-car (make-rect 810 750 100 30 'red) (make-disk 0 0 16 'black)) ;Heres the boom. (draw-solid-disk (make-posn 860 750) 150 'yellow) (draw-solid-disk (make-posn 860 750) 100 'red) (draw-solid-disk (make-posn 860 750) 50 'yellow)