Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.96 KB | None | 0 0
  1. ;; UFO game
  2. (define CWIDTH 600)
  3. (define CHEIGHT 400)
  4.  
  5. (define CANVAS (empty-scene CWIDTH CHEIGHT))
  6. (define TANK (rectangle (* CWIDTH 0.1) (* CHEIGHT 0.1) "solid" "darkgreen"))
  7. (define MISSILE (triangle 10 "solid" "red"))
  8. (define UFO (ellipse (* CWIDTH 0.15) (* CHEIGHT .1) "solid" "blue"))
  9.  
  10. (define-struct aim (ufo tank))
  11. (define-struct fired (ufo tank missile))
  12. ; A UFO is Posn.
  13. ; interp.: (make-posn x y) is the UFO's current location
  14.  
  15. ; A Missile is Posn.S
  16. ; interp.: (make-posn x y) is the missile's current location
  17.  
  18. (define-struct tank (loc vel))
  19. ; A Tank is (make-tank Number Number).
  20. ; interp.: (make-tank x dx) means the tank is at (x ,HEIGHT)
  21. ;   and that it moves dx pixels per clock tick
  22.  
  23. (define w0 (make-aim (make-posn (random CWIDTH) 5)
  24.                      (make-tank (floor (/ CWIDTH 2)) 0)))
  25.  
  26. ;; on-tick : world -> world
  27. ;; process movements
  28.  
  29. (big-bang w0
  30.           (on-tick tock 0.5)
  31.           (on-key typed)
  32.           (stop-when end?))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement