- [CHG] Ja no se perden vides al jugar des de l'editor

- [NEW] Funcions per a obtindre el nom dels boosters, skills i parts, segons el seu numero
- [NEW] El minimapa mostra on estàn els boosts, skills i parts
- Més habitacions
This commit is contained in:
2024-09-25 13:48:36 +02:00
parent c49684981c
commit 1b9dfddc94
14 changed files with 496 additions and 41 deletions

View File

@@ -4,6 +4,7 @@
#include "misc.h"
#include <SDL2/SDL.h>
#include "room.h"
#include "actor.h"
namespace modules
{
@@ -20,6 +21,7 @@ namespace modules
uint8_t h;
uint8_t color;
uint8_t exits[6];
uint32_t specials;
};
miniroom_t minirooms[64];
@@ -34,8 +36,8 @@ namespace modules
if (minirooms[room].exits[YN] != 255) { draw::isoline(x,y,+1,-1,14); /*draw::isoline(x,y-1,+1,-1,14);*/ draw::isoline(x,y+1,+1,-1,14); }
if (minirooms[room].exits[XP] != 255) { draw::isoline(x,y,+1,+1,14); /*draw::isoline(x,y-1,+1,+1,14);*/ draw::isoline(x,y+1,+1,+1,14); }
if (minirooms[room].exits[YP] != 255) { draw::isoline(x,y,-1,+1,14); /*draw::isoline(x,y-1,-1,+1,14);*/ draw::isoline(x,y+1,-1,+1,14); }
if (minirooms[room].exits[ZN] != 255) { draw::vline(x,y,24); /*draw::isoline(x,y-1,-1,+1,14);*/ draw::vline(x+1,y,24); }
if (minirooms[room].exits[ZP] != 255) { draw::vline(x,y-24,24); /*draw::isoline(x,y-1,-1,+1,14);*/ draw::vline(x+1,y-24,24); }
if (minirooms[room].exits[ZN] != 255) { draw::vline(x-1,y,24); /*draw::isoline(x,y-1,-1,+1,14);*/ draw::vline(x,y,24); }
if (minirooms[room].exits[ZP] != 255) { draw::vline(x-1,y-24,24); /*draw::isoline(x,y-1,-1,+1,14);*/ draw::vline(x,y-24,24); }
}
if (minirooms[room].exits[XN] != 255) drawLines(minirooms[room].exits[XN], x-24, y-12);
if (minirooms[room].exits[XP] != 255) drawLines(minirooms[room].exits[XP], x+24, y+12);
@@ -59,6 +61,10 @@ namespace modules
{
char num[] = "00"; num[0] = 48+(room/10); num[1] = 48+(room%10);
draw::print(num, x-4, y-3, LIGHT+(room==current_room?YELLOW:WHITE), BLACK);
if (minirooms[room].specials&0x000000ff) { draw::color(BLACK); draw::rect(x+3, y-4, 3, 3); draw::color(BLUE); draw::fillrect(x+4, y-3, 1, 1); }
if (minirooms[room].specials&0x0000ff00) { draw::color(BLACK); draw::rect(x+3, y-2, 3, 3); draw::color(GREEN); draw::fillrect(x+4, y-1, 1, 1); }
if (minirooms[room].specials&0x00ff0000) { draw::color(BLACK); draw::rect(x+3, y, 3, 3); draw::color(YELLOW); draw::fillrect(x+4, y+1, 1, 1); }
if (minirooms[room].specials&0xff000000) { draw::color(RED); draw::fillrect(x+4, y-3, 1, 5); }
}
}
if (minirooms[room].exits[XN] != 255) drawRoom(minirooms[room].exits[XN], x-24, y-12, shadow);
@@ -78,6 +84,27 @@ namespace modules
minirooms[room].color = room::getColor(0);
minirooms[room].w = (room::getSize().x >> 1)-1;
minirooms[room].h = (room::getSize().y >> 1)-1;
minirooms[room].specials = 0;
// Recolectem els especials de l'habitació per a mostrar-los
actor::actor_t *act = actor::getFirst();
while (act)
{
if (act->flags & FLAG_SPECIAL)
{
if (act->name[0]=='B') { // Es un booster
minirooms[room].specials |= actor::hero::getBoosterFromString(&act->name[2]);
} else if (act->name[0]=='S') { // Es un skill
minirooms[room].specials |= (actor::hero::getSkillFromString(&act->name[2])<<8);
} else if (act->name[0]=='P') { // Es una part
minirooms[room].specials |= (actor::hero::getPartFromString(&act->name[2])<<16);
} else {
minirooms[room].specials |= (1<<24); // Es algo invalid
}
}
act = act->next;
}
for (int i=0; i<=ZN; ++i) minirooms[room].exits[i] = room::getExit(i);
for (int i=0; i<=ZN; ++i) {
@@ -113,6 +140,13 @@ namespace modules
drawRoom(room::getCurrent(), scroll.x+x, scroll.y+y, true);
}
draw::stencil::enable();
draw::stencil::clear(255);
for (int i=0;i<64;++i) drawn[i]=false;
drawRoom(room::getCurrent(), scroll.x, scroll.y);
draw::render();
}
@@ -120,11 +154,22 @@ namespace modules
{
if (input::keyPressed(SDL_SCANCODE_ESCAPE) || input::keyPressed(SDL_SCANCODE_TAB)) return false;
draw::stencil::enable();
draw::stencil::clear(255);
//draw::stencil::enable();
//draw::stencil::clear(255);
//for (int i=0;i<64;++i) drawn[i]=false;
//drawRoom(room::getCurrent(), scroll.x, scroll.y);
const int hover = draw::stencil::query(input::mouseX(), input::mouseY());
if (hover!=255) {
draw::color(BLACK); draw::fillrect(0,0,60,60);
int line = 4;
draw::print2(hover, -2, 1, 1, WHITE, FONT_ZOOM_VERTICAL);
if (minirooms[hover].specials & 0x000000ff) draw::print2(actor::hero::getBoosterName(minirooms[hover].specials & 0xff), 1, line++, BLUE, FONT_ZOOM_NONE);
if (minirooms[hover].specials & 0x0000ff00) draw::print2(actor::hero::getSkillName((minirooms[hover].specials>>8) & 0xff), 1, line++, GREEN, FONT_ZOOM_NONE);
if (minirooms[hover].specials & 0x00ff0000) draw::print2(actor::hero::getPartName((minirooms[hover].specials>>16) & 0xff), 1, line++, YELLOW, FONT_ZOOM_NONE);
}
for (int i=0;i<64;++i) drawn[i]=false;
drawRoom(room::getCurrent(), scroll.x, scroll.y);
draw::render();
if (input::mouseClk(1)) {