Due date: 3/10 @ 4:30 pm
This problem set covers abstraction and "loops".
HtDP Problems:
19.1.5, 20.2.4 (also see 20.2.2)
The additional problems cover abstraction from the perspective of a game
program.
Problem Background:
In a "bumper cars" game, cars randomly move around the screen and
bump into other cars. Visually, a car is a red square. The natural
data representation of a car is a Posn
and
Number
; the position represents the cars's top-most
point and number represents its side length.
For full credit, use Scheme loops for the final definitions of these
functions. Recall that you do not have to use loops for the first
draft. Programming is like writing; editing and improving the essay is
everything.
Problem 1:
Design the function autos-create
, which consumes a natural
number and produces a list of Auto
s randomly placed in a 300
x 300 grid.
Problem 2:
Design the function autos-move
. It consumes a list of
Auto
s and produces one. The purpose is to move each Auto
randomly on a 300 x 300 scene by 3 pixels per tick of the clock.
Problem 3:
Design the function collisions?
, which consumes a list
of Auto
s and returns a list of Auto
s that have collided
with at least one other Auto
.
Optional:
Please explain any problems you had completing this assignment in no more than 30 words.