From 485e401435dd0c9d443299cb04b1576e0f15f43f Mon Sep 17 00:00:00 2001
From: jsancho <devnull@localhost>
Date: Sat, 22 Aug 2009 11:55:56 +0000
Subject: [PATCH]

---
 gacela_draw.lisp   | 13 +++++++++----
 gacela_tetris.lisp |  4 ++--
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/gacela_draw.lisp b/gacela_draw.lisp
index feaf0c3..5e93e77 100644
--- a/gacela_draw.lisp
+++ b/gacela_draw.lisp
@@ -56,7 +56,9 @@
 (defun draw-image-function (filename)
   (multiple-value-bind
    (texture width height) (load-texture filename)
-        (cond (texture))))
+        (cond (texture
+	       (lambda (&optional (f 0.0172))
+		 (draw-rectangle (* f width) (* f height) :texture texture))))))
 
 (defun draw-quad (v1 v2 v3 v4 &key texture color)
   (cond (texture (glBindTexture GL_TEXTURE_2D texture)
@@ -69,9 +71,12 @@
 	(t (cond (color (draw-color color)))
 	   (draw v1 v2 v3 v4))))
 
-(defun draw-square (&key size texture color)
-  (let ((-size (neg size)))
-    (draw-quad (list -size size 0) (list size size 0) (list size -size 0) (list -size -size 0) :texture texture :color color)))
+(defun draw-rectangle (width height &key texture color)
+  (let* ((w (/ width 2)) (-w (neg w)) (h (/ height 2)) (-h (neg h)))
+    (draw-quad (list -w h 0) (list w h 0) (list w -h 0) (list -w -h 0) :texture texture :color color)))
+
+(defun draw-square (&key (size 1) texture color)
+  (draw-rectangle size size :texture texture :color color))
 
 (defun draw-cube (&key size texture color)
   (let ((-size (neg size)))
diff --git a/gacela_tetris.lisp b/gacela_tetris.lisp
index 4bd3819..3397a91 100644
--- a/gacela_tetris.lisp
+++ b/gacela_tetris.lisp
@@ -103,7 +103,7 @@
       (next (random-tetramine))
       (timer (make-timer))
       (grid (make-list 20 :initial-element (make-list 14)))
-      (texture (load-texture "fondo_tetris.png")))
+      (background (draw-image-function "fondo_tetris.png")))
   (defun tetramine ()
     (cond ((eq (timer-state timer) 'stopped) (start-timer timer)))
 
@@ -129,7 +129,7 @@
 		  (setq next (random-tetramine)))
 		 (t (incf y) (start-timer timer)))))
 
-    (draw-square :size 20 :texture texture)))
+    (funcall background 0.086)))
 ;    (translate -25 19)
 ;    (draw-grid (join-grids tetramine grid x y))
 ;    (translate 40 40)
-- 
2.39.5