Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

Summary CPSC 110 Racket Solution PSET 5

Beoordeling
1.0
(1)
Verkocht
4
Pagina's
8
Cijfer
A+
Geüpload op
15-10-2021
Geschreven in
2021/2022

Summary CPSC 110 Racket Solution PSET 5

Instelling
Vak

Voorbeeld van de inhoud

1 ;; DO NOT PUT ANYTHING PERSONALLY IDENTIFYING BEYOND YOUR CWL IN THIS FILE.
2 ;; YOUR CWLs WILL BE SUFFICIENT TO IDENTIFY YOU AND, IF YOU HAVE ONE, YOUR
3 ;; PARTNER.
4 (require 2htdp/universe)
5 (require 2htdp/image)
6 (require spd/tags)
7
8 (@assignment pset-05);Do not edit or remove this tag
9 (@cwl sumi1008) ;Replace ??? with your cwl,
10 ;; ;second ??? is replaced with partner cwl if you have one
11
12 ;; Bounce any number of balls around the screen.
13
14
15 ;;
16 ;; In this problem set you are given our official solution to problem
17 ;; set 4 (with a few additional things added) as a starting point.
18 ;; We have given you some more constants, a helper function called
19 ;; touch-paddle? which you may use, and a new data defintion called Game.
20 ;; You need to revise the program so that:
21 ;; - the game includes a paddle that moves back and forth across the
22 ;; bottom of the screen
23 ;; - the paddle is controlled by the left and right arrow keys
24 ;; - when a ball hits the paddle it disappears




m
25 ;; - as before the mouse can be used to add balls to the game




er as
26 ;;
27 ;; As stated above, we have given you a new data definition called Game.




co
28 ;; You MUST revise the program so that it uses Game as the world state.




eH w
29 ;; You MUST NOT change the Game data definition in anyway (though you are




o.
30 ;; allowed to add more Game constants).
31 ;;
rs e
32 ;; We suggest you work in three distinct phases, making sure your program
ou urc
33 ;; works correctly at the end of each phase before going on to the next.
34 ;; - change the program's world state to Game
35 ;; - provide left/right arrow key control over the paddle
36 ;; - make it so that when a ball hits the paddle it disappears
o

37 ;;
aC s


38 ;; In each of these phases you should follow the design recipes! Re-work
vi y re


39 ;; the domain analysis for changing and constant information, update the
40 ;; data definitions, revise the main function, and so on. Make sure that
41 ;; your tags are correct and that all your tests work correctly before you
42 ;; proceed to the next phase.
43 ;;
ed d




44 ;; NOTE: Your on-tick function MUST be designed as a composition of two other
ar stu




45 ;; functions called game-with-next-balls and game-with-caught-balls.
46 ;;
47 ;; Note that we are giving you significant help in the starter file.
48 ;; You absolutely MUST USE OUR STARTER AS THE BASIS FOR YOUR WORK.
is




49 ;;
50 ;; We recommend that you begin by printing this file and planning out what
Th




51 ;; needs to change, what needs to be added, and what will be unchanged.
52 ;;
53 (@problem 1)
54 (@htdw ListOfBall)
55
sh




56 ;; Constants:
57 (define WIDTH 605)
58 (define HEIGHT 535)
59
60 (define PADDLE-WIDTH 60)
61 (define PADDLE-THICKNESS 10)
62 (define PADDLE (rectangle PADDLE-WIDTH PADDLE-THICKNESS "solid" "white"))
63 (define PADDLE-CTR-Y (- HEIGHT 40))
64 (define PADDLE-MOVE-PER-KEY 10)
65
66This(define BALL-RADIUS
study source was 10)
downloaded by 100000805705997 from CourseHero.com on 10-14-2021 20:26:46 GMT -05:00
67

https://www.coursehero.com/file/81743757/Pset5pdf/

