add tests for ball entity

This commit is contained in:
Peter Tillemans 2024-04-27 09:47:19 +02:00
parent 8d059e9468
commit cc01c77c66
2 changed files with 21 additions and 1 deletions

View file

@ -8,3 +8,21 @@
(in-suite all-tests) (in-suite all-tests)
(test test-ball
(let ((ball (make-ball 100 300 5.0 10)))
(is (= (ball-x ball) 100))
(is (= (ball-y ball) 300))
(is (= (ball-size ball) 10))
(is (= (ball-velocity ball) 5.0))))
(test test-ball-move
(let ((ball (make-ball 100 300 5.0 10)))
(is (= (ball-x (ball-move ball 1 600)) 100))
(is (= (ball-y (ball-move ball 1 600)) 305))
(is (= (ball-size (ball-move ball 1 600)) 10))
(is (= (ball-velocity (ball-move ball 1 600)) 6.0))))
(run-all-tests)
```

View file

@ -1,6 +1,8 @@
(defpackage :flappy-ball (defpackage :flappy-ball
(:use :cl :sketch) (:use :cl :sketch)
(:export :flappy-ball :on-click :on-key :setup)) (:export :flappy-ball :on-click :on-key :setup
:make-ball :ball-x :ball-y :ball-velocity :ball-size :ball-move :ball-flap :ball-draw
:make-pipe :pipe-x :pipe-height :pipe-gap :pipe-width :pipe-draw :pipe-collides))
(in-package :flappy-ball) (in-package :flappy-ball)