From 34c02c640b540c9f9c5062c422b2744c5eb95f0d Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 25 Jun 2013 07:44:16 -0400 Subject: Add more content to README. --- README.org | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/README.org b/README.org index fcdd061..343a182 100644 --- a/README.org +++ b/README.org @@ -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 -- cgit v1.2.3