(include "raylib-definitions.scm")
(import raylib-scm)
(use raylib-scm)

(define screen-width 800)
(define screen-height 450)

(define (main-loop position)
  (if (not (window-should-close?))
      (begin
        (begin-drawing)
        (clear-background RAYWHITE)
        (draw-text "move the ball with arrow keys" 10 10 20 DARKGRAY)
        (draw-circle-v position 50.0 DARKGRAY)
        (end-drawing)
        (cond ((is-key-down? keyboard-keys/key-right)
               (main-loop (make-vector-2 (+ (vector-2-x position) 2.0)
                                         (vector-2-y position))))
              ((is-key-down? keyboard-keys/key-left)
               (main-loop (make-vector-2 (- (vector-2-x position) 2.0)
                                         (vector-2-y position))))
              ((is-key-down? keyboard-keys/key-up)
               (main-loop (make-vector-2 (vector-2-x position)
                                         (- (vector-2-y position) 2.0))))
              ((is-key-down? keyboard-keys/key-down)
               (main-loop (make-vector-2 (vector-2-x position)
                                         (+ (vector-2-y position) 2.0))))
              (else (main-loop position))))
      (close-window)))

(init-window screen-width screen-height "raylib [core] example - keyboard input")
(set-target-fps 60)

(main-loop (make-vector-2 (/ screen-width 2) (/ screen-height 2)))
