]> git.jsancho.org Git - gacela.git/commitdiff
Window scene
authorJavier Sancho <jsf@jsancho.org>
Sat, 4 Feb 2017 01:02:44 +0000 (02:02 +0100)
committerJavier Sancho <jsf@jsancho.org>
Sat, 4 Feb 2017 01:02:44 +0000 (02:02 +0100)
examples/01-hello-world/01-hello-world.scm
examples/02-event-driven-programming/02-event-driven-programming.scm
gacela.scm
gacela/game.scm
gacela/scene.scm
gacela/window.scm [new file with mode: 0644]

index fd349c44c1b947a48cf05a60417efee44cbc45ea..cdad143f017f5dd5bc422b0b407779a3af2dc6b6 100644 (file)
@@ -19,4 +19,6 @@
 
 (use-modules (gacela))
 
-(run-scene (import-bitmap "hello-world.bmp"))
+(display-scene
+ (window '(#:resolution (640 480))
+        (import-bitmap "hello-world.bmp")))
index 903a6a536d00857feb92c97c5af32b3a22f8e32a..0044ac53160b33c7fc31663b4fc75e4fbd68b905 100644 (file)
@@ -19,4 +19,6 @@
 
 (use-modules (gacela))
 
-(run-scene (import-bitmap "x.bmp"))
+(display-scene
+ (window '(#:resolution (640 480))
+        (import-bitmap "x.bmp")))
index 5b31c641174c17f026b27c8ecc9bf8781f084f58..d49cbfae27fe17630d438a3b3ee398687be73414 100644 (file)
@@ -24,7 +24,8 @@
     (define %public-modules
       '((gacela image)
        (gacela math)
-       (gacela scene)))
+       (gacela scene)
+       (gacela window)))
 
     (for-each (let ((i (module-public-interface (current-module))))
                (lambda (m)
index dd7886cc150e5f230bf3ed5c3c97318c0aa8f4da..86136cd9a08fdf0070554dcf6a975efff108ff1d 100644 (file)
@@ -153,8 +153,8 @@ milliseconds of the last iteration of the game loop."
   (sdl2:hide-window! %sdl-window)
   (sdl2:sdl-quit))
 
-(define (play-game scene)
+(define (play-game scene . args)
   (init-window)
-  (open-window)
+  (apply open-window args)
   (run-game-loop scene)
   (close-window))
index e62048021a414f34de219e179378b9983ee84029..e969432c3314b2e05435d7f23a009408422f1a0d 100644 (file)
@@ -42,6 +42,6 @@
 (define (display-scene scene . args)
   (apply (scene-procedure scene) args))
 
-(define (run-scene scene)
-  (play-game
-   (scene-procedure scene)))
+(define (run-scene scene . args)
+  (apply play-game
+        (cons (scene-procedure scene) args)))
diff --git a/gacela/window.scm b/gacela/window.scm
new file mode 100644 (file)
index 0000000..eeed32d
--- /dev/null
@@ -0,0 +1,27 @@
+;;; Gacela, a GNU Guile extension for fast games development
+;;; Copyright (C) 2016 by Javier Sancho Fernandez <jsf at jsancho dot org>
+;;;
+;;; This program is free software: you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (gacela window)
+  #:use-module (gacela scene)
+  #:export (window))
+
+
+(define* (window window-properties #:optional scene)
+  (make-scene
+   "window"
+   (lambda ()
+     (apply run-scene (cons scene window-properties)))))