Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; UFO game
- (define CWIDTH 600)
- (define CHEIGHT 400)
- (define CANVAS (empty-scene CWIDTH CHEIGHT))
- (define TANK (rectangle (* CWIDTH 0.1) (* CHEIGHT 0.1) "solid" "darkgreen"))
- (define MISSILE (triangle 10 "solid" "red"))
- (define UFO (ellipse (* CWIDTH 0.15) (* CHEIGHT .1) "solid" "blue"))
- (define-struct aim (ufo tank))
- (define-struct fired (ufo tank missile))
- ; A UFO is Posn.
- ; interp.: (make-posn x y) is the UFO's current location
- ; A Missile is Posn.S
- ; interp.: (make-posn x y) is the missile's current location
- (define-struct tank (loc vel))
- ; A Tank is (make-tank Number Number).
- ; interp.: (make-tank x dx) means the tank is at (x ,HEIGHT)
- ; and that it moves dx pixels per clock tick
- (define w0 (make-aim (make-posn (random CWIDTH) 5)
- (make-tank (floor (/ CWIDTH 2)) 0)))
- ;; on-tick : world -> world
- ;; process movements
- (big-bang w0
- (on-tick tock 0.5)
- (on-key typed)
- (stop-when end?))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement