]> git.jsancho.org Git - gacela.git/blobdiff - games/asteroids/asteroids.scm
Fran example using scenes
[gacela.git] / games / asteroids / asteroids.scm
index a1e23f6d599c99bb7548c28ee13e67af664d3d1f..902fd549bec2825b5b5d52961b601510c1f33edb 100644 (file)
@@ -1,23 +1,44 @@
-(set-game-properties! #:title "Gacela Asteroids")
+;;; Gacela, a GNU Guile extension for fast games development
+;;; Copyright (C) 2014 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 draw-asteroid
-  (let ((asteroid (load-texture "Asteroid.png")))
-    (lambda (a)
-      (to-origin)
-      (translate (car a) (cadr a))
-      (draw-texture asteroid))))
 
-(define (move-asteroid a)
-  (let* ((x (car a)) (y (cadr a))
-        (vx (caddr a)) (vy (cadddr a))
-        (nx (+ x vx)) (ny (+ y vy)))
-    (cond ((> nx 320) (set! vx -1))
-         ((< nx -320) (set! vx 1)))
-    (cond ((> ny 240) (set! vy -1))
-         ((< ny -240) (set! vy 1)))
-    (list (+ x vx) (+ y vy) vx vy)))
+(define-module (gacela examples asteroids))
+;  #:use-module (gacela game))
 
-(let ((asteroids '((100 100 1 1) (-100 -100 -1 1))))
-  (run-game
-   (set! asteroids (map move-asteroid asteroids))
-   (for-each draw-asteroid asteroids)))
+
+(define asteroids (game "Asteroids"))
+(define player (entity))
+(set! player (add-component player (name "player")))
+(set! player (add-component player (transform)))
+(set! player (add-component player (mesh)))
+(set! asteroids (add-entity asteroids player))
+(define rock (entity))
+(set! rock (add-component rock (name "rock")))
+(set! rock (add-component rock (transform)))
+(set! rock (add-component rock (mesh)))
+(set! asteroids (add-entity asteroids rock))
+
+
+(define asteroids
+  (game "Asteroids"
+   (entity
+    (name "player")
+    (transform)
+    (mesh))
+   (entity
+    (name "rock")
+    (transform)
+    (mesh))))