]> git.jsancho.org Git - gacela.git/commitdiff
(no commit message)
authorjsancho <devnull@localhost>
Tue, 26 Oct 2010 19:09:57 +0000 (19:09 +0000)
committerjsancho <devnull@localhost>
Tue, 26 Oct 2010 19:09:57 +0000 (19:09 +0000)
gacela.lisp
gacela_sound.lisp

index f174a48a53179c1bada10dfab85a2b707a146332..299ab90b9a21b328337bde69d2a8b598a5742b4d 100644 (file)
 (defun make-resource-sound (&key filename)
   `(:type sound :filename ,filename))
 
+(defun make-resource-music (&key filename)
+  `(:type music :filename ,filename))
+
 (defmacro get-rtime (key)
   `(resource-time (gethash ,key resources-table)))
 
index e0cdf56137b1d216efd3640bac3ab60738a68b86..e1a4c9b2db3de4973c5890d3822aa6615d8e176a 100644 (file)
                         :static static)
           key))))
 
+(defun play-sound (sound &optional (loops 0))
+  (let ((id-sound (getf (get-resource sound) :id-sound)))
+    (/= (Mix_PlayChannel -1 id-sound loops) -1)))
+
+(defun load-music (filename &key static)
+  (let ((key (make-resource-music :filename filename)))
+    (cond ((get-resource key) key)
+         (t (true-load-music filename static)))))
+
+(defun true-load-music (filename static)
+  (init-audio)
+  (let ((key (make-resource-music :filename filename))
+       (music (Mix_LoadMUS filename)))
+    (cond ((/= music 0)
+          (set-resource key
+                        `(:id-music ,music)
+                        (lambda () (true-load-music filename static))
+                        (lambda () (Mix_FreeMusic music))
+                        :static static)
+          key))))
+
+(defun playing-music? ()
+  (/= (Mix_PlayingMusic) 0))
+
+(defun play-music (music &optional (loops -1))
+  (cond ((not (playing-music?))
+        (let ((id-music (getf (get-resource music) :id-music)))
+          (/= (Mix_PlayMusic id-music loops) -1)))))