211 F '04
Set 1
Set 2
Set 3
Set 4
Set 5
Set 6
Set 7
Set 8
Set 9
Set 10
Set 11
Set 12
Set 13
Set 14

Problem Set 8

Due date: 11/1 @ 6:00 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 "space war" game, the player can fire shots at the UFO as it descends. Visually a shot is a thin, yellow rectangle. The natural data representation of a shot is a Posn; the position represents the shot's top-most point.

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 shots-create, which consumes a natural number and produces a list of Shots randomly placed in a 100 x 300 grid.

Problem 2:

Design the function shots-move. It consumes a list of Shots and produces one. The purpose is to move each shot upwards on a 100 x 300 scene by 3 pixels per tick of the clock.

Problem 3:

Design the function hit?, which consumes a Rectangle and a list of shots and determines whether any of the shots is inside the Rectangle.

(define-struct rectangle (x y width height))
;; A Rectangle is: 
;; --- (make-rectangle Number Number Number Number)

last updated on Mon Nov 29 11:44:30 EST 2004generated with PLT Scheme