From 112681d88bf5021a4a56b794e7c97d1f57533ff3 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Mon, 29 Jun 2020 20:00:18 -0400 Subject: fourteen: server.rkt: Update eat-all-the-things Make new cupcakes appear on the screen every other time one is eaten. --- net/ricketyspace/ror/fourteen/server.rkt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'net') diff --git a/net/ricketyspace/ror/fourteen/server.rkt b/net/ricketyspace/ror/fourteen/server.rkt index e551b2f..8088b40 100644 --- a/net/ricketyspace/ror/fourteen/server.rkt +++ b/net/ricketyspace/ror/fourteen/server.rkt @@ -279,13 +279,16 @@ The server is responsible for: ;; determine left-over foods (define (eat-all-the-things player foods) (define b (ip-body player)) - (define (new-cupcake) - (create-a-body CUPCAKE)) + (define (new-cupcakes) + (cond [(> (length foods) 10) '()] + [else + (for/list ([i (in-range (random 1 3))]) + (create-a-body CUPCAKE))])) (for/fold ([foods '()]) ([f foods]) (cond [(body-collide? f b) (set-body-size! b (+ PLAYER-FATTEN-DELTA (body-size b))) - (cons (new-cupcake) foods)] + (append foods (new-cupcakes))] [else (cons f foods)]))) ;; body body -> Boolean -- cgit v1.2.3