From 983f42814ffe6d78b1958f2c3c0e63852f28d217 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 29 Nov 2025 10:06:33 +0100 Subject: [PATCH] afegides shapes per a fonts --- CMakeLists.txt | 1 + data/shapes/char_0.shp | 25 ----------- data/shapes/char_1.shp | 13 ------ data/shapes/char_2.shp | 22 ---------- data/shapes/char_3.shp | 22 ---------- data/shapes/char_4.shp | 19 --------- data/shapes/char_5.shp | 22 ---------- data/shapes/char_6.shp | 25 ----------- data/shapes/char_7.shp | 16 ------- data/shapes/char_8.shp | 28 ------------- data/shapes/char_9.shp | 25 ----------- data/shapes/char_colon.shp | 12 ------ data/shapes/char_comma.shp | 9 ---- data/shapes/char_dot.shp | 9 ---- data/shapes/char_minus.shp | 9 ---- data/shapes/font/char_0.shp | 10 +++++ data/shapes/font/char_1.shp | 10 +++++ data/shapes/font/char_2.shp | 10 +++++ data/shapes/font/char_3.shp | 11 +++++ data/shapes/font/char_4.shp | 12 ++++++ data/shapes/font/char_5.shp | 10 +++++ data/shapes/font/char_6.shp | 10 +++++ data/shapes/font/char_7.shp | 10 +++++ data/shapes/font/char_8.shp | 12 ++++++ data/shapes/font/char_9.shp | 10 +++++ data/shapes/font/char_A.shp | 11 +++++ data/shapes/font/char_B.shp | 11 +++++ data/shapes/font/char_C.shp | 9 ++++ data/shapes/font/char_D.shp | 9 ++++ data/shapes/font/char_E.shp | 10 +++++ data/shapes/font/char_F.shp | 10 +++++ data/shapes/font/char_G.shp | 9 ++++ data/shapes/font/char_H.shp | 13 ++++++ data/shapes/font/char_I.shp | 9 ++++ data/shapes/font/char_J.shp | 9 ++++ data/shapes/font/char_K.shp | 13 ++++++ data/shapes/font/char_L.shp | 9 ++++ data/shapes/font/char_M.shp | 9 ++++ data/shapes/font/char_N.shp | 9 ++++ data/shapes/font/char_O.shp | 9 ++++ data/shapes/font/char_P.shp | 11 +++++ data/shapes/font/char_Q.shp | 11 +++++ data/shapes/font/char_R.shp | 13 ++++++ data/shapes/font/char_S.shp | 9 ++++ data/shapes/font/char_T.shp | 11 +++++ data/shapes/font/char_U.shp | 9 ++++ data/shapes/font/char_V.shp | 9 ++++ data/shapes/font/char_W.shp | 9 ++++ data/shapes/font/char_X.shp | 11 +++++ data/shapes/font/char_Y.shp | 12 ++++++ data/shapes/font/char_Z.shp | 9 ++++ data/shapes/font/char_colon.shp | 11 +++++ data/shapes/font/char_comma.shp | 9 ++++ data/shapes/font/char_dot.shp | 9 ++++ data/shapes/font/char_exclamation.shp | 11 +++++ data/shapes/font/char_minus.shp | 9 ++++ data/shapes/font/char_question.shp | 11 +++++ data/shapes/font/char_space.shp | 9 ++++ data/shapes/{ => logo}/letra_a.shp | 0 data/shapes/{ => logo}/letra_e.shp | 0 data/shapes/{ => logo}/letra_g.shp | 0 data/shapes/{ => logo}/letra_i.shp | 0 data/shapes/{ => logo}/letra_j.shp | 0 data/shapes/{ => logo}/letra_l.shp | 0 data/shapes/{ => logo}/letra_m.shp | 0 data/shapes/{ => logo}/letra_s.shp | 0 source/game/escenes/escena_logo.cpp | 4 +- source/utils/text_renderer.cpp | 60 +++++++++++++++++++++++++++ source/utils/text_renderer.hpp | 30 ++++++++++++++ 69 files changed, 530 insertions(+), 258 deletions(-) delete mode 100644 data/shapes/char_0.shp delete mode 100644 data/shapes/char_1.shp delete mode 100644 data/shapes/char_2.shp delete mode 100644 data/shapes/char_3.shp delete mode 100644 data/shapes/char_4.shp delete mode 100644 data/shapes/char_5.shp delete mode 100644 data/shapes/char_6.shp delete mode 100644 data/shapes/char_7.shp delete mode 100644 data/shapes/char_8.shp delete mode 100644 data/shapes/char_9.shp delete mode 100644 data/shapes/char_colon.shp delete mode 100644 data/shapes/char_comma.shp delete mode 100644 data/shapes/char_dot.shp delete mode 100644 data/shapes/char_minus.shp create mode 100644 data/shapes/font/char_0.shp create mode 100644 data/shapes/font/char_1.shp create mode 100644 data/shapes/font/char_2.shp create mode 100644 data/shapes/font/char_3.shp create mode 100644 data/shapes/font/char_4.shp create mode 100644 data/shapes/font/char_5.shp create mode 100644 data/shapes/font/char_6.shp create mode 100644 data/shapes/font/char_7.shp create mode 100644 data/shapes/font/char_8.shp create mode 100644 data/shapes/font/char_9.shp create mode 100644 data/shapes/font/char_A.shp create mode 100644 data/shapes/font/char_B.shp create mode 100644 data/shapes/font/char_C.shp create mode 100644 data/shapes/font/char_D.shp create mode 100644 data/shapes/font/char_E.shp create mode 100644 data/shapes/font/char_F.shp create mode 100644 data/shapes/font/char_G.shp create mode 100644 data/shapes/font/char_H.shp create mode 100644 data/shapes/font/char_I.shp create mode 100644 data/shapes/font/char_J.shp create mode 100644 data/shapes/font/char_K.shp create mode 100644 data/shapes/font/char_L.shp create mode 100644 data/shapes/font/char_M.shp create mode 100644 data/shapes/font/char_N.shp create mode 100644 data/shapes/font/char_O.shp create mode 100644 data/shapes/font/char_P.shp create mode 100644 data/shapes/font/char_Q.shp create mode 100644 data/shapes/font/char_R.shp create mode 100644 data/shapes/font/char_S.shp create mode 100644 data/shapes/font/char_T.shp create mode 100644 data/shapes/font/char_U.shp create mode 100644 data/shapes/font/char_V.shp create mode 100644 data/shapes/font/char_W.shp create mode 100644 data/shapes/font/char_X.shp create mode 100644 data/shapes/font/char_Y.shp create mode 100644 data/shapes/font/char_Z.shp create mode 100644 data/shapes/font/char_colon.shp create mode 100644 data/shapes/font/char_comma.shp create mode 100644 data/shapes/font/char_dot.shp create mode 100644 data/shapes/font/char_exclamation.shp create mode 100644 data/shapes/font/char_minus.shp create mode 100644 data/shapes/font/char_question.shp create mode 100644 data/shapes/font/char_space.shp rename data/shapes/{ => logo}/letra_a.shp (100%) rename data/shapes/{ => logo}/letra_e.shp (100%) rename data/shapes/{ => logo}/letra_g.shp (100%) rename data/shapes/{ => logo}/letra_i.shp (100%) rename data/shapes/{ => logo}/letra_j.shp (100%) rename data/shapes/{ => logo}/letra_l.shp (100%) rename data/shapes/{ => logo}/letra_m.shp (100%) rename data/shapes/{ => logo}/letra_s.shp (100%) create mode 100644 source/utils/text_renderer.cpp create mode 100644 source/utils/text_renderer.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index eef6346..6c03243 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ set(APP_SOURCES source/game/entities/nau.cpp source/game/entities/bala.cpp source/game/entities/enemic.cpp + source/utils/text_renderer.cpp ) # Configuración de SDL3 diff --git a/data/shapes/char_0.shp b/data/shapes/char_0.shp deleted file mode 100644 index b954940..0000000 --- a/data/shapes/char_0.shp +++ /dev/null @@ -1,25 +0,0 @@ -# char_0.shp - Dígito 0 -# Display de 7 segmentos: a,b,c,e,f,g (sin d) -# Dimensiones: 10×20 (escalable) - -name: char_0 -scale: 1.0 -center: 5, 10 - -# Segmento a (horizontal superior) -line: 1,0 9,0 - -# Segmento b (vertical izquierda superior) -line: 0,1 0,9 - -# Segmento c (vertical derecha superior) -line: 10,1 10,9 - -# Segmento e (vertical izquierda inferior) -line: 0,11 0,19 - -# Segmento f (vertical derecha inferior) -line: 10,11 10,19 - -# Segmento g (horizontal inferior) -line: 1,20 9,20 diff --git a/data/shapes/char_1.shp b/data/shapes/char_1.shp deleted file mode 100644 index b9a5847..0000000 --- a/data/shapes/char_1.shp +++ /dev/null @@ -1,13 +0,0 @@ -# char_1.shp - Dígito 1 -# Display de 7 segmentos: c,f -# Dimensiones: 10×20 (escalable) - -name: char_1 -scale: 1.0 -center: 5, 10 - -# Segmento c (vertical derecha superior) -line: 10,1 10,9 - -# Segmento f (vertical derecha inferior) -line: 10,11 10,19 diff --git a/data/shapes/char_2.shp b/data/shapes/char_2.shp deleted file mode 100644 index 2cc43cb..0000000 --- a/data/shapes/char_2.shp +++ /dev/null @@ -1,22 +0,0 @@ -# char_2.shp - Dígito 2 -# Display de 7 segmentos: a,c,d,e,g -# Dimensiones: 10×20 (escalable) - -name: char_2 -scale: 1.0 -center: 5, 10 - -# Segmento a (horizontal superior) -line: 1,0 9,0 - -# Segmento c (vertical derecha superior) -line: 10,1 10,9 - -# Segmento d (horizontal medio) -line: 1,10 9,10 - -# Segmento e (vertical izquierda inferior) -line: 0,11 0,19 - -# Segmento g (horizontal inferior) -line: 1,20 9,20 diff --git a/data/shapes/char_3.shp b/data/shapes/char_3.shp deleted file mode 100644 index 7205699..0000000 --- a/data/shapes/char_3.shp +++ /dev/null @@ -1,22 +0,0 @@ -# char_3.shp - Dígito 3 -# Display de 7 segmentos: a,c,d,f,g -# Dimensiones: 10×20 (escalable) - -name: char_3 -scale: 1.0 -center: 5, 10 - -# Segmento a (horizontal superior) -line: 1,0 9,0 - -# Segmento c (vertical derecha superior) -line: 10,1 10,9 - -# Segmento d (horizontal medio) -line: 1,10 9,10 - -# Segmento f (vertical derecha inferior) -line: 10,11 10,19 - -# Segmento g (horizontal inferior) -line: 1,20 9,20 diff --git a/data/shapes/char_4.shp b/data/shapes/char_4.shp deleted file mode 100644 index 91fc6de..0000000 --- a/data/shapes/char_4.shp +++ /dev/null @@ -1,19 +0,0 @@ -# char_4.shp - Dígito 4 -# Display de 7 segmentos: b,c,d,f -# Dimensiones: 10×20 (escalable) - -name: char_4 -scale: 1.0 -center: 5, 10 - -# Segmento b (vertical izquierda superior) -line: 0,1 0,9 - -# Segmento c (vertical derecha superior) -line: 10,1 10,9 - -# Segmento d (horizontal medio) -line: 1,10 9,10 - -# Segmento f (vertical derecha inferior) -line: 10,11 10,19 diff --git a/data/shapes/char_5.shp b/data/shapes/char_5.shp deleted file mode 100644 index ee9083c..0000000 --- a/data/shapes/char_5.shp +++ /dev/null @@ -1,22 +0,0 @@ -# char_5.shp - Dígito 5 -# Display de 7 segmentos: a,b,d,f,g -# Dimensiones: 10×20 (escalable) - -name: char_5 -scale: 1.0 -center: 5, 10 - -# Segmento a (horizontal superior) -line: 1,0 9,0 - -# Segmento b (vertical izquierda superior) -line: 0,1 0,9 - -# Segmento d (horizontal medio) -line: 1,10 9,10 - -# Segmento f (vertical derecha inferior) -line: 10,11 10,19 - -# Segmento g (horizontal inferior) -line: 1,20 9,20 diff --git a/data/shapes/char_6.shp b/data/shapes/char_6.shp deleted file mode 100644 index 2bf9154..0000000 --- a/data/shapes/char_6.shp +++ /dev/null @@ -1,25 +0,0 @@ -# char_6.shp - Dígito 6 -# Display de 7 segmentos: a,b,d,e,f,g -# Dimensiones: 10×20 (escalable) - -name: char_6 -scale: 1.0 -center: 5, 10 - -# Segmento a (horizontal superior) -line: 1,0 9,0 - -# Segmento b (vertical izquierda superior) -line: 0,1 0,9 - -# Segmento d (horizontal medio) -line: 1,10 9,10 - -# Segmento e (vertical izquierda inferior) -line: 0,11 0,19 - -# Segmento f (vertical derecha inferior) -line: 10,11 10,19 - -# Segmento g (horizontal inferior) -line: 1,20 9,20 diff --git a/data/shapes/char_7.shp b/data/shapes/char_7.shp deleted file mode 100644 index 6646b28..0000000 --- a/data/shapes/char_7.shp +++ /dev/null @@ -1,16 +0,0 @@ -# char_7.shp - Dígito 7 -# Display de 7 segmentos: a,c,f -# Dimensiones: 10×20 (escalable) - -name: char_7 -scale: 1.0 -center: 5, 10 - -# Segmento a (horizontal superior) -line: 1,0 9,0 - -# Segmento c (vertical derecha superior) -line: 10,1 10,9 - -# Segmento f (vertical derecha inferior) -line: 10,11 10,19 diff --git a/data/shapes/char_8.shp b/data/shapes/char_8.shp deleted file mode 100644 index 525f056..0000000 --- a/data/shapes/char_8.shp +++ /dev/null @@ -1,28 +0,0 @@ -# char_8.shp - Dígito 8 -# Display de 7 segmentos: a,b,c,d,e,f,g (todos) -# Dimensiones: 10×20 (escalable) - -name: char_8 -scale: 1.0 -center: 5, 10 - -# Segmento a (horizontal superior) -line: 1,0 9,0 - -# Segmento b (vertical izquierda superior) -line: 0,1 0,9 - -# Segmento c (vertical derecha superior) -line: 10,1 10,9 - -# Segmento d (horizontal medio) -line: 1,10 9,10 - -# Segmento e (vertical izquierda inferior) -line: 0,11 0,19 - -# Segmento f (vertical derecha inferior) -line: 10,11 10,19 - -# Segmento g (horizontal inferior) -line: 1,20 9,20 diff --git a/data/shapes/char_9.shp b/data/shapes/char_9.shp deleted file mode 100644 index d7abe1a..0000000 --- a/data/shapes/char_9.shp +++ /dev/null @@ -1,25 +0,0 @@ -# char_9.shp - Dígito 9 -# Display de 7 segmentos: a,b,c,d,f,g -# Dimensiones: 10×20 (escalable) - -name: char_9 -scale: 1.0 -center: 5, 10 - -# Segmento a (horizontal superior) -line: 1,0 9,0 - -# Segmento b (vertical izquierda superior) -line: 0,1 0,9 - -# Segmento c (vertical derecha superior) -line: 10,1 10,9 - -# Segmento d (horizontal medio) -line: 1,10 9,10 - -# Segmento f (vertical derecha inferior) -line: 10,11 10,19 - -# Segmento g (horizontal inferior) -line: 1,20 9,20 diff --git a/data/shapes/char_colon.shp b/data/shapes/char_colon.shp deleted file mode 100644 index 3130d8b..0000000 --- a/data/shapes/char_colon.shp +++ /dev/null @@ -1,12 +0,0 @@ -# char_colon.shp - Símbolo : (dos puntos) -# Dimensiones: 10×20 (escalable) - -name: char_colon -scale: 1.0 -center: 5, 10 - -# Punto superior (Y=6) -line: 4,6 6,6 - -# Punto inferior (Y=14) -line: 4,14 6,14 diff --git a/data/shapes/char_comma.shp b/data/shapes/char_comma.shp deleted file mode 100644 index 2760384..0000000 --- a/data/shapes/char_comma.shp +++ /dev/null @@ -1,9 +0,0 @@ -# char_comma.shp - Símbolo , (coma) -# Dimensiones: 10×20 (escalable) - -name: char_comma -scale: 1.0 -center: 5, 10 - -# Coma en esquina inferior derecha (con cola hacia abajo) -polyline: 9,18 10,20 diff --git a/data/shapes/char_dot.shp b/data/shapes/char_dot.shp deleted file mode 100644 index 684314c..0000000 --- a/data/shapes/char_dot.shp +++ /dev/null @@ -1,9 +0,0 @@ -# char_dot.shp - Símbolo . (punto) -# Dimensiones: 10×20 (escalable) - -name: char_dot -scale: 1.0 -center: 5, 10 - -# Punto en esquina inferior derecha -line: 9,19 10,20 diff --git a/data/shapes/char_minus.shp b/data/shapes/char_minus.shp deleted file mode 100644 index be49ea0..0000000 --- a/data/shapes/char_minus.shp +++ /dev/null @@ -1,9 +0,0 @@ -# char_minus.shp - Símbolo - (menos/guión) -# Dimensiones: 10×20 (escalable) - -name: char_minus -scale: 1.0 -center: 5, 10 - -# Línea horizontal en el medio -line: 2,10 8,10 diff --git a/data/shapes/font/char_0.shp b/data/shapes/font/char_0.shp new file mode 100644 index 0000000..730403d --- /dev/null +++ b/data/shapes/font/char_0.shp @@ -0,0 +1,10 @@ +# char_0.shp - Dígito 0 +# Dimensiones: 20×40 (blocky display) +# Rectángulo cerrado (polyline continua, NO 6 líneas separadas) + +name: char_0 +scale: 1.0 +center: 10, 20 + +# Rectángulo cerrado +polyline: 2,10 18,10 18,30 2,30 2,10 diff --git a/data/shapes/font/char_1.shp b/data/shapes/font/char_1.shp new file mode 100644 index 0000000..ee91dba --- /dev/null +++ b/data/shapes/font/char_1.shp @@ -0,0 +1,10 @@ +# char_1.shp - Dígito 1 +# Dimensiones: 20×40 (blocky display) +# Línea vertical simple centrada + +name: char_1 +scale: 1.0 +center: 10, 20 + +# Línea vertical central +line: 10,10 10,30 diff --git a/data/shapes/font/char_2.shp b/data/shapes/font/char_2.shp new file mode 100644 index 0000000..9ec6267 --- /dev/null +++ b/data/shapes/font/char_2.shp @@ -0,0 +1,10 @@ +# char_2.shp - Dígito 2 +# Dimensiones: 20×40 (blocky display) +# Forma de "2" con curva simulada (polyline continua) + +name: char_2 +scale: 1.0 +center: 10, 20 + +# Trazo continuo en forma de S achatada +polyline: 2,10 18,10 18,20 2,20 2,30 18,30 diff --git a/data/shapes/font/char_3.shp b/data/shapes/font/char_3.shp new file mode 100644 index 0000000..92bf575 --- /dev/null +++ b/data/shapes/font/char_3.shp @@ -0,0 +1,11 @@ +# char_3.shp - Dígito 3 +# Dimensiones: 20×40 (blocky display) +# Forma de "3" con dos curvas (polylines) + +name: char_3 +scale: 1.0 +center: 10, 20 + +# Trazo continuo (barra superior + lateral derecho + barra media + lateral derecho + barra inferior) +polyline: 2,10 18,10 18,20 14,20 +polyline: 14,20 18,20 18,30 2,30 diff --git a/data/shapes/font/char_4.shp b/data/shapes/font/char_4.shp new file mode 100644 index 0000000..e09527e --- /dev/null +++ b/data/shapes/font/char_4.shp @@ -0,0 +1,12 @@ +# char_4.shp - Dígito 4 +# Dimensiones: 20×40 (blocky display) +# Forma de "4" con líneas continuas + +name: char_4 +scale: 1.0 +center: 10, 20 + +# Trazo principal (vertical izquierda + horizontal + vertical derecha superior) +polyline: 2,10 2,20 18,20 +# Vertical derecha completa (cruza la horizontal) +line: 18,10 18,30 diff --git a/data/shapes/font/char_5.shp b/data/shapes/font/char_5.shp new file mode 100644 index 0000000..ea82063 --- /dev/null +++ b/data/shapes/font/char_5.shp @@ -0,0 +1,10 @@ +# char_5.shp - Dígito 5 +# Dimensiones: 20×40 (blocky display) +# Forma de "5" con curva (polyline continua) + +name: char_5 +scale: 1.0 +center: 10, 20 + +# Trazo continuo en forma de S invertida +polyline: 18,10 2,10 2,20 18,20 18,30 2,30 diff --git a/data/shapes/font/char_6.shp b/data/shapes/font/char_6.shp new file mode 100644 index 0000000..36b02be --- /dev/null +++ b/data/shapes/font/char_6.shp @@ -0,0 +1,10 @@ +# char_6.shp - Dígito 6 +# Dimensiones: 20×40 (blocky display) +# Forma de "6" con espiral (polyline continua) + +name: char_6 +scale: 1.0 +center: 10, 20 + +# Trazo continuo: barra superior + lateral izquierdo + barra media + lateral derecho inferior + barra inferior + cierre +polyline: 18,10 2,10 2,30 18,30 18,20 2,20 diff --git a/data/shapes/font/char_7.shp b/data/shapes/font/char_7.shp new file mode 100644 index 0000000..5a5a1ea --- /dev/null +++ b/data/shapes/font/char_7.shp @@ -0,0 +1,10 @@ +# char_7.shp - Dígito 7 +# Dimensiones: 20×40 (blocky display) +# Línea horizontal superior + diagonal hacia abajo-derecha + +name: char_7 +scale: 1.0 +center: 10, 20 + +# Barra superior + diagonal +polyline: 2,10 18,10 18,30 diff --git a/data/shapes/font/char_8.shp b/data/shapes/font/char_8.shp new file mode 100644 index 0000000..8471765 --- /dev/null +++ b/data/shapes/font/char_8.shp @@ -0,0 +1,12 @@ +# char_8.shp - Dígito 8 +# Dimensiones: 20×40 (blocky display) +# Dos rectángulos apilados (polylines continuas) + +name: char_8 +scale: 1.0 +center: 10, 20 + +# Rectángulo superior +polyline: 2,10 18,10 18,20 2,20 2,10 +# Rectángulo inferior (comparte borde con el superior) +polyline: 2,20 18,20 18,30 2,30 2,20 diff --git a/data/shapes/font/char_9.shp b/data/shapes/font/char_9.shp new file mode 100644 index 0000000..0e93e2e --- /dev/null +++ b/data/shapes/font/char_9.shp @@ -0,0 +1,10 @@ +# char_9.shp - Dígito 9 +# Dimensiones: 20×40 (blocky display) +# Forma de "9" con espiral (polyline continua) + +name: char_9 +scale: 1.0 +center: 10, 20 + +# Trazo continuo: lateral derecho completo + barra superior + lateral izquierdo superior + barra media +polyline: 18,30 18,10 2,10 2,20 18,20 diff --git a/data/shapes/font/char_A.shp b/data/shapes/font/char_A.shp new file mode 100644 index 0000000..d50b1a4 --- /dev/null +++ b/data/shapes/font/char_A.shp @@ -0,0 +1,11 @@ +# char_A.shp - Letra A +# Dimensiones: 20×40 (blocky display) + +name: char_A +scale: 1.0 +center: 10, 20 + +# Forma triangular (dos diagonales hacia arriba) +polyline: 2,30 10,10 18,30 +# Barra horizontal media +line: 5,22 15,22 diff --git a/data/shapes/font/char_B.shp b/data/shapes/font/char_B.shp new file mode 100644 index 0000000..9efcd3e --- /dev/null +++ b/data/shapes/font/char_B.shp @@ -0,0 +1,11 @@ +# char_B.shp - Letra B +# Dimensiones: 20×40 (blocky display) + +name: char_B +scale: 1.0 +center: 10, 20 + +# Rectángulo superior +polyline: 2,10 14,10 14,20 2,20 2,10 +# Rectángulo inferior (más ancho) +polyline: 2,20 16,20 16,30 2,30 2,20 diff --git a/data/shapes/font/char_C.shp b/data/shapes/font/char_C.shp new file mode 100644 index 0000000..c0e8298 --- /dev/null +++ b/data/shapes/font/char_C.shp @@ -0,0 +1,9 @@ +# char_C.shp - Letra C +# Dimensiones: 20×40 (blocky display) + +name: char_C +scale: 1.0 +center: 10, 20 + +# Curva simulada (semicírculo abierto a la derecha) +polyline: 18,12 14,10 6,10 2,14 2,26 6,30 14,30 18,28 diff --git a/data/shapes/font/char_D.shp b/data/shapes/font/char_D.shp new file mode 100644 index 0000000..4067c96 --- /dev/null +++ b/data/shapes/font/char_D.shp @@ -0,0 +1,9 @@ +# char_D.shp - Letra D +# Dimensiones: 20×40 (blocky display) + +name: char_D +scale: 1.0 +center: 10, 20 + +# Vertical izquierda + curva derecha simulada +polyline: 2,10 14,10 18,14 18,26 14,30 2,30 2,10 diff --git a/data/shapes/font/char_E.shp b/data/shapes/font/char_E.shp new file mode 100644 index 0000000..e584e1a --- /dev/null +++ b/data/shapes/font/char_E.shp @@ -0,0 +1,10 @@ +# char_E.shp - Letra E +# Dimensiones: 20×40 (blocky display) + +name: char_E +scale: 1.0 +center: 10, 20 + +# Forma de E (vertical izquierda + 3 horizontales) +polyline: 18,10 2,10 2,30 18,30 +line: 2,20 14,20 diff --git a/data/shapes/font/char_F.shp b/data/shapes/font/char_F.shp new file mode 100644 index 0000000..b4eb850 --- /dev/null +++ b/data/shapes/font/char_F.shp @@ -0,0 +1,10 @@ +# char_F.shp - Letra F +# Dimensiones: 20×40 (blocky display) + +name: char_F +scale: 1.0 +center: 10, 20 + +# Vertical izquierda + barra superior + barra media +polyline: 2,30 2,10 18,10 +line: 2,20 14,20 diff --git a/data/shapes/font/char_G.shp b/data/shapes/font/char_G.shp new file mode 100644 index 0000000..f5fbe95 --- /dev/null +++ b/data/shapes/font/char_G.shp @@ -0,0 +1,9 @@ +# char_G.shp - Letra G +# Dimensiones: 20×40 (blocky display) + +name: char_G +scale: 1.0 +center: 10, 20 + +# Como C pero con barra horizontal hacia adentro +polyline: 18,12 14,10 6,10 2,14 2,26 6,30 14,30 18,28 18,20 12,20 diff --git a/data/shapes/font/char_H.shp b/data/shapes/font/char_H.shp new file mode 100644 index 0000000..a580ba8 --- /dev/null +++ b/data/shapes/font/char_H.shp @@ -0,0 +1,13 @@ +# char_H.shp - Letra H +# Dimensiones: 20×40 (blocky display) + +name: char_H +scale: 1.0 +center: 10, 20 + +# Vertical izquierda +line: 2,10 2,30 +# Vertical derecha +line: 18,10 18,30 +# Barra media +line: 2,20 18,20 diff --git a/data/shapes/font/char_I.shp b/data/shapes/font/char_I.shp new file mode 100644 index 0000000..6f62d73 --- /dev/null +++ b/data/shapes/font/char_I.shp @@ -0,0 +1,9 @@ +# char_I.shp - Letra I +# Dimensiones: 20×40 (blocky display) + +name: char_I +scale: 1.0 +center: 10, 20 + +# Línea vertical central +line: 10,10 10,30 diff --git a/data/shapes/font/char_J.shp b/data/shapes/font/char_J.shp new file mode 100644 index 0000000..a6ee800 --- /dev/null +++ b/data/shapes/font/char_J.shp @@ -0,0 +1,9 @@ +# char_J.shp - Letra J +# Dimensiones: 20×40 (blocky display) + +name: char_J +scale: 1.0 +center: 10, 20 + +# Vertical derecha con curva abajo-izquierda +polyline: 18,10 18,26 14,30 6,30 2,26 diff --git a/data/shapes/font/char_K.shp b/data/shapes/font/char_K.shp new file mode 100644 index 0000000..6e1c77c --- /dev/null +++ b/data/shapes/font/char_K.shp @@ -0,0 +1,13 @@ +# char_K.shp - Letra K +# Dimensiones: 20×40 (blocky display) + +name: char_K +scale: 1.0 +center: 10, 20 + +# Vertical izquierda +line: 2,10 2,30 +# Diagonal superior +line: 18,10 2,20 +# Diagonal inferior +line: 2,20 18,30 diff --git a/data/shapes/font/char_L.shp b/data/shapes/font/char_L.shp new file mode 100644 index 0000000..32dd285 --- /dev/null +++ b/data/shapes/font/char_L.shp @@ -0,0 +1,9 @@ +# char_L.shp - Letra L +# Dimensiones: 20×40 (blocky display) + +name: char_L +scale: 1.0 +center: 10, 20 + +# Forma de L (vertical izquierda + horizontal abajo) +polyline: 2,10 2,30 18,30 diff --git a/data/shapes/font/char_M.shp b/data/shapes/font/char_M.shp new file mode 100644 index 0000000..a69f8c0 --- /dev/null +++ b/data/shapes/font/char_M.shp @@ -0,0 +1,9 @@ +# char_M.shp - Letra M +# Dimensiones: 20×40 (blocky display) + +name: char_M +scale: 1.0 +center: 10, 20 + +# Forma de M con pico en el medio +polyline: 2,30 2,10 10,20 18,10 18,30 diff --git a/data/shapes/font/char_N.shp b/data/shapes/font/char_N.shp new file mode 100644 index 0000000..241d46d --- /dev/null +++ b/data/shapes/font/char_N.shp @@ -0,0 +1,9 @@ +# char_N.shp - Letra N +# Dimensiones: 20×40 (blocky display) + +name: char_N +scale: 1.0 +center: 10, 20 + +# Vertical izquierda + diagonal + vertical derecha +polyline: 2,30 2,10 18,30 18,10 diff --git a/data/shapes/font/char_O.shp b/data/shapes/font/char_O.shp new file mode 100644 index 0000000..648f95e --- /dev/null +++ b/data/shapes/font/char_O.shp @@ -0,0 +1,9 @@ +# char_O.shp - Letra O +# Dimensiones: 20×40 (blocky display) + +name: char_O +scale: 1.0 +center: 10, 20 + +# Rectángulo cerrado +polyline: 2,10 18,10 18,30 2,30 2,10 diff --git a/data/shapes/font/char_P.shp b/data/shapes/font/char_P.shp new file mode 100644 index 0000000..0acac3d --- /dev/null +++ b/data/shapes/font/char_P.shp @@ -0,0 +1,11 @@ +# char_P.shp - Letra P +# Dimensiones: 20×40 (blocky display) + +name: char_P +scale: 1.0 +center: 10, 20 + +# Vertical izquierda completa +line: 2,10 2,30 +# Rectángulo superior cerrado +polyline: 2,10 14,10 14,20 2,20 diff --git a/data/shapes/font/char_Q.shp b/data/shapes/font/char_Q.shp new file mode 100644 index 0000000..0e5b150 --- /dev/null +++ b/data/shapes/font/char_Q.shp @@ -0,0 +1,11 @@ +# char_Q.shp - Letra Q +# Dimensiones: 20×40 (blocky display) + +name: char_Q +scale: 1.0 +center: 10, 20 + +# Rectángulo cerrado (como O) +polyline: 2,10 18,10 18,30 2,30 2,10 +# Diagonal inferior derecha (cola de la Q) +line: 12,24 18,30 diff --git a/data/shapes/font/char_R.shp b/data/shapes/font/char_R.shp new file mode 100644 index 0000000..0d2e682 --- /dev/null +++ b/data/shapes/font/char_R.shp @@ -0,0 +1,13 @@ +# char_R.shp - Letra R +# Dimensiones: 20×40 (blocky display) + +name: char_R +scale: 1.0 +center: 10, 20 + +# Vertical izquierda completa +line: 2,10 2,30 +# Rectángulo superior cerrado +polyline: 2,10 14,10 14,20 2,20 +# Diagonal inferior derecha +line: 8,20 18,30 diff --git a/data/shapes/font/char_S.shp b/data/shapes/font/char_S.shp new file mode 100644 index 0000000..0515d73 --- /dev/null +++ b/data/shapes/font/char_S.shp @@ -0,0 +1,9 @@ +# char_S.shp - Letra S +# Dimensiones: 20×40 (blocky display) + +name: char_S +scale: 1.0 +center: 10, 20 + +# Forma de S con curvas simuladas +polyline: 18,12 14,10 6,10 2,14 2,18 6,20 14,20 18,22 18,26 14,30 6,30 2,28 diff --git a/data/shapes/font/char_T.shp b/data/shapes/font/char_T.shp new file mode 100644 index 0000000..359641a --- /dev/null +++ b/data/shapes/font/char_T.shp @@ -0,0 +1,11 @@ +# char_T.shp - Letra T +# Dimensiones: 20×40 (blocky display) + +name: char_T +scale: 1.0 +center: 10, 20 + +# Barra horizontal superior +line: 2,10 18,10 +# Línea vertical central +line: 10,10 10,30 diff --git a/data/shapes/font/char_U.shp b/data/shapes/font/char_U.shp new file mode 100644 index 0000000..e61f36b --- /dev/null +++ b/data/shapes/font/char_U.shp @@ -0,0 +1,9 @@ +# char_U.shp - Letra U +# Dimensiones: 20×40 (blocky display) + +name: char_U +scale: 1.0 +center: 10, 20 + +# Forma de U (dos verticales + curva abajo) +polyline: 2,10 2,26 6,30 14,30 18,26 18,10 diff --git a/data/shapes/font/char_V.shp b/data/shapes/font/char_V.shp new file mode 100644 index 0000000..6912cbc --- /dev/null +++ b/data/shapes/font/char_V.shp @@ -0,0 +1,9 @@ +# char_V.shp - Letra V +# Dimensiones: 20×40 (blocky display) + +name: char_V +scale: 1.0 +center: 10, 20 + +# Forma de V (dos diagonales hacia abajo) +polyline: 2,10 10,30 18,10 diff --git a/data/shapes/font/char_W.shp b/data/shapes/font/char_W.shp new file mode 100644 index 0000000..3bc9c16 --- /dev/null +++ b/data/shapes/font/char_W.shp @@ -0,0 +1,9 @@ +# char_W.shp - Letra W +# Dimensiones: 20×40 (blocky display) + +name: char_W +scale: 1.0 +center: 10, 20 + +# Forma de W (doble V) +polyline: 2,10 5,30 10,20 15,30 18,10 diff --git a/data/shapes/font/char_X.shp b/data/shapes/font/char_X.shp new file mode 100644 index 0000000..4a938d4 --- /dev/null +++ b/data/shapes/font/char_X.shp @@ -0,0 +1,11 @@ +# char_X.shp - Letra X +# Dimensiones: 20×40 (blocky display) + +name: char_X +scale: 1.0 +center: 10, 20 + +# Diagonal \ +line: 2,10 18,30 +# Diagonal / +line: 18,10 2,30 diff --git a/data/shapes/font/char_Y.shp b/data/shapes/font/char_Y.shp new file mode 100644 index 0000000..a40d98d --- /dev/null +++ b/data/shapes/font/char_Y.shp @@ -0,0 +1,12 @@ +# char_Y.shp - Letra Y +# Dimensiones: 20×40 (blocky display) + +name: char_Y +scale: 1.0 +center: 10, 20 + +# Dos diagonales superiores que se juntan +polyline: 2,10 10,20 +polyline: 18,10 10,20 +# Línea vertical inferior +line: 10,20 10,30 diff --git a/data/shapes/font/char_Z.shp b/data/shapes/font/char_Z.shp new file mode 100644 index 0000000..4b0be85 --- /dev/null +++ b/data/shapes/font/char_Z.shp @@ -0,0 +1,9 @@ +# char_Z.shp - Letra Z +# Dimensiones: 20×40 (blocky display) + +name: char_Z +scale: 1.0 +center: 10, 20 + +# Barra superior + diagonal + barra inferior +polyline: 2,10 18,10 2,30 18,30 diff --git a/data/shapes/font/char_colon.shp b/data/shapes/font/char_colon.shp new file mode 100644 index 0000000..8a6436d --- /dev/null +++ b/data/shapes/font/char_colon.shp @@ -0,0 +1,11 @@ +# char_colon.shp - Símbolo : (dos puntos) +# Dimensiones: 20×40 (blocky display) + +name: char_colon +scale: 1.0 +center: 10, 20 + +# Punto superior +polyline: 8,14 12,14 12,17 8,17 8,14 +# Punto inferior +polyline: 8,23 12,23 12,26 8,26 8,23 diff --git a/data/shapes/font/char_comma.shp b/data/shapes/font/char_comma.shp new file mode 100644 index 0000000..25f711e --- /dev/null +++ b/data/shapes/font/char_comma.shp @@ -0,0 +1,9 @@ +# char_comma.shp - Símbolo , (coma) +# Dimensiones: 20×40 (blocky display) + +name: char_comma +scale: 1.0 +center: 10, 20 + +# Dot + tail hacia abajo-izquierda +polyline: 10,28 10,32 8,34 diff --git a/data/shapes/font/char_dot.shp b/data/shapes/font/char_dot.shp new file mode 100644 index 0000000..138ba52 --- /dev/null +++ b/data/shapes/font/char_dot.shp @@ -0,0 +1,9 @@ +# char_dot.shp - Símbolo . (punto) +# Dimensiones: 20×40 (blocky display) + +name: char_dot +scale: 1.0 +center: 10, 20 + +# Cuadrado pequeño centrado abajo +polyline: 8,28 12,28 12,32 8,32 8,28 diff --git a/data/shapes/font/char_exclamation.shp b/data/shapes/font/char_exclamation.shp new file mode 100644 index 0000000..7911da3 --- /dev/null +++ b/data/shapes/font/char_exclamation.shp @@ -0,0 +1,11 @@ +# char_exclamation.shp - Símbolo ! (exclamación) +# Dimensiones: 20×40 (blocky display) + +name: char_exclamation +scale: 1.0 +center: 10, 20 + +# Línea vertical superior +line: 10,10 10,24 +# Dot inferior +polyline: 8,28 12,28 12,32 8,32 8,28 diff --git a/data/shapes/font/char_minus.shp b/data/shapes/font/char_minus.shp new file mode 100644 index 0000000..a5cac28 --- /dev/null +++ b/data/shapes/font/char_minus.shp @@ -0,0 +1,9 @@ +# char_minus.shp - Símbolo - (menos/guión) +# Dimensiones: 20×40 (blocky display) + +name: char_minus +scale: 1.0 +center: 10, 20 + +# Línea horizontal en el centro +line: 4,20 16,20 diff --git a/data/shapes/font/char_question.shp b/data/shapes/font/char_question.shp new file mode 100644 index 0000000..117920e --- /dev/null +++ b/data/shapes/font/char_question.shp @@ -0,0 +1,11 @@ +# char_question.shp - Símbolo ? (interrogación) +# Dimensiones: 20×40 (blocky display) + +name: char_question +scale: 1.0 +center: 10, 20 + +# Curva superior + trazo hacia abajo +polyline: 2,12 10,10 18,12 18,18 10,20 10,24 +# Dot inferior +polyline: 8,28 12,28 12,32 8,32 8,28 diff --git a/data/shapes/font/char_space.shp b/data/shapes/font/char_space.shp new file mode 100644 index 0000000..e230816 --- /dev/null +++ b/data/shapes/font/char_space.shp @@ -0,0 +1,9 @@ +# char_space.shp - Espacio (vacío) +# Dimensiones: 20×40 (blocky display) +# Sin geometría (espacio vacío intencional) + +name: char_space +scale: 1.0 +center: 10, 20 + +# No hay polylines ni lines (vacío intencionado) diff --git a/data/shapes/letra_a.shp b/data/shapes/logo/letra_a.shp similarity index 100% rename from data/shapes/letra_a.shp rename to data/shapes/logo/letra_a.shp diff --git a/data/shapes/letra_e.shp b/data/shapes/logo/letra_e.shp similarity index 100% rename from data/shapes/letra_e.shp rename to data/shapes/logo/letra_e.shp diff --git a/data/shapes/letra_g.shp b/data/shapes/logo/letra_g.shp similarity index 100% rename from data/shapes/letra_g.shp rename to data/shapes/logo/letra_g.shp diff --git a/data/shapes/letra_i.shp b/data/shapes/logo/letra_i.shp similarity index 100% rename from data/shapes/letra_i.shp rename to data/shapes/logo/letra_i.shp diff --git a/data/shapes/letra_j.shp b/data/shapes/logo/letra_j.shp similarity index 100% rename from data/shapes/letra_j.shp rename to data/shapes/logo/letra_j.shp diff --git a/data/shapes/letra_l.shp b/data/shapes/logo/letra_l.shp similarity index 100% rename from data/shapes/letra_l.shp rename to data/shapes/logo/letra_l.shp diff --git a/data/shapes/letra_m.shp b/data/shapes/logo/letra_m.shp similarity index 100% rename from data/shapes/letra_m.shp rename to data/shapes/logo/letra_m.shp diff --git a/data/shapes/letra_s.shp b/data/shapes/logo/letra_s.shp similarity index 100% rename from data/shapes/letra_s.shp rename to data/shapes/logo/letra_s.shp diff --git a/source/game/escenes/escena_logo.cpp b/source/game/escenes/escena_logo.cpp index 736e207..0b97695 100644 --- a/source/game/escenes/escena_logo.cpp +++ b/source/game/escenes/escena_logo.cpp @@ -92,8 +92,8 @@ void EscenaLogo::inicialitzar_lletres() { // Llista de fitxers .shp (A repetida per a les dues A's) std::vector fitxers = { - "letra_j.shp", "letra_a.shp", "letra_i.shp", "letra_l.shp", - "letra_g.shp", "letra_a.shp", "letra_m.shp", "letra_e.shp", "letra_s.shp" + "logo/letra_j.shp", "logo/letra_a.shp", "logo/letra_i.shp", "logo/letra_l.shp", + "logo/letra_g.shp", "logo/letra_a.shp", "logo/letra_m.shp", "logo/letra_e.shp", "logo/letra_s.shp" }; // Pas 1: Carregar totes les formes i calcular amplades diff --git a/source/utils/text_renderer.cpp b/source/utils/text_renderer.cpp new file mode 100644 index 0000000..f83bcfb --- /dev/null +++ b/source/utils/text_renderer.cpp @@ -0,0 +1,60 @@ +// text_renderer.cpp - Implementació del renderitzador de text +// © 2025 Port a C++20 amb SDL3 + +#include "text_renderer.hpp" +#include "../core/graphics/shape_loader.hpp" +#include "../core/rendering/shape_renderer.hpp" +#include + +namespace Utils { + +void TextRenderer::render(SDL_Renderer* renderer, + const std::string& text, + int x, int y, + int spacing) { + int current_x = x; + + for (char c : text) { + std::string filename = get_char_filename(c); + auto shape = Graphics::ShapeLoader::load("font/" + filename); + + if (shape && shape->es_valida()) { + Punt pos = {current_x, y}; + Rendering::render_shape(renderer, shape, pos, 0.0f, 1.0f, true, 1.0f); + } + + current_x += spacing; + } +} + +int TextRenderer::calculate_width(const std::string& text, int spacing) { + return static_cast(text.length()) * spacing; +} + +std::string TextRenderer::get_char_filename(char c) { + // Números 0-9 + if (c >= '0' && c <= '9') + return std::string("char_") + c + ".shp"; + + // Letras A-Z (mayúsculas) + if (c >= 'A' && c <= 'Z') + return std::string("char_") + c + ".shp"; + + // Convertir minúsculas a mayúsculas + if (c >= 'a' && c <= 'z') + return std::string("char_") + char(c - 32) + ".shp"; + + // Caracteres especiales + switch (c) { + case ':': return "char_colon.shp"; + case '.': return "char_dot.shp"; + case '-': return "char_minus.shp"; + case ',': return "char_comma.shp"; + case '!': return "char_exclamation.shp"; + case '?': return "char_question.shp"; + case ' ': return "char_space.shp"; + default: return "char_question.shp"; // Fallback + } +} + +} // namespace Utils diff --git a/source/utils/text_renderer.hpp b/source/utils/text_renderer.hpp new file mode 100644 index 0000000..c71da65 --- /dev/null +++ b/source/utils/text_renderer.hpp @@ -0,0 +1,30 @@ +// text_renderer.hpp - Renderitzador de text amb formes .shp +// © 2025 Port a C++20 amb SDL3 + +#pragma once +#include +#include "../core/types.hpp" + +// Forward declarations +struct SDL_Renderer; +namespace Graphics { class Shape; } + +namespace Utils { + +class TextRenderer { +public: + // Renderitza un string en la posició especificada + static void render(SDL_Renderer* renderer, + const std::string& text, + int x, int y, + int spacing = 22); + + // Calcula el ancho total de un string + static int calculate_width(const std::string& text, int spacing = 22); + +private: + // Mapea un caràcter a su nombre de archivo .shp + static std::string get_char_filename(char c); +}; + +} // namespace Utils