mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-05 18:20:36 -08:00
update snake demo for api changes
This commit is contained in:
parent
20d8e4a6d6
commit
cc1b306e75
1 changed files with 8 additions and 8 deletions
|
|
@ -80,22 +80,22 @@
|
|||
(>= (* (car head-cell) segment-size) display-width)
|
||||
(>= (* (cadr head-cell) segment-size) display-height)
|
||||
(self-collision))
|
||||
(fill-style cx :red)
|
||||
(font-style cx "bold 20px sans-serif")
|
||||
(setf (fill-style cx) :red
|
||||
(font-style cx) "bold 20px sans-serif")
|
||||
(fill-text cx "GAME OVER" 30 30)
|
||||
(play-media (create-audio body :source "/demo/game-over.wav" :controls nil))
|
||||
(setf game-over t))
|
||||
(t
|
||||
(fill-style cx :purple)
|
||||
(setf (fill-style cx) :purple)
|
||||
(push head-cell (snake app))
|
||||
(dolist (cell (snake app))
|
||||
(draw-segment cell))
|
||||
(fill-style cx :white)
|
||||
(setf (fill-style cx) :white)
|
||||
(cond ((equal head-cell (food app))
|
||||
(fill-text cx (format nil "Score: ~A" (score app))
|
||||
5 (- display-height 15))
|
||||
(setf (score app) (+ (score app) 10))
|
||||
(fill-style cx :green)
|
||||
(setf (fill-style cx) :green)
|
||||
(fill-text cx (format nil "Score: ~A" (score app))
|
||||
5 (- display-height 15))
|
||||
(play-media (create-audio body :source "/demo/eat.wav" :controls nil))
|
||||
|
|
@ -103,7 +103,7 @@
|
|||
(t
|
||||
(draw-segment (car (last (snake app))))
|
||||
(setf (snake app) (butlast (snake app)))))
|
||||
(fill-style cx :brown)
|
||||
(setf (fill-style cx) :brown)
|
||||
(draw-segment (food app))))
|
||||
game-over)))
|
||||
|
||||
|
|
@ -152,8 +152,8 @@
|
|||
(dotimes (n initial-length)
|
||||
(push (list n 0) (snake app)))
|
||||
(setf context (create-context2d disp))
|
||||
(font-style context "normal 20px sans-serif")
|
||||
(fill-style context :green)
|
||||
(setf (font-style context) "normal 20px sans-serif"
|
||||
(fill-style context) :green)
|
||||
(fill-text context (format nil "Score: ~A" (score app))
|
||||
5 (- display-height 15))
|
||||
(set-on-key-down body #'on-key-down :disable-default t)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue