defun-games / claylib

A Common Lisp 2D/3D game toolkit built on top of Raylib 4.5.
zlib License
69 stars 4 forks source link

Add text example 1 #33

Closed mjkalyan closed 2 years ago

mjkalyan commented 2 years ago

Includes minor updates to other examples to make them use the new make-font-asset and claylib-path.

mjkalyan commented 2 years ago

Whoops I just noticed this isn't quite right. To correct it I could do this:

@@ -36,10 +36,10 @@
   "Set sizes & positions for each text in TEXTS so they are arranged in order on the screen."
   (loop for text in texts
         for i from 0
-        do (setf (size text) (* 2 (size text))
+        do (setf (size text) (* 2 (claylib/ll:font.base-size (claylib::c-struct (font text))))
                  (x text) (- (/ (get-screen-width) 2)
                              (/ (x (measure-text-ex text)) 2))
-                 (y text) (+ 60 (size text) (* 45 i)))
+                 (y text) (+ 60 (claylib/ll:font.base-size (claylib::c-struct (font text))) (* 45 i)))

But how do you feel about setting a text's %font-size to the baseSize of its %font when :font is given to make-text? I can't see anything wrong with that off the top of my head.

EDIT: NEVERMIND! If I wanted to make-text with the right size I could do (make-text :size (size font). Thanks defcreader... Fixed in https://github.com/defun-games/claylib/pull/33/commits/dbb5496f1a74c62d04591993fe7db69af2e3bd36 and should be ready to merge.

shelvick commented 2 years ago

Yep, on rare occasions we actually get to use the C values directly. :-) This looks good, just fix up the measure-text-ex pass-through and it should be ready to merge.

mjkalyan commented 2 years ago

Fixed measure-text-ex. You can just merge this and if we find better names I can add them separately.