]> git.jsancho.org Git - gacela.git/blob - gacela/image.scm
Images in development
[gacela.git] / gacela / image.scm
1 ;;; Gacela, a GNU Guile extension for fast games development
2 ;;; Copyright (C) 2016 by Javier Sancho Fernandez <jsf at jsancho dot org>
3 ;;;
4 ;;; This program is free software: you can redistribute it and/or modify
5 ;;; it under the terms of the GNU General Public License as published by
6 ;;; the Free Software Foundation, either version 3 of the License, or
7 ;;; (at your option) any later version.
8 ;;;
9 ;;; This program is distributed in the hope that it will be useful,
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ;;; GNU General Public License for more details.
13 ;;;
14 ;;; You should have received a copy of the GNU General Public License
15 ;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17
18 (define-module (gacela image)
19   #:use-module (gacela scene)
20   #:use-module (gacela game)
21   #:use-module ((sdl2 image) #:prefix sdl2:)
22   #:use-module ((sdl2 render) #:prefix sdl2:)
23   #:export (import-bitmap
24             move-xy))
25
26 (define-syntax-rule (import-bitmap filename)
27   (make-scene
28    "bitmap"
29    (let ((image (sdl2:load-image filename))
30          (texture #f))
31      (let ((a 0))
32        (lambda ()
33          (if (not texture)
34              (set! texture (sdl2:surface->texture %sdl-renderer image)))
35          ;; (set! a (+ a 1))
36          ;; (format #t "~a steps with texture ~a~%" a texture))))))
37          (sdl2:clear-renderer %sdl-renderer)
38          (sdl2:render-copy %sdl-renderer texture)
39          (sdl2:present-renderer %sdl-renderer))))))
40
41 (define-syntax-rule (move-xy x y scene)
42   (make-scene
43    "move-xy"
44    (lambda ()
45      (display-scene scene))))