summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoutade <thegoofist@protonmail.com>2019-10-12 08:56:42 -0500
committerBoutade <thegoofist@protonmail.com>2019-10-12 08:56:42 -0500
commit1545f6d93e13666b07a7aa7d7dc86e6b73a79d7c (patch)
tree4641d57d6458aafc67fdf21f78562833ba99321a
parent85474adccbf754034b877ad6e9ca133027c9c4e4 (diff)
audio, controlling space
-rw-r--r--assets/coldday.mp3bin0 -> 206724 bytes
-rw-r--r--the-price-of-a-cup-of-coffee.asd2
-rw-r--r--the-price-of-a-cup-of-coffee.lisp15
3 files changed, 13 insertions, 4 deletions
diff --git a/assets/coldday.mp3 b/assets/coldday.mp3
new file mode 100644
index 0000000..3d64363
--- /dev/null
+++ b/assets/coldday.mp3
Binary files differ
diff --git a/the-price-of-a-cup-of-coffee.asd b/the-price-of-a-cup-of-coffee.asd
index 7d53563..20deed3 100644
--- a/the-price-of-a-cup-of-coffee.asd
+++ b/the-price-of-a-cup-of-coffee.asd
@@ -6,7 +6,7 @@
:license "GPL3"
:version "0.0.1"
:serial t
- :depends-on (#:animise #:sdl2 #:sdl2-image #:harmony)
+ :depends-on (#:animise #:sdl2 #:sdl2-image #:harmony-simple)
:components ((:file "package")
(:file "macros")
(:file "assets")
diff --git a/the-price-of-a-cup-of-coffee.lisp b/the-price-of-a-cup-of-coffee.lisp
index f93d2d2..3b03169 100644
--- a/the-price-of-a-cup-of-coffee.lisp
+++ b/the-price-of-a-cup-of-coffee.lisp
@@ -2,7 +2,7 @@
(in-package #:the-price-of-a-cup-of-coffee)
-(defvar *human-fps* 5)
+(defvar *human-fps* 4)
(def-normal-class human ()
(walk-vec (cons 0 0))
@@ -24,10 +24,15 @@
(defgeneric render (sprite renderer))
(defgeneric update (thing time))
+(defparameter +vert-min+ 16)
+(defparameter +vert-max+ (- 600 128 10))
+
(defmethod update ((human human) ticks)
(with-slots (frame next-frame-at faces face walk-vec pos) human
- (incf (sdl2:rect-x pos) (car walk-vec))
- (incf (sdl2:rect-y pos) (cdr walk-vec))
+ (setf (sdl2:rect-x pos) (mod (+ (sdl2:rect-x pos) (car walk-vec)) 1024))
+ (setf (sdl2:rect-y pos)
+ (clamp (+ (sdl2:rect-y pos) (cdr walk-vec))
+ +vert-min+ +vert-max+))
(when (<= next-frame-at ticks)
(incf next-frame-at (/ 1000 *human-fps*))
(setf next-frame-at (max next-frame-at ticks))
@@ -143,6 +148,10 @@
(defun main ()
+
+ (harmony-simple:initialize)
+ (harmony-simple:play #P"assets/coldday.mp3" :music :loop t)
+
(sdl2:with-init (:everything)
(sdl2:with-window (win :w 1024 :h 600 :title "The Price Of A Cup Of Coffee" :flags '(:shown))
(sdl2:with-renderer (renderer win :flags '(:accelerated))