PasteRack.org
Paste # 21028
2017-04-25 20:00:32

Fork as a new paste.

Paste viewed 56 times.


Embed:

  1. #lang htdp/bsl
  2.  
  3. (require 2htdp/image)
  4. (require 2htdp/universe)
  5.  
  6. (define-struct world (square-position))
  7.  
  8. (define (update w)
  9.   ; increment the square position by 1
  10.   (make-world (add1 (world-square-position w))))
  11.  
  12. (define (draw w)
  13.   ; render a red square on an empty background
  14.   (place-image (square 50 "solid" "red")
  15.                (world-square-position w)
  16.                (world-square-position w)
  17.                (empty-scene 800 600)))
  18.  
  19. (big-bang
  20.  ; start with the square position at 0
  21.  (make-world 0)
  22.  
  23.  [to-draw draw]
  24.  [on-tick update])

=>