- 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

@@ -433,7 +433,7 @@ namespace actor
{
if (act->name[0]=='B') // Es un booster
{
hero::collectBooster(act->name[1]-48);
hero::collectBooster(act->name[1]-48, (act->name[3]-48)*10+(act->name[4]-48));
actor::remove(act);
}
}
@@ -1242,9 +1242,19 @@ namespace actor
int boost_god = 0;
int skills = SKILL_NONE;
int parts = PART_NONE;
bool boosters_collected[100];
void collectBooster(int booster)
void init()
{
boost_jumps = boost_steps = boost_god = 0;
skills = SKILL_NONE;
parts = PART_NONE;
for (int i=0; i<100; ++i) boosters_collected[i] = false;
}
void collectBooster(int booster, int id)
{
boosters_collected[id] = true;
switch (booster)
{
case BOOST_GOD: boost_god = 99*2; break;
@@ -1253,6 +1263,11 @@ namespace actor
}
}
bool wasBoosterCollected(int id)
{
return boosters_collected[id];
}
int getBoostGod()
{
return boost_god;

View File

@@ -166,7 +166,9 @@ namespace actor
namespace hero
{
void collectBooster(int booster);
void init();
void collectBooster(int booster, int id);
bool wasBoosterCollected(int id);
int getBoostGod();
int getBoostRun();
int getBoostJump();

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()
{

View File

@@ -8,6 +8,11 @@
#define DRAW_FLIP_VERTICAL 2
#define DRAW_FLIP_BOTH 3
#define FONT_ZOOM_NONE 0
#define FONT_ZOOM_VERTICAL 1
#define FONT_ZOOM_HORIZONTAL 2
#define FONT_ZOOM_BOTH 3
// Unitat per a la gestió dels recursos gràfics i dibuixat en pantalla
namespace draw
{
@@ -95,6 +100,8 @@ namespace draw
void rect(const int x, const int y, const int w, const int h);
void print(const char* text, const int x, const int y, const uint8_t color, const uint8_t borde);
void print2(const char* text, const int x, const int y, const uint8_t color, const int zoom);
void print2(const int num, const int positions, const int x, const int y, const uint8_t color, const int zoom);
/// @brief Refresca la pantalla
void render();

View File

@@ -30,6 +30,7 @@ int treeview_scroll = 0;
void restart()
{
actor::hero::init();
room::load(0); //room_w, room_h, room_xp, room_xn, room_yp, room_yn, room_color, room_floor, room_walls, room_doors, room_walldoors);
@@ -243,7 +244,8 @@ const uint8_t scancode_to_char(const uint8_t scancode)
if (scancode == SDL_SCANCODE_0) return '0';
if (scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_9) return scancode+19;
if (scancode >= SDL_SCANCODE_A && scancode <= SDL_SCANCODE_Z) return scancode+61;
return 32;
//if (scancode == SDL_SCANCODE_MINUS) return '-';
return '-';
}
const bool btn_txt(const char* label, const int x, const int y, char *var)
@@ -370,9 +372,18 @@ bool game::loop()
room::draw2();
draw::swapcol(1, WHITE+LIGHT);
actor::draw(actor::getPicked(), false);
print(10, 200, actor::hero::getBoostJump());
print(30, 200, actor::hero::getBoostGod()/2);
print(50, 200, actor::hero::getBoostRun()/2);
draw::print2("a", 4, 24, YELLOW, FONT_ZOOM_NONE);
draw::print2("b", 7, 24, LIGHT+TEAL, FONT_ZOOM_NONE);
draw::print2("c", 10, 24, LIGHT+PURPLE, FONT_ZOOM_NONE);
draw::print2(actor::hero::getBoostJump(), 2, 3, 26, LIGHT+PURPLE, FONT_ZOOM_NONE);
draw::print2(actor::hero::getBoostGod()/2, 2, 6, 26, YELLOW, FONT_ZOOM_NONE);
draw::print2(actor::hero::getBoostRun()/2, 2, 9, 26, LIGHT+TEAL, FONT_ZOOM_NONE);
//print(10, 200, actor::hero::getBoostJump());
//print(30, 200, actor::hero::getBoostGod()/2);
//print(50, 200, actor::hero::getBoostRun()/2);
//draw::draw(148+sx*2-sy*2, 67+sx+sy,24,24,24,0);
/*

View File

@@ -180,7 +180,19 @@ namespace room
} else if (util::strcomp(key, "actor{")) {
actor::actor_t *act = actor::createFromFile(&buffer);
actor::setDirty(act, true);
if (!::editor::isEditing() && act->flags & FLAG_SPECIAL)
{
if (act->name[0]=='B') // Es un booster
{
if (actor::hero::wasBoosterCollected((act->name[3]-48)*10+(act->name[4]-48)))
{
actor::remove(act);
act = nullptr;
}
}
}
if (act) actor::setDirty(act, true);
}
}
free(original_buffer);