Add exit actor that doesn't really work yet.

This commit is contained in:
David Thompson 2024-05-19 06:15:27 -04:00
parent a01fdd8983
commit e7e5413460
2 changed files with 34 additions and 10 deletions

View file

@ -46,11 +46,13 @@
(define *canvas-width* 0)
(define *canvas-height* 0)
;; Assets
(define tileset
(make-tileset (make-image "assets/images/cirkoban.png")
320 240
(inexact->exact tile-width)
(inexact->exact tile-height)))
(define audio:bump (make-audio "assets/sounds/bump.wav"))
;; Game state
(define *actormap* (make-whactormap))
@ -89,7 +91,9 @@
(define (move-player dir)
(save-snapshot!)
(with-goblins
($ *level* 'move-player dir)
(match ($ *level* 'move-player dir)
(#f (media-play audio:bump))
(_ #f))
(update-grid!)))
(define dt (/ 1000.0 60.0)) ; aim for updating at 60Hz
@ -110,6 +114,9 @@
(define (draw-player x y)
(draw-tile context tileset 0 x y))
(define (draw-exit x y)
(draw-tile context tileset 27 x y))
(define (draw-wall type x y)
(match type
('brick
@ -142,6 +149,7 @@
(match obj
(#f #f)
(('player) (draw-player x y))
(('exit) (draw-exit x y))
(('wall type) (draw-wall type x y))
(('block type) (draw-block type x y))
(('clock-emitter) (draw-clock-emitter x y))))))
@ -187,7 +195,9 @@
(move-player 'down))
((string=? key key:undo)
(rollback-snapshot!)
(with-goblins (update-grid!))))))
(with-goblins (update-grid!)))
((string=? key key:confirm)
(reset-game!)))))
(define (on-key-up event)
(let ((key (keyboard-event-code event)))