diff options
author | David Thompson <dthompson2@worcester.edu> | 2013-06-25 07:44:16 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2013-06-25 07:44:16 -0400 |
commit | 34c02c640b540c9f9c5062c422b2744c5eb95f0d (patch) | |
tree | 560974e4c61ba5e49b13a938439e26ea6adacd37 | |
parent | cc2ee1128583b44357827ab2f0c7a692463359c9 (diff) |
Add more content to README.
-rw-r--r-- | README.org | 58 |
1 files changed, 58 insertions, 0 deletions
@@ -12,10 +12,68 @@ - Input handling - Scripting +** Inspiration + Every programming language should have a fun, easy to use 2D game + library. Guile-2d draws it's inspiration from great + libraries/frameworks such as [[http://love2d.org][LÖVE]], [[http://pygame.org][Pygame]], and [[http://pyglet.org][Pyglet]]. + +** Example + Here is the simplest Guile-2d application (so far). + + ```scheme + (use-modules ((sdl sdl) #:prefix SDL:) + (figl gl) + (2d sprite) + (2d game-loop) + (2d window)) + + (define window-width 800) + (define window-height 600) + (define sprite #f) + + (define (key-down key) + (display key) (newline) + (case key + ;; Quit program when ESCAPE or Q is pressed. + ;; For now we have to use the SDL keycodes, but not for long! + ((SDLK_ESCAPE SDLK_q) + (close-window) + (quit)))) + + ;; Draw our sprite + (define (render) + (draw-sprite sprite)) + + ;; Register callbacks. + (set-render-callback (lambda () (render))) + (set-key-down-callback (lambda (key) (key-down key))) + + ;; Open the window. + (open-window window-width window-height) + + ;; Load a sprite and center it on the screen. + ;; Must be done AFTER opening the window. + (set! sprite (load-sprite "sprite.png" #:position (vector (/ window-width 2) + (/ window-height 2)))) + + ;; Start the game loop. + ;; The render callback will be called through this procedure. + (run-game-loop) + ``` + +** REPL Driven Development + The read-eval-print-loop present in Guile allows you to develop + your game while it is running! This allows you to see in real time + what your changes do to the game without having to restart the + program every time. + + ** This section needs to be completed. ** + ** Dependencies - guile-figl - guile-sdl + - SDL 1.2 ** License |