mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
Add sounds to demo
This commit is contained in:
parent
7307ebabd0
commit
4cc510b2c1
4 changed files with 10 additions and 4 deletions
|
|
@ -55,7 +55,7 @@
|
||||||
(sleep .1))
|
(sleep .1))
|
||||||
(setf (hiddenp splash) t)))
|
(setf (hiddenp splash) t)))
|
||||||
|
|
||||||
(defun paint (cx app)
|
(defun paint (body cx app)
|
||||||
(let ((game-over nil)
|
(let ((game-over nil)
|
||||||
(head-cell (car (snake app))))
|
(head-cell (car (snake app))))
|
||||||
|
|
||||||
|
|
@ -94,6 +94,7 @@
|
||||||
(fill-style cx :red)
|
(fill-style cx :red)
|
||||||
(font-style cx "bold 20px sans-serif")
|
(font-style cx "bold 20px sans-serif")
|
||||||
(fill-text cx "GAME OVER" 30 30)
|
(fill-text cx "GAME OVER" 30 30)
|
||||||
|
(play-media (create-audio body :source "/demo/game-over.wav" :controls nil))
|
||||||
(setf game-over t))
|
(setf game-over t))
|
||||||
(t
|
(t
|
||||||
(fill-style cx :purple)
|
(fill-style cx :purple)
|
||||||
|
|
@ -113,6 +114,8 @@
|
||||||
(fill-text cx (format nil "Score: ~A" (score app))
|
(fill-text cx (format nil "Score: ~A" (score app))
|
||||||
5 (- display-height 15))
|
5 (- display-height 15))
|
||||||
|
|
||||||
|
(play-media (create-audio body :source "/demo/eat.wav" :controls nil))
|
||||||
|
|
||||||
(setf (food app) (new-food)))
|
(setf (food app) (new-food)))
|
||||||
(t
|
(t
|
||||||
(draw-segment (car (last (snake app))))
|
(draw-segment (car (last (snake app))))
|
||||||
|
|
@ -179,10 +182,12 @@
|
||||||
(set-on-click up-btn #'on-click)
|
(set-on-click up-btn #'on-click)
|
||||||
(set-on-click down-btn #'on-click)
|
(set-on-click down-btn #'on-click)
|
||||||
|
|
||||||
|
(play-media (create-audio body :source "/demo/start.wav" :controls nil))
|
||||||
|
|
||||||
;; Game loop
|
;; Game loop
|
||||||
(loop
|
(loop
|
||||||
(unless (validp body) (return))
|
(unless (validp body) (return))
|
||||||
(when (paint context app) (return))
|
(when (paint body context app) (return))
|
||||||
(sleep .1))))
|
(sleep .1))))
|
||||||
|
|
||||||
(defun on-new-window (body)
|
(defun on-new-window (body)
|
||||||
|
|
@ -190,7 +195,8 @@
|
||||||
(setf (connection-data-item body "app-data") app))
|
(setf (connection-data-item body "app-data") app))
|
||||||
|
|
||||||
(display-splash body)
|
(display-splash body)
|
||||||
(start-game body))
|
(start-game body)
|
||||||
|
(run body))
|
||||||
|
|
||||||
(defun start-demo ()
|
(defun start-demo ()
|
||||||
"Start demo."
|
"Start demo."
|
||||||
|
|
|
||||||
BIN
static-files/demo/eat.wav
Normal file
BIN
static-files/demo/eat.wav
Normal file
Binary file not shown.
BIN
static-files/demo/game-over.wav
Normal file
BIN
static-files/demo/game-over.wav
Normal file
Binary file not shown.
BIN
static-files/demo/start.wav
Normal file
BIN
static-files/demo/start.wav
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue