Guile-2d is a 2D game programming library for GNU Guile. It is a layer above SDL and OpenGL that provides abstractions for common 2D game programming requirements such as:
- Tile maps
- Scene graph
- Input handling
Here is the simplest Guile-2d application (so far).
(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. **
GNU LGPL v3