From: Javier Sancho Date: Sat, 4 Feb 2017 01:02:44 +0000 (+0100) Subject: Window scene X-Git-Url: https://git.jsancho.org/?p=gacela.git;a=commitdiff_plain;h=ee72c2bc37b7d06fbf90b27fa8e45e6f2d4e27bc Window scene --- diff --git a/examples/01-hello-world/01-hello-world.scm b/examples/01-hello-world/01-hello-world.scm index fd349c4..cdad143 100644 --- a/examples/01-hello-world/01-hello-world.scm +++ b/examples/01-hello-world/01-hello-world.scm @@ -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"))) diff --git a/examples/02-event-driven-programming/02-event-driven-programming.scm b/examples/02-event-driven-programming/02-event-driven-programming.scm index 903a6a5..0044ac5 100644 --- a/examples/02-event-driven-programming/02-event-driven-programming.scm +++ b/examples/02-event-driven-programming/02-event-driven-programming.scm @@ -19,4 +19,6 @@ (use-modules (gacela)) -(run-scene (import-bitmap "x.bmp")) +(display-scene + (window '(#:resolution (640 480)) + (import-bitmap "x.bmp"))) diff --git a/gacela.scm b/gacela.scm index 5b31c64..d49cbfa 100644 --- a/gacela.scm +++ b/gacela.scm @@ -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) diff --git a/gacela/game.scm b/gacela/game.scm index dd7886c..86136cd 100644 --- a/gacela/game.scm +++ b/gacela/game.scm @@ -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)) diff --git a/gacela/scene.scm b/gacela/scene.scm index e620480..e969432 100644 --- a/gacela/scene.scm +++ b/gacela/scene.scm @@ -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 index 0000000..eeed32d --- /dev/null +++ b/gacela/window.scm @@ -0,0 +1,27 @@ +;;; Gacela, a GNU Guile extension for fast games development +;;; Copyright (C) 2016 by Javier Sancho Fernandez +;;; +;;; 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 . + + +(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)))))