;; 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 entry9) (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"))))) ;;Lab 3 ;; ;;Purpose: To define the variables of sun-radius, sun-distance, and x-coordinate for sun. (define SUN-RADIUS 50) ;(define SUN-DISTANCE 10) ;(define X-SUN (WIDTH 2)) ;;Contract: number number -> grahic window ;;Purpose: To define the size of the graphic window we will be using for cartonn. (start 600 500) ;;Contract: position number -> solid disk ;;Purpose: to make a sun in the upper left hand corner of the screen. (draw-solid-disk (make-posn 60 50) SUN-RADIUS 'yellow) ;;Contract: position number number -> rectangle ;;Purpose: to make a rectangle for the bottom of the house (draw-solid-rect (make-posn 200 200) 150 60 'black) (draw-solid-rect (make-posn 350 200) 150 60 'black) ;;Contract: position position -> solid line ;;Purpose: To make the roof of the house with solid lines (draw-solid-line (make-posn 200 200) (make-posn 350 150) 'black) (draw-solid-line (make-posn 500 200) (make-posn 350 150) 'black) ;;Contract: position number -> circle ;;Purpose: To make the head of the person (draw-circle (make-posn 151 145) 5 'black) ;;Contract: position position -> Solid line ;;Purpose: To make the body of the person (draw-solid-line (make-posn 150 150) (make-posn 150 170) 'black) ;;Contract: position position -> solid line ;;Purpose: To make the arms of the person (draw-solid-line (make-posn 150 150) (make-posn 155 160) 'black) (draw-solid-line (make-posn 150 150) (make-posn 145 160) 'black) ;;Contract: position position -> solid line ;;Purpose: To make the legs of the person (draw-solid-line (make-posn 150 170) (make-posn 155 185) 'black) (draw-solid-line (make-posn 150 170) (make-posn 145 185) 'black) ;;Contract: position number -> solid disk ;;Purpose: To make the rock with a solid gray disk (draw-solid-disk (make-posn -100 250 ) 75 'gray) (sleep-for-a-while 1) ;;Clear the whole body and rock. (clear-circle (make-posn 151 145) 5 'black) (clear-solid-line (make-posn 150 150) (make-posn 150 170) 'black) (clear-solid-line (make-posn 150 150) (make-posn 155 160) 'black) (clear-solid-line (make-posn 150 150) (make-posn 145 160) 'black) (clear-solid-line (make-posn 150 170) (make-posn 155 185) 'black) (clear-solid-line (make-posn 150 170) (make-posn 145 185) 'black) ;;Now we need to re-draw the rock and body to next position ;;Contract: position number -> circle ;;Purpose: To make the head of the person (draw-circle (make-posn 150 130) 8 'black) ;;Contract: position position -> Solid line ;;Purpose: To make the body of the person (draw-solid-line (make-posn 150 138) (make-posn 150 190) 'black) ;;Contract: position position -> solid line ;;Purpose: To make the arms of the person (draw-solid-line (make-posn 150 160) (make-posn 165 180) 'black) (draw-solid-line (make-posn 150 160) (make-posn 135 180) 'black) ;;Contract: position position -> solid line ;;Purpose: To make the legs of the person (draw-solid-line (make-posn 150 190) (make-posn 160 250) 'black) (draw-solid-line (make-posn 150 190) (make-posn 140 250) 'black) ;;Contract: position number -> solid disk ;;Purpose: To make the rock with a solid gray disk (draw-solid-disk (make-posn 0 235 ) 25 'gray) (sleep-for-a-while 1) ;;Now we need to clear the body and rock again (clear-circle (make-posn 150 130) 8 'black) (clear-solid-line (make-posn 150 150) (make-posn 150 170) 'black) (clear-solid-line (make-posn 150 160) (make-posn 165 180) 'black) (clear-solid-line (make-posn 150 160) (make-posn 135 180) 'black) (clear-solid-line (make-posn 150 190) (make-posn 160 250) 'black) (clear-solid-line (make-posn 150 190) (make-posn 140 250) 'black) (clear-solid-disk (make-posn 0 235 ) 25 'gray) ;;Now we need to re-draw the rock and body to next position. ;;Contract: position number -> circle ;;Purpose: To make the head of the person (draw-circle (make-posn 150 130) 10 'black) ;;Contract: position position -> Solid line ;;Purpose: To make the body of the person (draw-solid-line (make-posn 150 138) (make-posn 150 190) 'black) ;;Contract: position position -> solid line ;;Purpose: To make the arms of the person (draw-solid-line (make-posn 150 150) (make-posn 175 225) 'black) (draw-solid-line (make-posn 150 150) (make-posn 125 225) 'black) ;;Contract: position position -> solid line ;;Purpose: To make the legs of the person (draw-solid-line (make-posn 150 190) (make-posn 135 260) 'black) (draw-solid-line (make-posn 150 190) (make-posn 165 260) 'black) ;;Contract: position number -> solid disk ;;Purpose: To make the rock with a solid gray disk (draw-solid-disk (make-posn 20 235 ) 50 'gray) (sleep-for-a-while 1) ;;Clear the person and rock and replace with the rock. (clear-solid-disk (make-posn 20 235 ) 50 'gray) ;;Contract: position number -> solid disk ;;Purpose: To make the rock with a solid gray disk (draw-solid-disk (make-posn 75 235) 60 'gray) ;;Clear rock and person (clear-circle (make-posn 150 130) 10 'black) (clear-solid-line (make-posn 150 138) (make-posn 150 190) 'black) (clear-solid-line (make-posn 150 150) (make-posn 175 225) 'black) (clear-solid-line (make-posn 150 150) (make-posn 125 225) 'black) (clear-solid-line (make-posn 150 190) (make-posn 135 260) 'black) (clear-solid-line (make-posn 150 190) (make-posn 165 260) 'black) (clear-solid-disk (make-posn 75 235) 60 'gray) ;;Contract: position number -> solid disk ;;Purpose: To make the rock with a solid gray disk (draw-solid-disk (make-posn 130 235) 70 'gray) (sleep-for-a-while 1) ;;Clear the rock and half of the house (clear-solid-disk (make-posn 130 235) 70 'gray) (clear-solid-line (make-posn 200 200) (make-posn 350 150) 'black) (clear-solid-rect (make-posn 200 200) 150 60 'black) (draw-solid-disk (make-posn 280 235) 70 'gray) (sleep-for-a-while 1) ;;Make the rock bigger and red on outside demonstrating an explosion. (draw-solid-disk (make-posn 250 235) 100 'red) (draw-solid-disk (make-posn 250 235) 70 'gray) (sleep-for-a-while 1) ;;Make the red explosion of the rock bigger. (clear-solid-disk (make-posn 250 235) 100 'red) (clear-solid-disk (make-posn 250 235) 70 'gray) (draw-solid-disk (make-posn 300 235) 235 'red) (draw-solid-disk (make-posn 300 235) 70 'gray) (sleep-for-a-while 1) ;;Clear the rest of the house and the rock. (clear-solid-disk (make-posn 300 235) 235 'red) (clear-solid-disk (make-posn 300 235) 70 'gray) (clear-solid-line (make-posn 500 200) (make-posn 350 150) 'black) (clear-solid-rect (make-posn 350 200) 150 60 'black)