main.scm 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ;;; This example is adapted from the project website at
  2. ;;; https://dthompson.us/projects/chickadee.html.
  3. (import
  4. (except (rnrs base) map)
  5. (only (guile)
  6. lambda* λ
  7. when
  8. simple-format
  9. current-output-port)
  10. ;; GNU Guile batteries
  11. (system repl coop-server)
  12. (ice-9 exceptions)
  13. ;; Chickadee libs
  14. (chickadee)
  15. (chickadee math vector)
  16. (chickadee graphics sprite)
  17. (chickadee graphics texture)
  18. (chickadee graphics font))
  19. (define-syntax once!
  20. (λ (stx)
  21. (syntax-case stx ()
  22. [(once! exprs ... flag)
  23. (syntax
  24. (unless flag
  25. exprs ...
  26. (set! flag #t)))])))
  27. (define sprite #f)
  28. (define dt-shown #f)
  29. (define repl (spawn-coop-repl-server))
  30. (define load
  31. (λ ()
  32. (set! sprite (load-image "images/chickadee.png"))))
  33. (define draw
  34. (λ (alpha)
  35. (draw-sprite sprite (vec2 256.0 176.0))))
  36. (define update
  37. (λ (dt)
  38. (poll-coop-repl-server repl)
  39. (once! (simple-format (current-output-port) "dt: ~a\n" dt)
  40. (simple-format (current-output-port) "(elapsed-time): ~a\n" (elapsed-time))
  41. dt-shown)))
  42. (run-game #:load load
  43. #:draw draw
  44. #:update update)
  45. ;;; Now you can connect to the Guile REPL server using M-x
  46. ;;; connect-to-guile in Emacs and then inspect bindings,
  47. ;;; which are already defined, modify them, or create new
  48. ;;; ones.