X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=games%2Fasteroids%2Fasteroids.scm;h=902fd549bec2825b5b5d52961b601510c1f33edb;hb=12725e0c889f28354fc75cfb34683f9323dd04dd;hp=a1e23f6d599c99bb7548c28ee13e67af664d3d1f;hpb=61cbb86694ce19f0d5dd44ccf847c9fbd61b8f7e;p=gacela.git diff --git a/games/asteroids/asteroids.scm b/games/asteroids/asteroids.scm index a1e23f6..902fd54 100644 --- a/games/asteroids/asteroids.scm +++ b/games/asteroids/asteroids.scm @@ -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 +;;; +;;; 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 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))))