- [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:
@@ -797,9 +797,12 @@ namespace actor
|
||||
vec3_t max = room::getMax();
|
||||
|
||||
if ( (act->push & PUSH_KILL) && (act->flags & FLAG_HERO) ) {
|
||||
const int lives = hero::getLives()-1;
|
||||
hero::setLives(lives);
|
||||
stats::loseLive();
|
||||
if (!editor::isDevMode())
|
||||
{
|
||||
const int lives = hero::getLives()-1;
|
||||
hero::setLives(lives);
|
||||
stats::loseLive();
|
||||
}
|
||||
// [TODO] If lives == 0 anar a la pantalla de game-over o cat's life
|
||||
actor_t *act = actor::find("HERO");
|
||||
act = actor::replaceWithTemplate(act, "EXPLOSION");
|
||||
@@ -1585,6 +1588,17 @@ namespace actor
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
const char *getBoosterName(int booster)
|
||||
{
|
||||
switch (booster)
|
||||
{
|
||||
case 1: return "RUN";
|
||||
case 2: return "GOD";
|
||||
case 4: return "JUMP";
|
||||
case 8: return "LIVE";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
bool giveBooster(char *booster)
|
||||
{
|
||||
@@ -1660,6 +1674,18 @@ namespace actor
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *getSkillName(int skill)
|
||||
{
|
||||
switch (skill)
|
||||
{
|
||||
case 1: return "SHOES";
|
||||
case 2: return "GLOVES";
|
||||
case 4: return "PANTS";
|
||||
case 8: return "BAG";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
bool giveSkill(int skill)
|
||||
{
|
||||
skills |= skill;
|
||||
@@ -1705,6 +1731,20 @@ namespace actor
|
||||
return PART_NONE;
|
||||
}
|
||||
|
||||
const char *getPartName(int part)
|
||||
{
|
||||
switch (part)
|
||||
{
|
||||
case 1: return "FILTER";
|
||||
case 2: return "PUMP";
|
||||
case 4: return "TIMER";
|
||||
case 8: return "SALT";
|
||||
case 16: return "PIPE";
|
||||
case 32: return "ELBOW";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
bool pickPart(char *part)
|
||||
{
|
||||
const int value = getPartFromString(part);
|
||||
|
||||
@@ -202,6 +202,8 @@ namespace actor
|
||||
void die();
|
||||
bool isDead();
|
||||
|
||||
const int getBoosterFromString(char *booster);
|
||||
const char *getBoosterName(int booster);
|
||||
bool giveBooster(char *booster);
|
||||
void collectBooster(int booster, int id);
|
||||
bool wasBoosterCollected(int id);
|
||||
@@ -212,6 +214,8 @@ namespace actor
|
||||
void useBoostRun();
|
||||
void useBoostJump();
|
||||
|
||||
const int getSkillFromString(char *skill);
|
||||
const char *getSkillName(int skill);
|
||||
bool giveSkill(int skill);
|
||||
bool giveSkill(char *skill);
|
||||
bool dropSkill(int skill);
|
||||
@@ -219,6 +223,8 @@ namespace actor
|
||||
bool wasSkillCollected(char *skill);
|
||||
int getSkills();
|
||||
|
||||
const int getPartFromString(char *part);
|
||||
const char *getPartName(int part);
|
||||
bool pickPart(char *part);
|
||||
bool dropPart(char *part);
|
||||
bool wasPartCollected(char *part);
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user