Skip to content

Commit

Permalink
fix step left/right, add shadows for debug text
Browse files Browse the repository at this point in the history
  • Loading branch information
XProger committed Nov 20, 2018
1 parent f287a6b commit 49abeea
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/collision.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct Collision {

struct Info {
int room, roomAbove, roomBelow;
int climb;
float floor, ceiling;
} info[4];

Expand Down Expand Up @@ -91,6 +92,7 @@ struct Collision {
inf.roomBelow = info.roomBelow;
inf.floor = info.floor;
inf.ceiling = info.ceiling;
inf.climb = info.climb;

if ((info.ceiling == info.floor) || (info.floor - info.ceiling < height) || (pos.y - info.floor > maxAscent) || (info.floor - pos.y > maxDescent) || (info.ceiling > pos.y) ||
(maxAscent == maxDescent && (maxAscent <= 256 + 128) && (abs(info.slantX) > 2 || abs(info.slantZ) > 2))) {
Expand Down
1 change: 1 addition & 0 deletions src/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ struct Controller {
info.floorIndex = s.floorIndex;
info.boxIndex = s.boxIndex;
info.lava = false;
info.climb = 0;
info.trigger = TR::Level::Trigger::ACTIVATE;
info.trigCmdCount = 0;

Expand Down
16 changes: 15 additions & 1 deletion src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ namespace Debug {
glEnd();
}

void text(const vec2 &pos, const vec4 &color, const char *str) {
void textColor(const vec2 &pos, const vec4 &color, const char *str) {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
Expand All @@ -197,6 +197,11 @@ namespace Debug {
glPopMatrix();
}

void text(const vec2 &pos, const vec4 &color, const char *str) {
textColor(pos + vec2(1.0f), vec4(0.0f, 0.0f, 0.0f, 1.0f), str);
textColor(pos, color, str);
}

void text(const vec3 &pos, const vec4 &color, const char *str) {
vec4 p = Core::mViewProj * vec4(pos, 1);
if (p.w > 0) {
Expand Down Expand Up @@ -723,6 +728,15 @@ namespace Debug {
if (info.lava)
Debug::Draw::text(vec2(16, y += 16), vec4(1.0f, 0.5f, 0.3f, 1.0f), "LAVA");

if (info.climb) {
sprintf(buf, "climb mask:");
if (info.climb & 0x01) strcat(buf, " +Z");
if (info.climb & 0x02) strcat(buf, " +X");
if (info.climb & 0x04) strcat(buf, " -Z");
if (info.climb & 0x08) strcat(buf, " -X");
Debug::Draw::text(vec2(16, y += 16), vec4(0.5f, 0.8f, 0.5f, 1.0f), buf);
}

if (info.trigCmdCount > 0) {
sprintf(buf, "trigger: %s%s mask: %d timer: %d", getTriggerType(level, info.trigger), info.trigInfo.once ? " (once)" : "", info.trigInfo.mask, info.trigInfo.timer);
Debug::Draw::text(vec2(16, y += 16), vec4(0.5f, 0.8f, 0.5f, 1.0f), buf);
Expand Down
14 changes: 11 additions & 3 deletions src/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,6 @@ namespace TR {
DRAW_LEFTGUN ,
SHOT_RIGHTGUN ,
SHOT_LEFTGUN ,
FLICKER = 16,
UNKNOWN ,
MESH_SWAP_1 ,
MESH_SWAP_2 ,
Expand All @@ -903,7 +902,16 @@ namespace TR {
INV_OFF ,
DYN_ON ,
DYN_OFF ,
FOOTPRINT = 32,
STATUE_FX ,
RESET_HAIR ,
BOILER_FX ,
ASSAULT_RESET ,
ASSAULT_STOP ,
ASSAULT_START ,
ASSAULT_FINISH ,
FOOTPRINT ,
// specific
TR1_FLICKER = 16,
};
};

Expand Down Expand Up @@ -2383,8 +2391,8 @@ namespace TR {
int floorIndex;
int boxIndex;
int lava;
int trigCmdCount;
int climb;
int trigCmdCount;
Trigger::Type trigger;
FloorData::TriggerInfo trigInfo;
FloorData::TriggerCommand trigCmd[MAX_TRIGGER_COMMANDS];
Expand Down
10 changes: 8 additions & 2 deletions src/lara.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ struct Lara : Character {
//reset(10, vec3(90443, 11264 - 256, 114614), PI, STAND_ONWATER); // villa mortal 2
// TR2
//reset(36, vec3(64190, 5632, 35743), 75 * DEG2RAD); // WALL (wade)
//reset(19, vec3(28353, 2560, 58587), 150 * DEG2RAD); // ASSAULT (wade)
//reset(19, vec3(28353, 2560, 58587), 150 * DEG2RAD); // ASSAULT (wade)

//dbgBoxes = NULL;

Expand Down Expand Up @@ -2718,7 +2718,13 @@ struct Lara : Character {
}

int checkMove(int newState, int maxAscent = 256 + 128, int maxDescent = 0xFFFFFF) {
float ext = angle.y + ((newState == STATE_BACK || newState == STATE_FAST_BACK) ? PI : 0.0f);
float ext = angle.y;
if (newState == STATE_BACK || newState == STATE_FAST_BACK)
ext += PI;
else if (newState == STATE_STEP_LEFT)
ext -= PI * 0.5f;
else if (newState == STATE_STEP_RIGHT)
ext += PI * 0.5f;
vec3 p = pos;
collision = Collision(this, getRoomIndex(), p, vec3(0.0f), vec3(0.0f), LARA_RADIUS * 1.1f, ext, 0, LARA_HEIGHT, maxAscent, maxDescent);
if (collision.side == Collision::FRONT)
Expand Down
5 changes: 4 additions & 1 deletion src/level.h
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,9 @@ struct Level : IGame {
case TR::Entity::STONE_ITEM_3 :
case TR::Entity::STONE_ITEM_4 : return new StoneItem(this, index);

case TR::Entity::WINDOW_1 :
case TR::Entity::WINDOW_2 : return new Window(this, index);

default : return (level.entities[index].modelIndex > 0) ? new Controller(this, index) : new Sprite(this, index, 0);
}
}
Expand Down Expand Up @@ -1849,7 +1852,7 @@ struct Level : IGame {
effectTimer += Core::deltaTime;

switch (effect) {
case TR::Effect::FLICKER : {
case TR::Effect::TR1_FLICKER : {
int idx = effectIdx;
switch (effectIdx) {
case 0 : if (effectTimer > 3.0f) effectIdx++; break;
Expand Down
9 changes: 9 additions & 0 deletions src/trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,15 @@ struct Explosion : Sprite {
};


struct Window : Controller {

Window(IGame *game, int entity) : Controller(game, entity) {
initMeshOverrides();
layers[0].mask = 0x00000001;
}
};


#define STONE_ITEM_LIGHT_RADIUS 2048.0f

struct StoneItem : Controller {
Expand Down

2 comments on commit 49abeea

@noabody
Copy link

@noabody noabody commented on 49abeea Nov 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silly, I know, but FYI:

(cd src/platform/nix && ./build.sh)

clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
In file included from main.cpp:14:
In file included from ../../game.h:8:
In file included from ../../level.h:8:
In file included from ../../enemy.h:5:
../../trigger.h:1573:8: error: definition of type 'Window' conflicts with
      typedef of the same name
struct Window : Controller {
       ^
/usr/include/X11/X.h:96:13: note: 'Window' declared here
typedef XID Window;
            ^
In file included from main.cpp:14:
In file included from ../../game.h:8:
../../level.h:1110:66: error: excess elements in scalar initializer
  ...TR::Entity::WINDOW_2               : return new Window(this, index);
                                                     ^          ~~~~~~~
2 errors generated.

Is "Window" really safe as a global typedef name?

@XProger
Copy link
Owner Author

@XProger XProger commented on 49abeea Nov 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch, thanks! %)

Please sign in to comment.