Skip to content

Instantly share code, notes, and snippets.

@davesmylie
davesmylie / gist:2662029
Created May 11, 2012 19:46
htdp2e exercise 172
; See http://htdp2e.blogspot.com/2012/05/exercise-172-develop-data.html
; Constants
(define WORM-SIZE 10)
(define WORM-MOVE (* WORM-SIZE 2))
(define WIDTH 800) ; width of the game
(define HEIGHT 500) ; height of the game
(define SEGMENT (circle WORM-SIZE "solid" "red"))
; these structs will hold the current list of worm segments, the direction
@davesmylie
davesmylie / gist:2650711
Created May 10, 2012 02:53
H2DP2E: Exercise 171
; Constants
(define WORM-SIZE 10)
(define WORM-MOVE WORM-SIZE)
(define WIDTH 800) ; width of the game
; these structs will hold the current position of the worm, the direction
; the worm is travelling in, and our world object
(define-struct worm(x-pos y-pos))
(define-struct direction(x y))
@davesmylie
davesmylie / gist:2640081
Created May 8, 2012 22:44
exercise 170
;Exercise 170: Design an interactive GUI program that continually moves a one-segment worm and enables a player to
;control the movement of the worm with the four cardinal arrow keys. Your program should use a red disk to render the
;one-and-only segment of the worm. For each clock tick, the worm should move diameter.
; Game constants and constants
; We make the worm size changable here, and when we move the worm it will be by the amount
; specified
; The hints provided in the question suggest two different means to keep track of the worm - a physical and logical