add score in display.

This commit is contained in:
Peter Tillemans 2024-05-01 11:57:14 +02:00
parent ba69ed8d03
commit 23cdd912cf
2 changed files with 8 additions and 4 deletions

View file

@ -4,7 +4,7 @@
A flappy bird clone to get experience with Common Lisp and game development.
* Game Plan [11/15]
* Game Plan [12/15]
- [X] Create bird, well, ball
- [X] Add physics for ball movement
- [X] Add inputs on key and mouse clicks
@ -16,7 +16,7 @@ A flappy bird clone to get experience with Common Lisp and game development.
- [X] Create random pipes
- [X] Add goal after last pipe
- [X] Create state machine to manage start/play/finish
- [ ] Add scores
- [X] Add scores
- [ ] Add high scores
- [ ] Package for Mac/Linux/(Windows?)
- [ ] Create different levels

View file

@ -141,7 +141,8 @@
(scroll-x 0.0)
(scroll-speed 0.2)
(target-x (- (* pipes-amount pipes-spacing) 720))
(state 'new))
(state 'new)
(score 0))
(draw-background scroll-x)
(draw-foreground pipes scroll-x pipe-pen height)
@ -162,14 +163,17 @@
(when (eq state 'died)
(text "You Died" 400 250 120 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)
(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 (> scroll-x (+ (* pipes-amount pipes-spacing) pipes-width))
(when (> (round score) pipes-amount)
(setf state 'won)))
)