;; The first three lines of this file were inserted by DrRacket. 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 |rocket final|) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "image.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "image.ss" "teachpack" "htdp"))))) (start 700 700) (draw-solid-rect(make-posn 0 600)700 100'green) (draw-solid-disk(make-posn 320 75)55'yellow) ;;rocket: number number -> symbol ;;to define a set of simple shapes as the image rocket that start in a particular spot on the canvas and then can be moved by x y coordinates. (define (rocket x y) (and (draw-solid-rect(make-posn(+ x 325)(+ y 510))25 90'red) (draw-solid-line(make-posn(+ x 325)(+ y 600))(make-posn (+ x 290)(+ y 600))'blue) (draw-solid-line(make-posn (+ x 290)(+ y 600))(make-posn (+ x 325)(+ y 550))'blue) (draw-solid-line(make-posn (+ x 350)(+ y 600))(make-posn (+ x 385)(+ y 600))'blue) (draw-solid-line(make-posn (+ x 385)(+ y 600))(make-posn (+ x 350)(+ y 550))'blue) (draw-solid-line(make-posn (+ x 325)(+ y 510))(make-posn (+ x 337.5)(+ y 490))'blue) (draw-solid-line(make-posn (+ x 350)(+ y 510))(make-posn (+ x 337.5)(+ y 490))'blue))) ;;(rocket -15 0) ;;clear-line : number number -> symbol ;;to clear the lines that make up parts of the rocket at point x y (define(clear-line x y) (and (clear-solid-line (make-posn(+ x 325)(+ y 600))(make-posn (+ x 290)(+ y 600))'blue) (clear-solid-line(make-posn (+ x 290)(+ y 600))(make-posn (+ x 325)(+ y 550))'blue) (clear-solid-line(make-posn (+ x 350)(+ y 600))(make-posn (+ x 385)(+ y 600))'blue) (clear-solid-line(make-posn (+ x 385)(+ y 600))(make-posn (+ x 350)(+ y 550))'blue) (clear-solid-line(make-posn (+ x 325)(+ y 510))(make-posn (+ x 337.5)(+ y 490))'blue) (clear-solid-line(make-posn (+ x 350)(+ y 510))(make-posn (+ x 337.5)(+ y 490))'blue))) ;;(clear-line -15 0) ;; clear-rocket : number number -> symbol ;; to clear the shape rocket at point x y. (define(clear-rocket x y) (and(clear-line x y) (clear-solid-rect(make-posn (+ x 325) (+ y 510))25 90'red))) ;; move-rocket number number number number number -> symbol ;; to move "rocket" from one point x y to another point x2 y2 sleeping for a given amount of time n. (define(move-rocket x y n x2 y2) (and(rocket x y) (sleep-for-a-while n) (clear-rocket x y) (rocket x2 y2))) ;;(move-rocket -15 0 2 -15 -105) ;;(move-rocket -15 -105 .5 -15 -205) ;;(move-rocket -15 -205 .5 -15 -305) ;;(move-rocket -15 -305 .5 -15 -335) ;; move-disk number number number color number -> symbol ;; to draw a disk at point x y with radius r and color c and then clearing that disk, but not before sleeping for a given amount of time n. (define(move-disk x y r c n) (and(draw-solid-disk(make-posn x y) r c) (sleep-for-a-while n) (clear-solid-disk(make-posn x y) r c))) ;;(move-disk 320 170 20 'blue .2) ;;(move-disk 320 170 40 'pink .2) ;;(move-disk 320 170 90 'red .2) ;;(move-disk 320 170 150 'orange .2) ;;(rocket -15 0) ;;(sleep-(draw-solid-rect(make-posn 0 600)700 100'green) (draw-solid-disk(make-posn 320 75)55'yellow) ;;(clear-rocket -15 0) ;;(rocket -15 -105) ;;(sleep-for-a-while .5) ;;(clear-rocket -15 -105) ;;(rocket -15 -205) ;;(sleep-for-a-while .5) ;;(clear-rocket -15 -205) ;;(rocket -15 -305) ;;(sleep-for-a-while .5) ;;(clear-rocket -15 -305) ;;(rocket -15 -335) ;;(sleep-for-a-while .5) ;;(clear-rocket -15 -335) ;;(sleep-for-a-while .1) ;;(draw-solid-disk(make-posn 320 170) 20'blue) ;;(sleep-for-a-while .1) ;;(clear-solid-disk(make-posn 320 170) 20'blue) ;;(draw-solid-disk(make-posn 320 170) 40'pink) ;;(sleep-for-a-while .1) ;;(clear-solid-disk(make-posn 320 170) 40'pink) ;;(sleep-for-a-while .1) ;;(draw-solid-disk(make-posn 320 170) 100'red) ;;(sleep-for-a-while .1) ;;(clear-solid-disk(make-posn 320 170) 100'red) ;;(sleep-for-a-while .1) ;;(draw-solid-disk(make-posn 320 170) 150'orange) ;;(sleep-for-a-while .1) ;;(clear-solid-rect(make-posn 290 65)100 75'orange) ;;(sleep-for-a-while .5) ;;(clear-solid-disk(make-posn 320 170) 100'red) ;;(sleep-for-a-while 1) ;;(clear-solid-disk(make-posn 320 170) 150'orange) ;;(sleep-for-a-while .1) ;; draw-stars : number number number -> symbol ;; to draw a group of solid yellow disks with radius r at points x y. (define(draw-stars x y r) (and (draw-solid-disk(make-posn (+ x 400)(+ y 50))(+ r 10)'yellow) (draw-solid-disk(make-posn (+ x 220)(+ y 70))(+ r 10)'yellow) (draw-solid-disk(make-posn (+ x 413) (+ y 120))(+ r 10)'yellow) (draw-solid-disk(make-posn (+ x 285) (+ y 175))(+ r 10)'yellow) (draw-solid-disk(make-posn (+ x 520) (+ y 130))(+ r 10)'yellow) (draw-solid-disk(make-posn (+ x 150) (+ y 80))(+ r 10)'yellow) (draw-solid-disk(make-posn (+ x 675) (+ y 10))(+ r 100)'yellow))) ;;(draw-stars 0 0 0) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rocket -15 0) (move-rocket -15 0 2 -15 -105) (move-rocket -15 -105 .5 -15 -205) (move-rocket -15 -205 .5 -15 -305) (move-rocket -15 -305 .5 -15 -400) (clear-rocket -15 -335) (sleep-for-a-while .1) (move-disk 320 170 20 'blue .2) (move-disk 320 170 40 'pink .2) (move-disk 320 170 90 'red .2) (clear-solid-disk(make-posn 320 75)55'yellow) (move-disk 320 170 150 'orange .2) (sleep-for-a-while .3) (draw-solid-rect(make-posn 0 0)700 600'black) (draw-solid-disk(make-posn 50 70)10'yellow) (draw-solid-disk(make-posn 85 155)10'yellow) (draw-stars 0 0 0)