;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
-(define-module (gacela examples asteroids)
- #:use-module (gacela game))
+(define-module (gacela examples asteroids))
+; #:use-module (gacela game))
-(define asteroids (make-game "Asteroids"))
-(define player (make-entity))
-(add-component player (make-transform))
-(add-component player (make-mesh))
-(add-entity asteroids player)
+(define asteroids (game "Asteroids"))
+(define player (entity))
+(set! player (add-component player (transform)))
+(set! player (add-component player (mesh)))
+(set! asteroids (add-entity asteroids player))
(define asteroids
- (make-game "Asteroids"
- (make-entity
- (make-transform)
- (make-mesh))))
+ (game "Asteroids"
+ (entity
+ (transform)
+ (mesh))))
;;; Working with entities
-(define-record-type entity
+(define-record-type entity-type
(make-entity-record id components)
entity?
(id entity-id)
+ (game entity-game set-entity-game!)
(components entity-components set-entity-components!))
(set-record-type-printer! entity
(entity-id record)
(entity-components record))))
-(define (make-entity . components)
+(define (entity . components)
(make-entity-record
(gensym)
+ #f
components))
-(export make-entity
+(export entity
entity?
entity-id)
;;; Game Definition
-(define-record-type game
+(define-record-type game-type
(make-game-record name entities)
game?
(name game-name set-game-name!)
'()
(game-entities record))))))
-(define (make-game name . entities)
+(define (game name . entities)
(make-game-record
name
(alist->vhash
(map (lambda (e) (cons (entity-id e) e))
entities))))
-(export make-game
+(export game
game?)