refine text and restart controls
This commit is contained in:
parent
23cdd912cf
commit
52b6640c99
1 changed files with 15 additions and 15 deletions
|
@ -134,7 +134,7 @@
|
||||||
(ball-pen (make-pen :stroke (gray 0.5) :fill sketch:+yellow+ :weight 1))
|
(ball-pen (make-pen :stroke (gray 0.5) :fill sketch:+yellow+ :weight 1))
|
||||||
(collision-pen (make-pen :stroke (gray 0.5) :fill sketch:+red+ :weight 1))
|
(collision-pen (make-pen :stroke (gray 0.5) :fill sketch:+red+ :weight 1))
|
||||||
(pipe-pen (make-pen :stroke (gray 0.5) :fill sketch:+green+ :weight 1))
|
(pipe-pen (make-pen :stroke (gray 0.5) :fill sketch:+green+ :weight 1))
|
||||||
(pipes-amount 1)
|
(pipes-amount 10)
|
||||||
(pipes-spacing 200)
|
(pipes-spacing 200)
|
||||||
(pipes-width 20)
|
(pipes-width 20)
|
||||||
(pipes (random-pipes pipes-amount pipes-spacing ground-level 100 pipes-width))
|
(pipes (random-pipes pipes-amount pipes-spacing ground-level 100 pipes-width))
|
||||||
|
@ -155,20 +155,23 @@
|
||||||
collision-pen)
|
collision-pen)
|
||||||
ball-pen))
|
ball-pen))
|
||||||
|
|
||||||
|
(if (>= scroll-x target-x)
|
||||||
|
(let ((pic (load-resource "assets/level1/prize.png")))
|
||||||
|
(draw pic :x (- (+ 960 target-x) scroll-x) :y 0 )))
|
||||||
|
|
||||||
(when (eq state 'new)
|
(when (eq state 'new)
|
||||||
(setf scroll-x 0.0)
|
(setf scroll-x 0.0)
|
||||||
(text "Click to Start" 350 250 200 40))
|
(text "Click to Start" 350 250 200 40))
|
||||||
(when (eq state 'won)
|
(when (eq state 'won)
|
||||||
(text "You Won" 400 100 120 40))
|
(text "You Won" 380 100 160 60)
|
||||||
|
(text "Return to Restart" 300 150 320 40)
|
||||||
|
)
|
||||||
(when (eq state 'died)
|
(when (eq state 'died)
|
||||||
(text "You Died" 400 250 120 40))
|
(text "You Died" 380 100 160 60)
|
||||||
|
(text "Return to Restart" 300 150 320 40))
|
||||||
|
|
||||||
(text (format nil "~3,'0d" (floor score)) 820 20 100 40)
|
(text (format nil "~3,'0d" (floor score)) 820 20 100 40)
|
||||||
|
|
||||||
(if (>= scroll-x target-x)
|
|
||||||
(let ((pic (load-resource "assets/level1/prize.png")))
|
|
||||||
(draw pic :x (- (+ 960 target-x) scroll-x) :y 0 )))
|
|
||||||
|
|
||||||
(when (eq state 'running)
|
(when (eq state 'running)
|
||||||
(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))
|
||||||
|
@ -182,20 +185,17 @@
|
||||||
(setf ball (ball-flap ball flap-speed))
|
(setf ball (ball-flap ball flap-speed))
|
||||||
(when (eq state 'new)
|
(when (eq state 'new)
|
||||||
(setf state 'running))
|
(setf state 'running))
|
||||||
(when (eq state 'died)
|
|
||||||
(setf state 'new))
|
|
||||||
(when (eq state 'won)
|
|
||||||
(setf state 'new))
|
|
||||||
))
|
))
|
||||||
|
|
||||||
(defmethod on-key ((instance flappy-ball) key state)
|
(defmethod on-key ((instance flappy-ball) key state)
|
||||||
(with-slots (ball flap-speed state) instance
|
(with-slots (ball flap-speed state) instance
|
||||||
(setf ball (ball-flap ball flap-speed))
|
(setf ball (ball-flap ball flap-speed))
|
||||||
(when (eq state 'new)
|
(print key)
|
||||||
(setf state 'running))
|
(when (and (eq state 'new) (not (eq key :RETURN))
|
||||||
(when (eq state 'died)
|
(setf state 'running))
|
||||||
|
(when (and (eq state 'died) (eq key :RETURN))
|
||||||
(setf state 'new))
|
(setf state 'new))
|
||||||
(when (eq state 'won)
|
(when (and (eq state 'won) (eq key :RETURN))
|
||||||
(setf state 'new))
|
(setf state 'new))
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue