From 1545f6d93e13666b07a7aa7d7dc86e6b73a79d7c Mon Sep 17 00:00:00 2001 From: Boutade Date: Sat, 12 Oct 2019 08:56:42 -0500 Subject: audio, controlling space --- the-price-of-a-cup-of-coffee.lisp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'the-price-of-a-cup-of-coffee.lisp') 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)) -- cgit v1.2.3