;; 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-intermediate-lambda-reader.ss" "lang")((modname EmmaMarkTara) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "hangman.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "hangman.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; The code from Elena ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; get-choice: string, list of strings -> integer ;; the function displays a simple menu form with the given message ;; and a drop-down menu with the list of choices. The menu ;; initially displays "Make a choice". Once a different item is chosen, ;; that item is returned. ;; When a "Close" button is pressed, the form disappears. (define (get-choice message list-of-choices) (local ( (define the-choices (make-choice (cons "Make a choice" list-of-choices))) (define w (create-window (list (list (make-message message)) (list the-choices) (list (make-button "Close" (lambda (e) (hide-window w))))))) (define (process-result n) (cond [(> n 200) (hide-window w)] ;; timeout after 200 sec [(= (choice-index the-choices) 0) (and (sleep-for-a-while 1) (process-result (+ n 1)))] [else true]) ) ) (cond [(process-result 0) (list-ref list-of-choices (- (choice-index the-choices) 1))]))) ;; get-answer: string number -> string ;; The function displays a simple text input with a question ;; and returns the answer typed in by the user ;; The second parameter (delay) is the number of seconds(empty ;; the function waits after the typing of the first character ;; before it returns the answer. If the user takes longer ;; than that, a partial answer may be returned ;; 5 sec delay is reasonable for a one-word answer8 (define (get-answer question delay) (local ((define the-answer (make-text question)) (define w (create-window (list (list the-answer) (list (make-button "Close" (lambda (e) (hide-window w))))))) (define (process-result n) (cond [(> n 200) (hide-window w)] ;; timeout after 200 sec [(string=? (text-contents the-answer) "") (and (sleep-for-a-while 1) (process-result (+ n 1)))] [else true] ;; the user starts typing ))) (cond [(process-result 0) (cond [(sleep-for-a-while delay) (text-contents the-answer)]) ]) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Our code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Manipulating Collections ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Here is the code for building a collection of titles, treasures, and powers. ;; add-to-collection adds a certain title, treasure, and power to a collection-structure ;; unless given false, in which case, it adds nothing of that type to the collection-structure. ;; Data Definitions and data analysis: (define-struct collection (title treasure power)) ;; Collection is a structure in which title, treasure, and power are lists. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Contract: add-to-collection : string string string collection-structure -> collection-structure ;; Purpose: to add a title, a treasure, and/or a power to the appropriate list of a collection structure ;; Example: (add-to-collection "Sir" "Bone" false (make-collection empty (list "Map") empty)) should return ;; (make-collection (list "Sir") (list "Bone" "Map") empty) ;; Definitions: (define (add-to-collection a-title a-treasure a-power a-collection) (make-collection (cond [(boolean? a-title) (collection-title a-collection)] [else (cons a-title (collection-title a-collection))] ) (cond [(boolean? a-treasure) (collection-treasure a-collection)] [else (cons a-treasure (collection-treasure a-collection))] ) (cond [(boolean? a-power) (collection-power a-collection)] [else (cons a-power (collection-power a-collection))] ) ) ) ;; Tests: ;(add-to-collection "Sir" "Bone" false (make-collection empty (list "Map") empty)) ;; Expected Value: ;(make-collection (list "Sir") (list "Bone" "Map") empty) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Contract: check-items : string collection-structure -> boolean ;; Purpose: to check if the item is in the collection and return true if it is ;; and false if it is not ;; Example: (check-items "Bone" (make-collection (list "Sir") (list "Bone" "Map") empty)) ;; should return true (define (check-items an-item a-collection) (or (cond [(empty? (collection-treasure a-collection)) false] [(string=? an-item (first (collection-treasure a-collection))) true] [else (check-items an-item (make-collection (collection-title a-collection) (rest (collection-treasure a-collection)) (collection-power a-collection)))]) (cond [(empty? (collection-power a-collection)) false] [(string=? an-item (first (collection-power a-collection))) true] [else (check-items an-item (make-collection (collection-title a-collection) (collection-treasure a-collection) (rest (collection-power a-collection))))]))) ;; Tests: ;(check-items "Bone" (make-collection (list "Sir") (list "Bone" "Map") empty)) ;; Expected Value: ;true ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Contract: remove-title string collection-structure -> collection-structure ;; Purpose: to remove all instances of a string in the list of titles in a collection structure (define (remove-title a-title a-collection) (cond [(empty? (collection-title a-collection)) (make-collection empty (collection-treasure a-collection) (collection-power a-collection))] [(string=? a-title (first (collection-title a-collection))) (remove-title a-title (make-collection (rest (collection-title a-collection)) (collection-treasure a-collection) (collection-power a-collection)))] [else (add-to-collection (first (collection-title a-collection)) false false (remove-title a-title (make-collection (rest (collection-title a-collection)) (collection-treasure a-collection) (collection-power a-collection))))] ) ) ;; tests: ;(remove-title "Master Cartographer" (make-collection (list "Mesiah" "Master Cartographer") empty empty)) ;; Expected Value ;(make-collection (list "Mesiah") empty empty) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Contract: remove-treasure string collection-structure -> collection-structure ;; Purpose: to remove all instances of a string in the list of treasures in a collection structure (define (remove-treasure a-treasure a-collection) (cond [(empty? (collection-treasure a-collection)) (make-collection (collection-title a-collection) empty (collection-power a-collection))] [(string=? a-treasure (first (collection-treasure a-collection))) (remove-treasure a-treasure (make-collection (collection-title a-collection) (rest (collection-treasure a-collection)) (collection-power a-collection)))] [else (add-to-collection false (first (collection-treasure a-collection)) false (remove-treasure a-treasure (make-collection (collection-title a-collection) (rest (collection-treasure a-collection)) (collection-power a-collection))))] ) ) ;; tests: ;(remove-treasure "Bone" (make-collection empty (list "Hat" "Bone") empty)) ;; Expected Value ;(make-collection empty (list "Hat") empty) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Contract: remove-power string collection-structure -> collection-structure ;; Purpose: to remove all instances of a string in the list of power in a collection structure (define (remove-power a-power a-collection) (cond [(empty? (collection-power a-collection)) (make-collection (collection-title a-collection) (collection-treasure a-collection) empty)] [(string=? a-power (first (collection-power a-collection))) (remove-power a-power (make-collection (collection-title a-collection) (collection-treasure a-collection) (rest (collection-power a-collection))))] [else (add-to-collection false false (first (collection-power a-collection)) (remove-power a-power (make-collection (collection-title a-collection) (collection-treasure a-collection) (rest (collection-power a-collection)))))] ) ) ;; tests: ;(remove-power "Juggling" (make-collection (list "Master Cartographer") empty (list "Jumping" "Juggling"))) ;; Expected Value ;(make-collection (list "Master Cartographer") empty (list "Jumping")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Drawing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;a circle is a structure (define-struct circle (center radius color)) ;;where center is a posn structure, radius is a number ;;and color is a symbol ;;(make-circle center radius color) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;a circ-outline is a structure (define-struct circ-outline (center radius color)) ;;where center is a posn structure and radius is a number ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;a rectangle is a structure: (make-rectangle nw width height color) (define-struct rectangle (nw width height color)) ;;where nw is a posn strucutre and width and height are both numbers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;a line is a structure: (make-line begin end color) (define-struct line (begin end color)) ;;where begin and end are posn structures and color is a symbol ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;a type is a structure: (make-type posn "string") (define-struct type (posn string)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;CHLOE is a list-of-circles representing a dog (define CHLOE (list (make-circle (make-posn 125 375) 75 'brown) (make-circ-outline (make-posn 125 375) 75 'black) (make-circle (make-posn 265 395) 15 'black) (make-circle (make-posn 155 395) 15 'black) (make-circle (make-posn 210 375) 50 'brown) (make-circ-outline (make-posn 210 375) 50 'black) (make-circle (make-posn 195 390) 13 'white) (make-circle (make-posn 195 397) 7 'black) (make-circle (make-posn 225 390) 13 'white) (make-circle (make-posn 225 397) 7 'black) (make-circle (make-posn 50 425) 26 'brown) (make-circ-outline (make-posn 50 425) 26 'black) (make-circle (make-posn 100 425) 26 'brown) (make-circ-outline (make-posn 100 425) 26 'black) (make-circle (make-posn 150 425) 26 'brown) (make-circ-outline (make-posn 150 425) 26 'black) (make-circle (make-posn 270 425) 26 'brown) (make-circ-outline (make-posn 270 425) 26 'black) (make-circle (make-posn 185 425) 28 'brown) (make-circ-outline (make-posn 185 425) 28 'black) (make-circle (make-posn 235 425) 28 'brown) (make-circ-outline (make-posn 235 425) 28 'black) (make-circle (make-posn 210 410) 10 'black))) (define chloe-cape (list (make-circle (make-posn 125 375) 75 'brown) (make-circ-outline (make-posn 125 375) 75 'black) (make-circle (make-posn 265 395) 15 'black) (make-circle (make-posn 155 395) 15 'black) (make-circle (make-posn 210 375) 50 'brown) (make-circ-outline (make-posn 210 375) 50 'black) (make-circle (make-posn 195 390) 13 'white) (make-circle (make-posn 195 397) 7 'black) (make-circle (make-posn 225 390) 13 'white) (make-circle (make-posn 225 397) 7 'black) (make-circle (make-posn 50 425) 26 'brown) (make-circ-outline (make-posn 50 425) 26 'black) (make-circle (make-posn 100 425) 26 'brown) (make-circ-outline (make-posn 100 425) 26 'black) (make-circle (make-posn 150 425) 26 'brown) (make-circ-outline (make-posn 150 425) 26 'black) (make-circle (make-posn 270 425) 26 'brown) (make-circ-outline (make-posn 270 425) 26 'black) (make-circle (make-posn 185 425) 28 'brown) (make-circ-outline (make-posn 185 425) 28 'black) (make-circle (make-posn 235 425) 28 'brown) (make-circ-outline (make-posn 235 425) 28 'black) (make-circle (make-posn 210 410) 10 'black) (make-rectangle (make-posn 50 300) 123 40 'red))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define chloe-head (list (make-circle (make-posn 265 395) 15 'black) (make-circle (make-posn 155 395) 15 'black) (make-circle (make-posn 210 375) 50 'brown) (make-circ-outline (make-posn 210 375) 50 'black) (make-circle (make-posn 195 390) 13 'white) (make-circle (make-posn 195 397) 7 'black) (make-circle (make-posn 225 390) 13 'white) (make-circle (make-posn 225 397) 7 'black) (make-circle (make-posn 185 425) 28 'brown) (make-circ-outline (make-posn 185 425) 28 'black) (make-circle (make-posn 235 425) 28 'brown) (make-circ-outline (make-posn 235 425) 28 'black) (make-circle (make-posn 210 410) 10 'black))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;map is a list of shapes representing a map (define found-map (list (make-rectangle (make-posn 450 420) 64 15 'gold) (make-circ-outline (make-posn 476 420) 6 'red) (make-circ-outline (make-posn 488 420) 6 'red) (make-line (make-posn 482 420) (make-posn 474 435) 'red) (make-line (make-posn 482 420) (make-posn 490 435) 'red) (make-line (make-posn 482 420) (make-posn 482 435) 'red))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;open-map is a list of shapes representing the map if chloe reads it (define open-map (list (make-rectangle (make-posn 450 350) 64 85 'gold) (make-type (make-posn 453 359) "o") (make-line (make-posn 455 355) (make-posn 480 355) 'black) (make-line (make-posn 480 355) (make-posn 480 366) 'black) (make-line (make-posn 480 366) (make-posn 508 380) 'black) (make-line (make-posn 508 380) (make-posn 508 388) 'black) (make-line (make-posn 508 388) (make-posn 478 388) 'black) (make-line (make-posn 478 388) (make-posn 478 395) 'black) (make-line (make-posn 478 395) (make-posn 489 395) 'black) (make-line (make-posn 489 395) (make-posn 489 410) 'black) (make-line (make-posn 489 410) (make-posn 460 410) 'black) (make-line (make-posn 460 410) (make-posn 460 420) 'black) (make-line (make-posn 460 420) (make-posn 500 420) 'black) (make-type (make-posn 500 424) "x"))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define grass (list (make-rectangle (make-posn 0 435) 900 65 'green))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define orange-road (list (make-rectangle (make-posn 0 435) 900 54 'orange))) ;;making the forest (define tree-trunks (list (make-rectangle (make-posn 180 75) 30 360 'brown) (make-rectangle (make-posn 50 100) 100 335 'brown) (make-rectangle (make-posn 600 100) 80 335 'brown))) (define tree-trunks-fore (list (make-rectangle (make-posn 300 185) 75 355 'brown))) (define tree-life-fore (list (make-circle (make-posn 337 175) 60 'green))) (define tree-life (list (make-circle (make-posn 195 60) 25 'green) (make-circle (make-posn 100 80) 100 'green) (make-circle (make-posn 640 80) 70 'green))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;cartographer-hat is a list of shapes representing a hat ;;this hat symbolizes a power Chloe can acquire (define cartographer-hat (list (make-rectangle (make-posn 135 325) 150 40 'black) (make-circle (make-posn 210 323) 40 'black))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;wand is a list of shapes representing a wand (define wand (list (make-rectangle (make-posn 276 360) 8 70 'black) (make-circle (make-posn 280 430) 7 'black) (make-circle (make-posn 280 360) 4 'black))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;sword is a list of shapes representing a sword (define sword (list (make-rectangle (make-posn 120 415) 50 15 'gray) (make-rectangle (make-posn 137 430) 16 15 'gray) (make-rectangle (make-posn 137 350) 16 65 'gray) (make-rectangle (make-posn 139 348) 12 63 'gray) (make-rectangle (make-posn 141 346) 8 61 'gray) (make-rectangle (make-posn 143 344) 4 59 'gray) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Bone is a list of shapes representing a bone (define bone (list (make-circle (make-posn 150 480) 9 'tan) (make-rectangle (make-posn 150 475) 50 10 'tan) (make-circle (make-posn 200 480) 9 'tan) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;juggling-balls is a list of shapes that represent juggling balls. (define juggling-balls (list (make-circle (make-posn 125 250) 9 'red) (make-circle (make-posn 170 200) 9 'blue) (make-circle (make-posn 215 240) 9 'green) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define sword2 (list (make-rectangle (make-posn 415 120) 15 50 'gray) (make-rectangle (make-posn 400 137) 15 16 'gray) (make-rectangle (make-posn 415 137) 65 16 'gray) (make-rectangle (make-posn 417 139) 65 12 'gray) (make-rectangle (make-posn 419 141) 65 8 'gray) (make-rectangle (make-posn 421 143) 65 4 'gray) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;cape is a list of shapes that represent a cape. (define cape (list (make-rectangle (make-posn 50 300) 123 40 'red))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define amulet (list (make-circle (make-posn 160 400) 5 'gold) (make-circle (make-posn 162 410) 5 'gold) (make-circle (make-posn 260 400) 5 'gold) (make-circle (make-posn 258 410) 5 'gold) (make-circle (make-posn 167 420) 5 'gold) (make-circle (make-posn 253 420) 5 'gold) (make-circle (make-posn 170 430) 5 'gold) (make-circle (make-posn 250 430) 5 'gold) (make-circle (make-posn 174 440) 5 'gold) (make-circle (make-posn 246 440) 5 'gold) (make-circle (make-posn 180 450) 5 'gold) (make-circle (make-posn 240 450) 5 'gold) (make-circle (make-posn 186 458) 5 'gold) (make-circle (make-posn 234 458) 5 'gold) (make-circle (make-posn 192 466) 5 'gold) (make-circle (make-posn 228 466) 5 'gold) (make-circle (make-posn 202 466) 5 'gold) (make-circle (make-posn 218 466) 5 'gold) (make-circle (make-posn 210 470) 10 'gold) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;wizard is a list of shapes representing a wizard (define wizard (list (make-circle (make-posn 400 130) 50 'yellow) (make-line (make-posn 320 110) (make-posn 480 110) 'blue) (make-rectangle (make-posn 350 90) 100 20 'blue) (make-rectangle (make-posn 360 70) 80 20 'blue) (make-rectangle (make-posn 370 50) 60 20 'blue) (make-rectangle (make-posn 380 30) 40 20 'blue) (make-rectangle (make-posn 390 10) 20 20 'blue) (make-circle (make-posn 400 225) 50 'blue) (make-rectangle (make-posn 350 225) 100 300 'blue) (make-circle (make-posn 400 350) 15 'yellow) (make-line (make-posn 385 350) (make-posn 385 225) 'black) (make-line (make-posn 415 350) (make-posn 415 225) 'black) (make-rectangle (make-posn 275 280) 75 30 'blue) (make-rectangle (make-posn 265 130) 10 400 'brown) (make-rectangle (make-posn 375 126) 3 8 'black) (make-rectangle (make-posn 357 155) 15 4 'black) (make-rectangle (make-posn 355 146) 18 6 'gray) (make-rectangle (make-posn 373 146) 6 68 'gray) (make-rectangle (make-posn 356 162) 16 75 'gray) (make-rectangle (make-posn 349 146) 6 68 'gray) (make-rectangle (make-posn 420 111) 26 150 'gray) (make-rectangle (make-posn 410 111) 42 125 'gray) (make-rectangle (make-posn 400 111) 42 100 'gray))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;evil-wizard is a list of shapes representing a evil wizard (define evil-wizard (list (make-circle (make-posn 400 130) 50 'green) (make-line (make-posn 320 110) (make-posn 480 110) 'red) (make-rectangle (make-posn 350 90) 100 20 'black) (make-rectangle (make-posn 360 70) 80 20 'red) (make-rectangle (make-posn 370 50) 60 20 'black) (make-rectangle (make-posn 380 30) 40 20 'red) (make-rectangle (make-posn 390 10) 20 20 'black) (make-circle (make-posn 400 225) 50 'red) (make-rectangle (make-posn 350 225) 100 300 'red) (make-circle (make-posn 400 350) 15 'green) (make-line (make-posn 385 350) (make-posn 385 225) 'black) (make-line (make-posn 415 350) (make-posn 415 225) 'black) (make-rectangle (make-posn 275 280) 75 30 'red) (make-rectangle (make-posn 265 130) 10 400 'brown) (make-rectangle (make-posn 375 126) 8 3 'black) (make-rectangle (make-posn 357 155) 15 4 'black) (make-rectangle (make-posn 355 146) 18 6 'black) (make-rectangle (make-posn 373 146) 6 40 'black) (make-rectangle (make-posn 356 162) 16 30 'black) (make-rectangle (make-posn 349 146) 6 40 'black) (make-rectangle (make-posn 420 111) 26 150 'black) (make-rectangle (make-posn 410 111) 42 125 'black) (make-rectangle (make-posn 400 111) 42 100 'black))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define chloe-robe (list (make-circle (make-posn 400 225) 50 'red) (make-rectangle (make-posn 350 225) 100 300 'red) (make-circle (make-posn 450 350) 15 'brown) (make-circle (make-posn 450 225) 15 'red) (make-rectangle (make-posn 435 225) 30 125 'red) (make-line (make-posn 435 350) (make-posn 435 225) 'black) (make-line (make-posn 465 350) (make-posn 465 225) 'black) (make-rectangle (make-posn 275 280) 75 30 'red) (make-rectangle (make-posn 265 130) 10 400 'brown) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define castle (list (make-rectangle (make-posn 450 100) 100 335 'gray) (make-rectangle (make-posn 550 25) 250 410 'gray) (make-rectangle (make-posn 600 200) 150 235 'brown) (make-rectangle (make-posn 800 100) 100 335 'gray))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Picture Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;draw-picture : list-of-shapes -> boolean ;;to draw each item on a consumed list of shapes (define (draw-picture alos) (cond [(empty? alos) true] [(boolean? alos) alos] [else (cond [(circ-outline? (first alos)) (and (draw-circle (circ-outline-center (first alos)) (circ-outline-radius (first alos)) (circ-outline-color (first alos))) (draw-picture (rest alos)))] [(circle? (first alos)) (and (draw-solid-disk (circle-center (first alos)) (circle-radius (first alos)) (circle-color (first alos))) (draw-picture (rest alos)))] [(line? (first alos)) (and (draw-solid-line (line-begin (first alos)) (line-end (first alos)) (line-color (first alos))) (draw-picture (rest alos)))] [(rectangle? (first alos)) (and (draw-solid-rect (rectangle-nw (first alos)) (rectangle-width (first alos)) (rectangle-height (first alos)) (rectangle-color (first alos))) (draw-picture (rest alos)))] [(type? (first alos)) (and (draw-solid-string (type-posn (first alos)) (type-string (first alos))) (draw-picture (rest alos)))])])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;translate-picture : list-of-shapes number number -> list-of-shapes ;;to produce the list-of-shapes translated, x-delta moves the picture horizontally and y-delta moves the picture vertically (define (translate alos x-delta y-delta) (cond [(empty? alos) empty] [(boolean? alos) alos] [else (cond [(circ-outline? (first alos)) (cons (make-circ-outline (make-posn (+ (posn-x (circ-outline-center (first alos))) x-delta) (- (posn-y (circ-outline-center (first alos))) y-delta)) (circ-outline-radius (first alos)) (circ-outline-color (first alos))) (translate (rest alos) x-delta y-delta))] [(circle? (first alos)) (cons (make-circle (make-posn (+ (posn-x (circle-center (first alos))) x-delta) (- (posn-y (circle-center (first alos))) y-delta)) (circle-radius (first alos)) (circle-color (first alos))) (translate (rest alos) x-delta y-delta))] [(line? (first alos)) (cons (make-line (make-posn (+ (posn-x (line-begin (first alos))) x-delta) (- (posn-y (line-begin (first alos))) y-delta)) (make-posn (+ (posn-x (line-end (first alos))) x-delta) (- (posn-y (line-end (first alos))) y-delta)) (line-color (first alos))) (translate (rest alos) x-delta y-delta))] [(rectangle? (first alos)) (cons (make-rectangle (make-posn (+ (posn-x (rectangle-nw (first alos))) x-delta) (- (posn-y (rectangle-nw (first alos))) y-delta)) (rectangle-width (first alos)) (rectangle-height (first alos)) (rectangle-color (first alos))) (translate (rest alos) x-delta y-delta))] [(type? (first alos)) (cons (make-type (make-posn (+ (posn-x (type-posn (first alos))) x-delta) (- (posn-y (type-posn (first alos))) y-delta)) (type-string (first alos))) (translate (rest alos) x-delta y-delta))])])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;clear-picture : alos -> boolean ;;to erase each item on a consumed list of shapes from the canvas (define (clear-picture alos) (cond [(empty? alos) true] [(boolean? alos) alos] [else (cond [(circ-outline? (first alos)) (and (clear-circle (circ-outline-center (first alos)) (circ-outline-radius (first alos)) (circ-outline-color (first alos))) (clear-picture (rest alos)))] [(circle? (first alos)) (and (clear-solid-disk (circle-center (first alos)) (circle-radius (first alos)) (circle-color (first alos))) (clear-picture (rest alos)))] [(line? (first alos)) (and (clear-solid-line (line-begin (first alos)) (line-end (first alos)) (line-color (first alos))) (clear-picture (rest alos)))] [(rectangle? (first alos)) (and (clear-solid-rect (rectangle-nw (first alos)) (rectangle-width (first alos)) (rectangle-height (first alos)) (rectangle-color (first alos))) (clear-picture (rest alos)))] [(type? (first alos)) (and (clear-solid-string (type-posn (first alos)) (type-string (first alos))) (clear-picture (rest alos)))])])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;draw-and-clear-picture : list-of-shapes -> boolean ;;to draw a picture, sleep for a while, and clear the picture (define (draw-and-clear-picture alos) (cond [(empty? alos) true] [else (and (draw-picture alos) (sleep-for-a-while 2) (clear-picture alos))])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;move-picture : list-of-shapes delta -> boolean ;;to draw a picture, sleep for a while, clear the picture, ;;and produce a translated version, moved by delta pixels (define (move-picture alos x-delta y-delta) (cond [(empty? alos) true] [else (and (draw-picture (translate alos x-delta y-delta)) (sleep-for-a-while .5) (clear-picture (translate alos x-delta y-delta)))])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; The Quest Begins ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Stage 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (start 900 500) ;;The title (draw-picture grass) (draw-solid-string (make-posn 400 250) "THE WIZARD OF ODD") (sleep-for-a-while 1) (draw-solid-string (make-posn 400 270) "Starring Chloe - The Traveling Dog") (define collection0 (make-collection empty empty empty)) ;; drawing the dog (draw-picture CHLOE) (draw-picture grass) (sleep-for-a-while 1) ;;clearing the title (clear-solid-string (make-posn 400 250) "THE WIZARD OF ODD") (sleep-for-a-while 1) (clear-solid-string (make-posn 400 270) "Starring Chloe - The Traveling Dog") (clear-picture CHLOE) (draw-picture grass) (move-picture CHLOE 100 0) (draw-picture grass) (move-picture CHLOE 200 0) (draw-picture grass) (move-picture CHLOE 300 0) (draw-picture grass) (move-picture CHLOE 400 0) (draw-picture grass) (move-picture CHLOE 500 0) (draw-picture grass) (move-picture CHLOE 600 0) (draw-picture grass) (move-picture CHLOE 700 0) (draw-picture grass) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Stage 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (draw-picture grass) (draw-picture found-map) (move-picture CHLOE -100 0) (draw-picture grass) (draw-picture CHLOE) (draw-picture grass) (draw-solid-string (make-posn 500 100) "You find a Map!") (draw-solid-string (make-posn 500 120) "No, not a nap, a MAP!") (define choice1 (get-choice "What would you like to do with it?" (list "Eat It!" "Read It"))) (define collection1 (cond [(string=? choice1 "Eat It!") (add-to-collection "Master Cartographer" "Hat" false collection0)] [(string=? choice1 "Read It") (add-to-collection "Tree Doctor" "Wand" false collection0)] ) ) (cond [(string=? choice1 "Eat It!") (and (clear-picture CHLOE) (move-picture CHLOE 100 0) (draw-picture grass) (move-picture CHLOE 150 0) (draw-picture grass) (draw-picture (translate CHLOE 150 0)) (draw-picture grass) (clear-picture found-map) (draw-solid-string (make-posn 450 420) "Chomp!") (draw-solid-string (make-posn 500 160) "You have gained the title 'Master Cartographer'!") (sleep-for-a-while .5) (draw-solid-string (make-posn 500 180) "You are now really Good with maps and stuff.") (sleep-for-a-while .5) (draw-solid-string (make-posn 500 200) "AND you get a sweet hat!") (draw-picture (translate cartographer-hat 150 0)) (sleep-for-a-while 4) (clear-solid-string (make-posn 500 160) "You have gained the title 'Master Cartographer'!") (clear-solid-string (make-posn 500 180) "You are now really Good with maps and stuff.") (clear-solid-string (make-posn 500 200) "AND you get a sweet hat!") (clear-solid-string (make-posn 450 420) "Chomp!") (clear-picture (translate CHLOE 150 0)) (clear-picture (translate cartographer-hat 150 0)) (draw-picture CHLOE) (draw-picture grass) (draw-picture cartographer-hat) )] [(string=? choice1 "Read It") (and (clear-picture CHLOE) (draw-picture grass) (move-picture CHLOE 100 0) (draw-picture grass) (move-picture CHLOE 150 0) (draw-picture grass) (draw-picture (translate CHLOE 150 0)) (draw-picture grass) (clear-picture found-map) (draw-picture open-map) (sleep-for-a-while 3) (clear-picture (translate CHLOE 150 0)) (move-picture CHLOE 250 0) (draw-picture grass) (draw-solid-rect (make-posn 0 0) 900 500 'black) (sleep-for-a-while 1) (clear-solid-rect (make-posn 0 0) 900 500 'black) (move-picture CHLOE 350 0) (draw-picture grass) (draw-solid-rect (make-posn 0 0) 900 500 'black) (sleep-for-a-while 1) (clear-solid-rect (make-posn 0 0) 900 500 'black) (move-picture CHLOE 450 0) (draw-picture grass) (draw-solid-rect (make-posn 0 0) 900 500 'black) (sleep-for-a-while 1) (clear-solid-rect (make-posn 0 0) 900 500 'black) (draw-solid-rect (make-posn 0 0) 900 500 'gray) (draw-picture grass) (draw-picture tree-trunks) (draw-picture tree-trunks-fore) (move-picture CHLOE -100 0) (draw-solid-rect (make-posn 0 0) 900 500 'gray) (draw-picture grass) (draw-picture tree-trunks) (draw-picture CHLOE) (draw-picture grass) (draw-picture tree-trunks-fore) (draw-solid-string (make-posn 500 160) "You go to the Enchanted forest and...") (sleep-for-a-while 2) (draw-solid-rect (make-posn 0 0) 900 500 'black) (sleep-for-a-while .3) (draw-solid-rect (make-posn 0 0) 900 500 'white) (sleep-for-a-while .3) (draw-solid-rect (make-posn 0 0) 900 500 'gray) (draw-picture tree-trunks) (draw-picture tree-life) (draw-picture CHLOE) (draw-picture grass) (draw-picture tree-trunks-fore) (draw-picture tree-life-fore) (draw-solid-string (make-posn 500 170) "save many sick trees.") (draw-solid-string (make-posn 500 200) "You gain the title 'Tree Doctor' and a new treasure for") (draw-solid-string (make-posn 500 220) "your services - A wand.") (draw-picture wand) (sleep-for-a-while 5) (clear-solid-string (make-posn 500 160) "You go to the Enchanted forest and...") (clear-solid-string (make-posn 500 170) "save many sick trees.") (clear-solid-string (make-posn 500 200) "You gain the title 'Tree Doctor' and a new treasure for") (clear-solid-string (make-posn 500 220) "your services - A wand.") (clear-solid-rect (make-posn 0 0) 900 500 'gray) (clear-picture tree-trunks) (clear-picture tree-life) (clear-picture CHLOE) (clear-picture grass) (clear-picture tree-trunks-fore) (clear-picture tree-life-fore) (draw-picture CHLOE) (draw-picture wand) )] ) collection1 (clear-solid-string (make-posn 500 100) "You find a Map!") (clear-solid-string (make-posn 500 120) "No, not a nap, a MAP!") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Stage 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (draw-picture castle) (draw-picture grass) (draw-solid-string (make-posn 500 70) "You continue on your travels and...") (sleep-for-a-while 1) (draw-solid-string (make-posn 500 100) "arrive at a grand castle!") (draw-solid-string (make-posn 500 120) "And find a tasty treasure - a bone.") (define collection2 (add-to-collection false "Bone" false collection1)) collection2 (define choice2 (random 2)) (define collection3 (cond [(= choice2 0) (add-to-collection false "Sword" false collection2)] [(= choice2 1) (add-to-collection false false "Juggling" collection2)] ) ) (sleep-for-a-while 3) (draw-picture bone) (cond [(= choice2 0) (and (draw-solid-string (make-posn 500 140) "Then, you chill with some knights") (draw-solid-string (make-posn 500 160) "And earn a sword.") (sleep-for-a-while 5) (draw-picture sword) (clear-solid-string (make-posn 500 140) "Then, you chill with some knights") (clear-solid-string (make-posn 500 160) "And earn a sword.") ) ] [(= choice2 1) (and (draw-solid-string (make-posn 500 140) "Then, you chill with the king") (draw-solid-string (make-posn 500 160) "And he makes you his jestor,") (draw-solid-string (make-posn 500 180) "Giving you the 'Juggling' power.") (sleep-for-a-while 3) (draw-picture juggling-balls) (clear-solid-string (make-posn 500 140) "Then, you chill with the king") (clear-solid-string (make-posn 500 160) "And he makes you his jestor,") (clear-solid-string (make-posn 500 180) "Giving you the 'Juggling' power.") ) ] ) collection3 (clear-solid-string (make-posn 500 70) "You continue on your travels and...") (clear-solid-string (make-posn 500 100) "arrive at a grand castle!") (clear-solid-string (make-posn 500 120) "And find a tasty treasure - a bone.") (clear-picture castle) (clear-picture grass) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Stage 3: the orange-brick road ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (draw-picture orange-road) (draw-picture bone) (draw-solid-string (make-posn 500 100) "You arrive at the orange-brick road") (draw-solid-string (make-posn 500 120) "And are attacked by flying monkeys!") (define choice3 (get-choice "What would you do?" (list "Eat Them!" "Play hide-and-go-seek!"))) (sleep-for-a-while 2) (clear-solid-string (make-posn 500 100) "You arrive at the orange-brick road") (clear-solid-string (make-posn 500 120) "And are attacked by flying monkeys!") (cond [(string=? choice3 "Play hide-and-go-seek!") (and (draw-solid-string (make-posn 500 100) "From playing with the monkeys you learn their ways and...") (draw-solid-string (make-posn 500 200) "they give you a cape which allows you to fly!"))] [(string=? choice3 "Eat Them!") (draw-solid-string (make-posn 300 100) "You lose your bone because the monkeys steal it while trying to fight back.")]) (define collection4 (cond [(string=? choice3 "Eat Them!") (remove-treasure "Bone" collection3)] [(string=? choice3 "Play hide-and-go-seek!") (add-to-collection false "Cape" "Flying" collection3)] ) ) (cond [(string=? choice3 "Eat Them!") (clear-picture bone)] [(string=? choice3 "Play hide-and-go-seek!") (and (draw-picture cape) (sleep-for-a-while 1) (clear-solid-string (make-posn 500 100) "From playing with the monkeys you learn their ways and...") (clear-solid-string (make-posn 500 200) "they give you a cape which allows you to fly!") (clear-picture CHLOE) (clear-picture cape) (draw-picture orange-road) (clear-picture juggling-balls) (clear-picture wand) (clear-picture cartographer-hat) (move-picture (append chloe-cape (cond [(check-items "Hat" collection4) cartographer-hat] [else empty])) 100 100) (move-picture (append chloe-cape (cond [(check-items "Hat" collection4) cartographer-hat] [else empty])) 200 200) (move-picture (append chloe-cape (cond [(check-items "Hat" collection4) cartographer-hat] [else empty])) 300 300) (move-picture (append chloe-cape (cond [(check-items "Hat" collection4) cartographer-hat] [else empty])) 400 400)) ] ) (sleep-for-a-while 2) (clear-solid-string (make-posn 300 100) "You lose your bone because the monkeys steal it while trying to fight back.") collection4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Stage 4: the wizard ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (draw-solid-string (make-posn 500 100) "You fly over the castle and through the woods to...") (sleep-for-a-while 1) (draw-solid-string (make-posn 500 120) "Grandfather's house we go!") (sleep-for-a-while 1) (draw-picture CHLOE) (draw-picture (translate wizard 32 0)) (draw-solid-string (make-posn 500 140) "But your flight stops short when you...") (sleep-for-a-while 1) (draw-solid-string (make-posn 500 160) "Encounter a wizard!!") (sleep-for-a-while 2) (clear-solid-string (make-posn 500 100) "You fly over the castle and through the woods to...") (clear-solid-string (make-posn 500 120) "Grandfather's house we go!") (clear-solid-string (make-posn 500 140) "But your flight stops short when you...") (clear-solid-string (make-posn 500 160) "Encounter a wizard!!") (draw-solid-string (make-posn 500 120) "Grandpa?!") (draw-solid-string (make-posn 500 140) "Yes Chloe, It is time we meet...") (draw-solid-string (make-posn 500 160) "Do you have anything to barter?") (define choice4 (get-choice "What do you want to trade?" (list "Hat" "Wand" "Bone" "Sword" "Juggling" "Cape"))) {cond [(boolean=? (check-items choice4 collection4) false) (and (draw-solid-string (make-posn 500 200) "You don't have that, Chloe!") (draw-solid-string (make-posn 500 220) "You are no grandchild of mine!") (sleep-for-a-while 5) (clear-solid-string (make-posn 500 200) "You don't have that, Chloe!") (clear-solid-string (make-posn 500 220) "You are no grandchild of mine!") ) ] [else (and (draw-solid-string (make-posn 500 200) "You are very generous, Chloe!") (draw-solid-string (make-posn 500 220) "But I do not want to take this from you.") (draw-solid-string (make-posn 500 240) "Here, have this MAGICAL HEIRLOOM!!") (draw-solid-string (make-posn 500 260) "It is a protective amulet.") (sleep-for-a-while 5) (clear-solid-string (make-posn 500 200) "You are very generous, Chloe!") (clear-solid-string (make-posn 500 220) "But I do not want to take this from you.") (clear-solid-string (make-posn 500 240) "Here, have this MAGICAL HEIRLOOM!!") (clear-solid-string (make-posn 500 260) "It is a protective amulet.") (draw-picture amulet) ) ] } (define collection5 (cond [(boolean=? (check-items choice4 collection4) false) (add-to-collection false false "Shame" collection4)] [else (add-to-collection false "Amulet" "Pride" collection4)] ) ) (clear-solid-string (make-posn 500 100) "But your flight stops short when you...") (clear-solid-string (make-posn 500 200) "Encounter a wizard!!") (clear-solid-string (make-posn 500 120) "Grandpa?!") (clear-solid-string (make-posn 500 140) "Yes Chloe, It is time we meet...") (clear-solid-string (make-posn 500 160) "Do you have anything to barter?") (sleep-for-a-while 2) (clear-picture (translate wizard 32 0)) (draw-picture grass) (draw-picture amulet) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Stage 5: becoming a wizard ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (cond [(check-items "Amulet" collection5) (and (draw-solid-string (make-posn 500 100) "The amulet weighs heavy around your neck...") (sleep-for-a-while .5) (draw-solid-string (make-posn 500 120) "This is no ordinary family heirloom...") (sleep-for-a-while .5) (draw-solid-string (make-posn 500 140) "It is causing some strange tingling sensations...") (sleep-for-a-while .5) (draw-solid-string (make-posn 500 160) "What's going on?!?") (sleep-for-a-while .5) (draw-solid-string (make-posn 500 180) "Your destiny is being fulfilled") (sleep-for-a-while .5) (draw-solid-string (make-posn 500 200) "You are becoming the wizard that runs in your veins...") )] [else (and (draw-solid-string (make-posn 500 100) "You follow the family veins and become a wizard, however....") (draw-solid-string (make-posn 500 120) "You recieve the power of shame.") (draw-solid-string (make-posn 500 140) "You must continue the game without the protective amulet") ) ] ) (clear-picture CHLOE) (clear-picture juggling-balls) (clear-picture cartographer-hat) (clear-picture sword) (clear-picture wand) (clear-picture cape) (draw-picture (translate chloe-robe -190 0)) (draw-picture (translate chloe-head 0 250)) (draw-picture grass) (cond [(check-items "Amulet" collection5) (draw-picture (translate amulet 0 200))] [else true] ) (cond [(check-items "Hat" collection5) (draw-picture (translate cartographer-hat 0 240))] [else true] ) (cond [(check-items "Sword" collection5) (draw-picture (translate (translate sword2 -145 0) 0 -210))] [else true] ) (sleep-for-a-while 4) (clear-solid-string (make-posn 500 100) "The amulet weighs heavy around your neck...") (clear-solid-string (make-posn 500 120) "This is no ordinary family heirloom...") (clear-solid-string (make-posn 500 140) "It is causing some strange tingling sensations...") (clear-solid-string (make-posn 500 160) "What's going on?!?") (clear-solid-string (make-posn 500 180) "Your destiny is being fulfilled") (clear-solid-string (make-posn 500 200) "You are becoming the wizard that runs in your veins...") (clear-solid-string (make-posn 500 100) "You follow the family veins and become a wizard, however....") (clear-solid-string (make-posn 500 120) "You recieve the power of shame.") (clear-solid-string (make-posn 500 140) "You must continue the game without the protective amulet") (sleep-for-a-while 4) (draw-solid-string (make-posn 500 100) "You encounter an EVIL WIZARD!") (sleep-for-a-while 1.5) (clear-solid-string (make-posn 500 100) "You encounter an EVIL WIZARD!") (draw-picture (translate evil-wizard 300 0)) (sleep-for-a-while 1) (draw-solid-string (make-posn 350 100) "So, if it isn't CHLOE!") (sleep-for-a-while 1) (draw-solid-string (make-posn 300 140) "How Do You know my name?") (sleep-for-a-while 1) (draw-solid-string (make-posn 350 180) "It's me, Dr. Rick.") (sleep-for-a-while 1) (draw-solid-string (make-posn 350 220) "I brought you into this world,") (draw-solid-string (make-posn 350 240) "and I'll take you out of it!") (sleep-for-a-while 2) (clear-solid-string (make-posn 350 100) "So, if it isn't CHLOE!") (clear-solid-string (make-posn 300 140) "How Do You know my name?") (clear-solid-string (make-posn 350 180) "It's me, Dr. Rick.") (clear-solid-string (make-posn 350 220) "I brought you into this world,") (clear-solid-string (make-posn 350 240) "and I'll take you out of it!") (draw-solid-string (make-posn 350 100) "Dr. Rick attacks!") (cond [(check-items "Amulet" collection5) (and (draw-solid-string (make-posn 300 140) "But the protective amulet saves you.") (sleep-for-a-while 2) (clear-solid-string (make-posn 300 140) "But the protective amulet saves you.") ) ] [else (and (draw-solid-string (make-posn 300 140) "But your power of Shame protects you.") (sleep-for-a-while 2) (clear-solid-string (make-posn 300 140) "But your power of Shame protects you.") ) ] ) (clear-solid-string (make-posn 350 100) "Dr. Rick attacks!") (define choice5 (get-choice "What do you counter-attack with?" (list "Hat" "Bone" "Sword" "Juggling" "Cape"))) (cond [(check-items choice5 collection5) (and (draw-solid-string (make-posn 300 140) "Take THAT!") (sleep-for-a-while 1) (clear-solid-rect (make-posn 565 130) 10 400) (draw-solid-string (make-posn 340 160) "AHHH! You've Pulverized my staff!") (draw-picture grass) (sleep-for-a-while 2) (clear-solid-string (make-posn 340 160) "AHHH! You've Pulverized my staff!") (clear-solid-string (make-posn 300 140) "Take THAT!") ) ] [else (and (draw-solid-string (make-posn 300 140) "You reach for this item,") (draw-solid-string (make-posn 300 160) "but too late you realize") (draw-solid-string (make-posn 300 180) "that you don't have it.") (sleep-for-a-while 2) (draw-solid-string (make-posn 300 220) "Dr. Rick takes advantage") (draw-solid-string (make-posn 300 240) "and defeats you!") (sleep-for-a-while 5) (error 'Fail "You Lose") ) ] ) (draw-solid-string (make-posn 300 140) "Answer me THIS, Chloe!") (draw-solid-string (make-posn 300 180) "You have seven apples.") (draw-solid-string (make-posn 300 200) "I take four away.") (draw-solid-string (make-posn 300 220) "How many apples do I have?") (sleep-for-a-while 2) (define riddle-answer (get-answer "How many is it, Chloe?" 3)) (cond [(or (string=? riddle-answer "4") (string=? riddle-answer "four") (string=? riddle-answer "Four")) (draw-solid-string (make-posn 300 260) "Your wit has bested me!!!!")] [else (and (draw-solid-string (make-posn 300 260) "No. The answer is Four, Chloe") (sleep-for-a-while 4) (error 'Fail "You Lose") )]) "RICK IS DEAD"