(define-module (game render key)
  #:use-module (game util assets)
  #:use-module (game model key)
  #:use-module (game render level)
  #:use-module (chickadee math vector)
  #:use-module (chickadee graphics sprite)
  #:use-module (chickadee graphics texture)
  #:export (render-keys))

(define key-index 1726)
(define closed-goal-index 3404)
(define open-goal-index ladder-index)

(define (render-key key)
  (draw-sprite 
   (texture-atlas-ref tile-atlas key-index)
   (vec2+ (key-position key) (vec2 -8 0))))

(define (render-goal keys goal-position)
  (let ((goal-index (if (null? keys) open-goal-index closed-goal-index)))
    (draw-sprite 
     (texture-atlas-ref tile-atlas goal-index)
     goal-position)))

(define (render-keys keys goal-position)
  (for-each (lambda (key)
              (render-key key))
            keys)
  (render-goal keys goal-position))