, 68 (define TOP BALL-RADIUS)
69 (define BOT (- HEIGHT BALL-RADIUS 1))
70 (define LEF BALL-RADIUS)
71 (define RIG (- WIDTH BALL-RADIUS 1))
72
73 (define BALL (circle BALL-RADIUS "solid" "white"))
74
75 (define MTS (rectangle WIDTH HEIGHT "solid" "green"))
76
77
78 ;; ===========================================================================
79 ;; ===========================================================================
80 ;; Data definitions:
81
82 (@htdd Ball)
83 (define-struct ball (x y dx dy))
84 ;; Ball is (make-ball Number Number Number Number)
85 ;; interp. (make-ball x y dx dy) is ball
86 ;; - position x, y in screen coordinates
87 ;; - velocity dx, dy in pixels/tick
88 ;; CONSTRAINT: x is in [LEF, RIG]; y is in [TOP, BOT]
89 (define B1 (make-ball (/ WIDTH 2) (/ HEIGHT 2) 4 -3))
90
91 (@dd-template-rules compound)




m
92




er as
93 (define (fn-for-ball b)
94 (... (ball-x b)




co
95 (ball-y b)




eH w
96 (ball-dx b)




o.
97 (ball-dy b)))
98
99 (@htdd ListOfBall) rs e
ou urc
100 ;; ListOfBall is one of:
101 ;; - empty
102 ;; - (cons Ball ListOfBall)
103 ;; interp. a list of balls
o

104 (define LOB1 empty)
aC s


105 (define LOB2 (cons B1 empty))
vi y re


106
107 (@dd-template-rules one-of
108 atomic-distinct
109 compound
110 ref
ed d




111 self-ref)
ar stu




112
113 (define (fn-for-lob lob)
114 (cond [(empty? lob) (...)]
115 [else
is




116 (... (fn-for-ball (first lob))
117 (fn-for-lob (rest lob)))]))
Th




118
119
120 (@htdd Game)
121 (define-struct game (balls paddle))
122 ;; Game is (make-game ListOfBall Number)
sh




123 ;; interp. the current state of a game, with all the balls in play,
124 ;; as well as the x-position of the paddle in screen coordinates
125 (define G0 (make-game empty (/ WIDTH 2)))
126 (define G1 (make-game (cons B1 empty) (/ WIDTH 2)))
127
128 (@dd-template-rules compound ref)
129
130 (define (fn-for-game g)
131 (... (fn-for-lob (game-balls g))
132 (game-paddle g)))
133This study source was downloaded by 100000805705997 from CourseHero.com on 10-14-2021 20:26:46 GMT -05:00
134

https://www.coursehero.com/file/81743757/Pset5pdf/

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
15 oktober 2021
Aantal pagina's
8
Geschreven in
2021/2022
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

$17.99
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF


Ook beschikbaar in voordeelbundel

Beoordelingen van geverifieerde kopers

Alle reviews worden weergegeven
3 jaar geleden

1.0

1 beoordelingen

5
0
4
0
3
0
2
0
1
1
Betrouwbare reviews op Stuvia

Alle beoordelingen zijn geschreven door echte Stuvia-gebruikers na geverifieerde aankopen.

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
StuviaGuides West Virgina University
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
16178
Lid sinds
7 jaar
Aantal volgers
8362
Documenten
5972
Laatst verkocht
1 dag geleden
Accounting, Finance, Statistics, Computer Science, Nursing, Chemistry, Biology & More — A+ Test Banks, Study Guides & Solutions

As a Top 1st Seller on Stuvia and a nursing professional, my mission is to be your light in the dark during nursing school and beyond. I know how stressful exams and assignments can be, which is why I’ve created clear, reliable, and well-structured resources to help you succeed. I offer test banks, study guides, and solution manuals for all subjects — including specialized test banks and solution manuals for business books. My materials have already supported countless students in achieving higher grades, and I want them to be the guide that makes your academic journey easier too. I’m passionate, approachable, and always focused on quality — because I believe every student deserves the chance to excel.

Lees meer Lees minder
4.3

2292 beoordelingen

5
1569
4
305
3
183
2
74
1
161

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen