#lang scheme (require "snake.ss") (require 2htdp/universe) (big-bang world0 (on-draw (lambda (w) (snake+scene (world-snake w) (blocks+scene (world-blocks w) (foldr food+scene (level+scene (world-level w) MT-SCENE) (world-food w)))))) (on-tick (lambda (w) (cond [(ormap (lambda (f) (eating? (world-snake w) f)) (world-food w)) (eat-and-grow w)] [(level-complete? w) (next-level w)] [else (make-world (snake-slither (world-snake w)) (maybe-new-food (filter food-not-rotten? (map food-decay (world-food w)))) (world-level w) (world-blocks w))])) 1/10) (on-key (lambda (w ke) (cond [(direction? ke) (make-world (snake-change-direction (world-snake w) ke) (world-food w) (world-level w) (world-blocks w))] [else w]))) (stop-when (lambda (w) (or (self-colliding? (world-snake w)) (wall-colliding? (world-snake w)) (ormap (lambda (b) (block-colliding? (world-snake w) b)) (world-blocks w))))))