- Font definitiva, amb stretch

- Els boosters ja son de un us nomes
- Contadors de boosters amb font definitiva i icona furtada del Batman
-
This commit is contained in:
2024-07-02 10:38:46 +02:00
parent 8b1cf9a405
commit 96c6677a87
9 changed files with 120 additions and 36 deletions

View File

@@ -27,6 +27,7 @@ namespace draw
uint8_t transparent = 0; // El color transparent
surface *textsurf = nullptr; // Surface on guardar el gif amb la font
surface *textsurf2 = nullptr; // Surface on guardar el gif amb la font gran
SDL_Rect viewport;
@@ -52,12 +53,14 @@ namespace draw
for (int i=0;i<256;++i) color_indices[i] = i;
textsurf = loadSurface("font.gif");
textsurf2 = loadSurface("font2.gif");
}
// Finalització del sistema
void quit()
{
if (textsurf) freeSurface(textsurf);
if (textsurf2) freeSurface(textsurf2);
// Si la superficie "screen" existia, alliberem la seua memòria
if (screen != nullptr)
@@ -383,6 +386,34 @@ namespace draw
source = tmp;
}
void print2(const char* text, const int x, const int y, const Uint8 color, const int zoom)
{
surface* tmp = source;
source = textsurf2;
swapcol(1, color);
const int len = strlen(text);
for (int i=0;i<len;++i)
{
char chr = text[i]-32;
draw((x+i)*8, y*8, zoom&FONT_ZOOM_HORIZONTAL?16:8, zoom&FONT_ZOOM_VERTICAL?16:8, (chr&15)*8, (chr>>4)*8);
}
source = tmp;
}
void print2(const int num, const int positions, const int x, const int y, const uint8_t color, const int zoom)
{
char buffer[positions];
int digit = positions-1;
int value = num;
while (digit>=0)
{
buffer[digit] = (value%10)==0 && digit<positions-1 ? 32 : (value%10)+48;
value = value/10;
digit--;
}
print2(buffer, x, y, color, zoom);
}
// Refresca la pantalla
void render()
{