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 ()
|
||||
"load all resources for all levels in memory"
|
||||
(setf *resources* (serapeum:dict))
|
||||
(loop for level in (list "level1")
|
||||
(loop for level in (list "level1" "level2" "level3" "level4")
|
||||
do (read-level-assets level)
|
||||
finally (return *resources*)))
|
||||
|
||||
|
@ -235,11 +235,11 @@ Hash-table with level name => file name => resource.")
|
|||
(score 0)
|
||||
(high-scores (load-high-scores "highscores"))
|
||||
(on-exit (lambda () ()))
|
||||
(play-level 0)
|
||||
(play-level 1)
|
||||
)
|
||||
|
||||
(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-foreground level pipes scroll-x pipe-pen height)
|
||||
|
@ -267,16 +267,25 @@ Hash-table with level name => file name => resource.")
|
|||
(with-slots (score state
|
||||
width ground-level
|
||||
scroll-x scroll-speed
|
||||
pipes-width pipes-spacing pipes-amount
|
||||
pipes pipes-width pipes-spacing pipes-amount
|
||||
ball gravity
|
||||
play-level
|
||||
high-scores) instance
|
||||
(setf score (1+ (/ (- scroll-x pipes-width (/ width 10)) pipes-spacing)))
|
||||
(setf scroll-x (+ scroll-x scroll-speed))
|
||||
(setf ball (ball-move ball gravity ground-level))
|
||||
(when (> (round score) pipes-amount)
|
||||
(setf state 'won)
|
||||
(setf high-scores (high-scores-add high-scores score))
|
||||
(save-high-scores "highscores" high-scores))))
|
||||
(if (eq play-level 4)
|
||||
(progn
|
||||
(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))
|
||||
(with-slots (state high-scores score) instance
|
||||
|
|
Loading…
Reference in a new issue