diff --git a/TODO.org b/TODO.org index 70f8915..73d2d57 100644 --- a/TODO.org +++ b/TODO.org @@ -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 diff --git a/flappy-ball.lisp b/flappy-ball.lisp index a203d68..8b24d1c 100644 --- a/flappy-ball.lisp +++ b/flappy-ball.lisp @@ -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))) )