aboutsummaryrefslogtreecommitdiff
path: root/demo/shmup.scm
diff options
context:
space:
mode:
Diffstat (limited to 'demo/shmup.scm')
-rw-r--r--demo/shmup.scm86
1 files changed, 43 insertions, 43 deletions
diff --git a/demo/shmup.scm b/demo/shmup.scm
index 15afb71..6d6ffe0 100644
--- a/demo/shmup.scm
+++ b/demo/shmup.scm
@@ -43,10 +43,10 @@
(define (entities-overlap? a b)
(aabb-overlap?
- (entity-ref a #:x 0) (entity-ref a #:y 0)
- (entity-ref a #:width 0) (entity-ref a #:height 0)
- (entity-ref b #:x 0) (entity-ref b #:y 0)
- (entity-ref b #:width 0) (entity-ref b #:height 0)))
+ (entity-ref a #:x 0) (entity-ref a #:y 0)
+ (entity-ref a #:width 0) (entity-ref a #:height 0)
+ (entity-ref b #:x 0) (entity-ref b #:y 0)
+ (entity-ref b #:width 0) (entity-ref b #:height 0)))
(define (find-dead entities)
(let ((bullets (filter (lambda (e) (eq? (entity-type e) 'bullet)) entities))
@@ -75,7 +75,7 @@
(define (clamp-player-x player)
(entity-set player #:x
- (max 0 (min (- +screen-width+ 16) (entity-ref player #:x 0)))))
+ (max 0 (min (- +screen-width+ 16) (entity-ref player #:x 0)))))
(define (update-player player input)
(let ((updated (chain player
@@ -120,43 +120,43 @@
(define *game*
(make-game
- title: "Demo: Shoot-em-up"
- width: +screen-width+ height: +screen-height+
-
- preload: (lambda (game)
- (init-audio!)
- (load-sounds! '((shoot . "demo/assets/jump.wav"))))
-
- create: (lambda (game)
- (game-scene-set! game
- (make-scene
- entities: (list (make-player))
- tilemap: #f
- camera: (make-camera x: 0 y: 0)
- tileset-texture: #f
- camera-target: #f
- engine-update: 'none)))
-
- update: (lambda (game dt)
- (set! *frame-count* (+ *frame-count* 1))
- (let* ((input (game-input game))
- (scene (game-scene game))
- (player (car (scene-entities scene))))
- (receive (player new-entities) (update-player player input)
- (let* ((others (filter (lambda (e) (not (eq? (entity-type e) 'player)))
- (scene-entities scene)))
- (spawned (maybe-spawn-enemies))
- (all (cons player (append new-entities spawned others))))
- (game-scene-set! game
- (chain (update-scene scene entities: all)
- (scene-map-entities _
- (lambda (scene_ e) (if (eq? (entity-type e) 'player) e (move-projectile e))))
- (scene-remove-dead _)
- (scene-filter-entities _
- (lambda (e) (or (eq? (entity-type e) 'player) (in-bounds? e))))))))))
-
- render: (lambda (game)
- (for-each (cut draw-shmup-entity (game-renderer game) <>)
- (scene-entities (game-scene game))))))
+ title: "Demo: Shoot-em-up"
+ width: +screen-width+ height: +screen-height+
+
+ preload: (lambda (game)
+ (init-audio!)
+ (load-sounds! '((shoot . "demo/assets/jump.wav"))))
+
+ create: (lambda (game)
+ (game-scene-set! game
+ (make-scene
+ entities: (list (make-player))
+ tilemap: #f
+ camera: (make-camera x: 0 y: 0)
+ tileset-texture: #f
+ camera-target: #f
+ engine-update: 'none)))
+
+ update: (lambda (game dt)
+ (set! *frame-count* (+ *frame-count* 1))
+ (let* ((input (game-input game))
+ (scene (game-scene game))
+ (player (car (scene-entities scene))))
+ (receive (player new-entities) (update-player player input)
+ (let* ((others (filter (lambda (e) (not (eq? (entity-type e) 'player)))
+ (scene-entities scene)))
+ (spawned (maybe-spawn-enemies))
+ (all (cons player (append new-entities spawned others))))
+ (game-scene-set! game
+ (chain (update-scene scene entities: all)
+ (scene-map-entities _
+ (lambda (scene_ e) (if (eq? (entity-type e) 'player) e (move-projectile e))))
+ (scene-remove-dead _)
+ (scene-filter-entities _
+ (lambda (e) (or (eq? (entity-type e) 'player) (in-bounds? e))))))))))
+
+ render: (lambda (game)
+ (for-each (cut draw-shmup-entity (game-renderer game) <>)
+ (scene-entities (game-scene game))))))
(game-run! *game*)