From: jsancho Date: Sun, 25 Oct 2009 10:03:38 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=313f0f55db1767306751807b41bf3ca125909ea0;p=gacela.git --- diff --git a/gacela.lisp b/gacela.lisp index eecc489..6597f78 100644 --- a/gacela.lisp +++ b/gacela.lisp @@ -153,8 +153,8 @@ (defun make-resource-texture (&key filename min-filter mag-filter) `(:type texture :filename ,filename :min-filter ,min-filter :mag-filter ,mag-filter)) -(defun make-resource-font (&key filename size encoding) - `(:type font :filename ,filename :size ,size :enconding ,encoding)) +(defun make-resource-font (&key filename encoding) + `(:type font :filename ,filename :enconding ,encoding)) (let ((resources-table (make-hash-table :test 'equal))) diff --git a/gacela_tetris.lisp b/gacela_tetris.lisp index a89d138..aadcb52 100644 --- a/gacela_tetris.lisp +++ b/gacela_tetris.lisp @@ -99,12 +99,16 @@ (t (fill (cons (make-list 14) grid) (- n 1)))))) (fill res (- 20 (length res)))))) +(let ((points 0)) + (defun get-points () + points)) + (let ((tetramine (random-tetramine)) (x 6) (y 0) (next (random-tetramine)) (timer (make-timer)) (grid (make-list 20 :initial-element (make-list 14))) (background (draw-image-function "fondo_tetris.png")) - (font (load-font "lazy.ttf"))) + (font (load-font "lazy.ttf" :size 20))) (defun tetramine () (cond ((eq (timer-state timer) 'stopped) (start-timer timer))) diff --git a/gacela_ttf.lisp b/gacela_ttf.lisp index 3cb8493..f0e21a2 100644 --- a/gacela_ttf.lisp +++ b/gacela_ttf.lisp @@ -16,23 +16,27 @@ (in-package :gacela) -(defun load-font (font-file &key (size 80) (encoding ft_encoding_unicode) static) - (let ((key (make-resource-font :filename font-file :size size :encoding encoding))) - (cond ((get-resource key) key) +(defun load-font (font-file &key (size 40) (encoding ft_encoding_unicode) static) + (let* ((key (make-resource-font :filename font-file :encoding encoding)) + (res (get-resource key))) + (cond (res (ftglSetFontFaceSize (getf res :id-font) size 72) + key) (t (true-load-font font-file size encoding static))))) (defun true-load-font (font-file size encoding static) - (let ((key (make-resource-font :filename font-file :size size :encoding encoding)) + (let ((key (make-resource-font :filename font-file :encoding encoding)) (font (ftglCreateTextureFont font-file))) (cond ((/= font 0) (ftglSetFontFaceSize font size 72) (ftglSetFontCharMap font encoding) (set-resource key `(:id-font ,font) - (lambda () (true-load-font font-file size encoding static)) + (lambda () (true-load-font font-file encoding static)) (lambda () (ftglDestroyFont font)) :static static) key)))) -(defun render-text (text font) - (ftglRenderFont (getf (get-resource font) :id-font) text FTGL_RENDER_ALL)) +(defun render-text (text font &key size) + (let ((id-font (getf (get-resource font) :id-font))) + (cond (size (ftglSetFontFaceSize id-font size 72))) + (ftglRenderFont id-font text FTGL_RENDER_ALL)))