Gene Pasquet on Nostr: Is there a better way to write this in scheme? That looks ugly to me: (define ...
Is there a better way to write this in scheme? That looks ugly to me:
(define (player-collides?)
(let ((player-hitbox (vehicle-hitbox player-position)))
(let loop ((vehicles vehicles))
(if (rect-intersects? player-hitbox (vehicle-hitbox (vehicle-position (car vehicles))))
#t
(if (null? (cdr vehicles))
#f
(loop (cdr vehicles)))))))
#lisp #scheme #lispgamejam
(define (player-collides?)
(let ((player-hitbox (vehicle-hitbox player-position)))
(let loop ((vehicles vehicles))
(if (rect-intersects? player-hitbox (vehicle-hitbox (vehicle-position (car vehicles))))
#t
(if (null? (cdr vehicles))
#f
(loop (cdr vehicles)))))))
#lisp #scheme #lispgamejam