first draft of level support
This commit is contained in:
parent
e10f22ceb1
commit
9cd0cba597
1 changed files with 16 additions and 7 deletions
|
@ -161,7 +161,7 @@ Hash-table with level name => file name => resource.")
|
||||||
(defun %read-static-files-in-memory ()
|
(defun %read-static-files-in-memory ()
|
||||||
"load all resources for all levels in memory"
|
"load all resources for all levels in memory"
|
||||||
(setf *resources* (serapeum:dict))
|
(setf *resources* (serapeum:dict))
|
||||||
(loop for level in (list "level1")
|
(loop for level in (list "level1" "level2" "level3" "level4")
|
||||||
do (read-level-assets level)
|
do (read-level-assets level)
|
||||||
finally (return *resources*)))
|
finally (return *resources*)))
|
||||||
|
|
||||||
|
@ -235,11 +235,11 @@ Hash-table with level name => file name => resource.")
|
||||||
(score 0)
|
(score 0)
|
||||||
(high-scores (load-high-scores "highscores"))
|
(high-scores (load-high-scores "highscores"))
|
||||||
(on-exit (lambda () ()))
|
(on-exit (lambda () ()))
|
||||||
(play-level 0)
|
(play-level 1)
|
||||||
)
|
)
|
||||||
|
|
||||||
(let ((ball-collides (some (lambda (pipe) (pipe-collides pipe ball scroll-x)) pipes))
|
(let ((ball-collides (some (lambda (pipe) (pipe-collides pipe ball scroll-x)) pipes))
|
||||||
(level (format nil "level~a" (1+ play-level))))
|
(level (format nil "level~a" play-level)))
|
||||||
|
|
||||||
(draw-background level scroll-x)
|
(draw-background level scroll-x)
|
||||||
(draw-foreground level pipes scroll-x pipe-pen height)
|
(draw-foreground level pipes scroll-x pipe-pen height)
|
||||||
|
@ -267,16 +267,25 @@ Hash-table with level name => file name => resource.")
|
||||||
(with-slots (score state
|
(with-slots (score state
|
||||||
width ground-level
|
width ground-level
|
||||||
scroll-x scroll-speed
|
scroll-x scroll-speed
|
||||||
pipes-width pipes-spacing pipes-amount
|
pipes pipes-width pipes-spacing pipes-amount
|
||||||
ball gravity
|
ball gravity
|
||||||
|
play-level
|
||||||
high-scores) instance
|
high-scores) instance
|
||||||
(setf score (1+ (/ (- scroll-x pipes-width (/ width 10)) pipes-spacing)))
|
(setf score (1+ (/ (- scroll-x pipes-width (/ width 10)) pipes-spacing)))
|
||||||
(setf scroll-x (+ scroll-x scroll-speed))
|
(setf scroll-x (+ scroll-x scroll-speed))
|
||||||
(setf ball (ball-move ball gravity ground-level))
|
(setf ball (ball-move ball gravity ground-level))
|
||||||
(when (> (round score) pipes-amount)
|
(when (> (round score) pipes-amount)
|
||||||
(setf state 'won)
|
(if (eq play-level 4)
|
||||||
(setf high-scores (high-scores-add high-scores score))
|
(progn
|
||||||
(save-high-scores "highscores" high-scores))))
|
(setf state 'won)
|
||||||
|
(setf high-scores (high-scores-add high-scores score))
|
||||||
|
(save-high-scores "highscores" high-scores))
|
||||||
|
(progn
|
||||||
|
(setf play-level (1+ play-level))
|
||||||
|
(setf pipes (random-pipes pipes-amount pipes-spacing ground-level 100 pipes-width))
|
||||||
|
(setf scroll-x 0.0)
|
||||||
|
(setf scroll-speed (* 0.8 scroll-speed)))))))
|
||||||
|
|
||||||
|
|
||||||
(defmethod on-death ((instance flappy-ball))
|
(defmethod on-death ((instance flappy-ball))
|
||||||
(with-slots (state high-scores score) instance
|
(with-slots (state high-scores score) instance
|
||||||
|
|
Loading…
Reference in a new issue