- 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

BIN
data/font2.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

View File

@@ -10,7 +10,7 @@ exit-xn: 5
exit-zp: 7 exit-zp: 7
actor{ actor{
name: B1 name: B1-00
bmp: objectes.gif bmp: objectes.gif
bmp-rect: 114 78 15 18 bmp-rect: 114 78 15 18
bmp-offset: -8 22 bmp-offset: -8 22
@@ -22,32 +22,6 @@ actor{
movement: CW movement: CW
} }
actor{
name: YONKI
bmp: caixes.gif
bmp-rect: 168 64 19 32
bmp-offset: -7 37
pos: 18 9 0
size: 6 6 12
anim-cycle: SEQ
anim-wait: 1
flags: PUSHABLE GRAVITY
movement: CW
}
actor{
name: B2
bmp: objectes.gif
bmp-rect: 114 78 15 18
bmp-offset: -8 22
pos: 16 32 0
size: 4 4 4
anim-cycle: SEQ
anim-wait: 2
flags: ANIMATED SPECIAL
movement: CW
}
actor{ actor{
name: LIFT name: LIFT
bmp: caixes.gif bmp: caixes.gif
@@ -60,6 +34,32 @@ actor{
movement: Z movement: Z
} }
actor{
name: YONKI
bmp: caixes.gif
bmp-rect: 168 64 19 32
bmp-offset: -7 37
pos: 18 9 0
size: 6 6 12
anim-cycle: SEQ
anim-wait: 1
flags: PUSHABLE GRAVITY
movement: CW
}
actor{
name: B2-01
bmp: objectes.gif
bmp-rect: 114 78 15 18
bmp-offset: -8 22
pos: 16 32 0
size: 4 4 4
anim-cycle: SEQ
anim-wait: 2
flags: ANIMATED SPECIAL
movement: CW
}
actor{ actor{
name: BARREL name: BARREL
bmp: caixes.gif bmp: caixes.gif
@@ -94,7 +94,7 @@ actor{
} }
actor{ actor{
name: B4 name: B4-02
bmp: objectes.gif bmp: objectes.gif
bmp-rect: 114 78 15 18 bmp-rect: 114 78 15 18
bmp-offset: -8 22 bmp-offset: -8 22

View File

@@ -433,7 +433,7 @@ namespace actor
{ {
if (act->name[0]=='B') // Es un booster 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); actor::remove(act);
} }
} }
@@ -1242,9 +1242,19 @@ namespace actor
int boost_god = 0; int boost_god = 0;
int skills = SKILL_NONE; int skills = SKILL_NONE;
int parts = PART_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) switch (booster)
{ {
case BOOST_GOD: boost_god = 99*2; break; case BOOST_GOD: boost_god = 99*2; break;
@@ -1253,6 +1263,11 @@ namespace actor
} }
} }
bool wasBoosterCollected(int id)
{
return boosters_collected[id];
}
int getBoostGod() int getBoostGod()
{ {
return boost_god; return boost_god;

View File

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

View File

@@ -27,6 +27,7 @@ namespace draw
uint8_t transparent = 0; // El color transparent uint8_t transparent = 0; // El color transparent
surface *textsurf = nullptr; // Surface on guardar el gif amb la font 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; SDL_Rect viewport;
@@ -52,12 +53,14 @@ namespace draw
for (int i=0;i<256;++i) color_indices[i] = i; for (int i=0;i<256;++i) color_indices[i] = i;
textsurf = loadSurface("font.gif"); textsurf = loadSurface("font.gif");
textsurf2 = loadSurface("font2.gif");
} }
// Finalització del sistema // Finalització del sistema
void quit() void quit()
{ {
if (textsurf) freeSurface(textsurf); if (textsurf) freeSurface(textsurf);
if (textsurf2) freeSurface(textsurf2);
// Si la superficie "screen" existia, alliberem la seua memòria // Si la superficie "screen" existia, alliberem la seua memòria
if (screen != nullptr) if (screen != nullptr)
@@ -383,6 +386,34 @@ namespace draw
source = tmp; 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 // Refresca la pantalla
void render() void render()
{ {

View File

@@ -8,6 +8,11 @@
#define DRAW_FLIP_VERTICAL 2 #define DRAW_FLIP_VERTICAL 2
#define DRAW_FLIP_BOTH 3 #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 // Unitat per a la gestió dels recursos gràfics i dibuixat en pantalla
namespace draw namespace draw
{ {
@@ -95,6 +100,8 @@ namespace draw
void rect(const int x, const int y, const int w, const int h); 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 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 /// @brief Refresca la pantalla
void render(); void render();

View File

@@ -30,6 +30,7 @@ int treeview_scroll = 0;
void restart() 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); 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_0) return '0';
if (scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_9) return scancode+19; if (scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_9) return scancode+19;
if (scancode >= SDL_SCANCODE_A && scancode <= SDL_SCANCODE_Z) return scancode+61; 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) const bool btn_txt(const char* label, const int x, const int y, char *var)
@@ -370,9 +372,18 @@ bool game::loop()
room::draw2(); room::draw2();
draw::swapcol(1, WHITE+LIGHT); draw::swapcol(1, WHITE+LIGHT);
actor::draw(actor::getPicked(), false); actor::draw(actor::getPicked(), false);
print(10, 200, actor::hero::getBoostJump()); draw::print2("a", 4, 24, YELLOW, FONT_ZOOM_NONE);
print(30, 200, actor::hero::getBoostGod()/2); draw::print2("b", 7, 24, LIGHT+TEAL, FONT_ZOOM_NONE);
print(50, 200, actor::hero::getBoostRun()/2); 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); //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{")) { } else if (util::strcomp(key, "actor{")) {
actor::actor_t *act = actor::createFromFile(&buffer); 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); free(original_buffer);

View File

@@ -14,6 +14,12 @@ x Gràfics de nevera
x Gràfics de bancada de cuina x Gràfics de bancada de cuina
- Gràfics de sofà? - Gràfics de sofà?
- Gràfics de Plantes, arbres... - Gràfics de Plantes, arbres...
- Gràfics de llit
- Gràfics de lampara
- Grafics de mancuerna
- Gràfics de recreativa
- Gràfics de Batman
- gràfics de WC, Pila
- Decidir objectes de habilitats - Decidir objectes de habilitats
x Motxilla: permet agafar parts de la piscina x Motxilla: permet agafar parts de la piscina