From b56cc2e7d421a067fbdcd3a542908fe0617352b8 Mon Sep 17 00:00:00 2001 From: jsancho Date: Wed, 2 Sep 2009 16:10:47 +0000 Subject: [PATCH] --- gacela.lisp | 14 ++++++++------ gacela_tetris.lisp | 15 ++++++++------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/gacela.lisp b/gacela.lisp index 4dc430a..b7ad4e3 100644 --- a/gacela.lisp +++ b/gacela.lisp @@ -22,8 +22,7 @@ (defvar *height-screen* 480) (defvar *bpp-screen* 32) (defvar *title-screen* "Happy Hacking!!") -(defvar *frames-per-second* 30) -;(defvar *gacela-freq* 100) +(defvar *frames-per-second* 20) (defvar *transparent-color* '(:red 0 :green 0 :blue 0)) (defvar *background-color* '(:red 0 :green 0 :blue 0)) @@ -349,21 +348,24 @@ (eval (read-from-string (concatenate 'string "(progn " (car comlst) ")"))))))) (run-com running))))))) +(let ((gacela-timer (make-timer))) + (defun start-gacela-timer () (start-timer gacela-timer)) + (defun get-gacela-time () (get-time gacela-timer))) + (defmacro run-game (title &body code) - `(let ((fpstemp (make-timer))) + `(progn (init-video-mode) (SDL_WM_SetCaption ,title "") (process-events) (do () ((quit?)) - (start-timer fpstemp) + (start-gacela-timer) (glClear (+ GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) (glLoadIdentity) ,@code (SDL_GL_SwapBuffers) - (let ((frame-time (get-time fpstemp)) (time-per-frame (/ 1000.0 *frames-per-second*))) + (let ((frame-time (get-gacela-time)) (time-per-frame (/ 1000.0 *frames-per-second*))) (cond ((< frame-time time-per-frame) (SDL_Delay (- time-per-frame frame-time))))) -; (SDL_Delay (- *gacela-freq* (rem (SDL_GetTicks) *gacela-freq*))) (process-events) (setq running nil)))) diff --git a/gacela_tetris.lisp b/gacela_tetris.lisp index 6a0242f..6403e2c 100644 --- a/gacela_tetris.lisp +++ b/gacela_tetris.lisp @@ -1,5 +1,7 @@ (in-package :gacela) +(setq *frames-per-second* 15) + (defun tetramine-i () (let ((color '(1 0 0))) `((,color ,color ,color ,color)))) @@ -101,7 +103,7 @@ (next (random-tetramine)) (timer (make-timer)) (grid (make-list 20 :initial-element (make-list 14))) - (background (draw-image-function "fondo_tetris.png"))) + (background (draw-image-function "fondo_tetris2.png"))) (defun tetramine () (cond ((eq (timer-state timer) 'stopped) (start-timer timer))) @@ -127,12 +129,11 @@ (setq next (random-tetramine))) (t (incf y) (start-timer timer))))) -; (draw-square :size 200))) - (funcall background))) -; (translate -288 218) -; (draw-grid (join-grids tetramine grid x y)) -; (translate 440 440) -; (draw-grid next))) + (funcall background) + (translate -288 218) + (draw-grid (join-grids tetramine grid x y)) + (translate 440 440) + (draw-grid next))) (let ((frame 0.0) (fps (make-timer)) (update (make-timer))) (start-timer update) -- 2.39.5