mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-17 02:24:07 +02:00
#3 fix change slide direction
This commit is contained in:
42
src/lara.h
42
src/lara.h
@@ -2098,8 +2098,7 @@ struct Lara : Character {
|
|||||||
if (pos.y + 8 >= info.floor && (abs(info.slantX) > 2 || abs(info.slantZ) > 2)) {
|
if (pos.y + 8 >= info.floor && (abs(info.slantX) > 2 || abs(info.slantZ) > 2)) {
|
||||||
pos.y = info.floor;
|
pos.y = info.floor;
|
||||||
|
|
||||||
if (stand == STAND_GROUND)
|
slide();
|
||||||
slideStart();
|
|
||||||
|
|
||||||
return STAND_SLIDE;
|
return STAND_SLIDE;
|
||||||
}
|
}
|
||||||
@@ -2382,29 +2381,28 @@ struct Lara : Character {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void slideStart() {
|
void slide() {
|
||||||
if (state != STATE_SLIDE && state != STATE_SLIDE_BACK) {
|
TR::Level::FloorInfo info;
|
||||||
TR::Level::FloorInfo info;
|
getFloorInfo(getRoomIndex(), pos, info);
|
||||||
getFloorInfo(getRoomIndex(), pos, info);
|
|
||||||
|
|
||||||
int sx = abs(info.slantX), sz = abs(info.slantZ);
|
int sx = abs(info.slantX), sz = abs(info.slantZ);
|
||||||
// get direction
|
// get direction
|
||||||
float dir;
|
float dir;
|
||||||
if (sx > sz)
|
if (sx >= sz)
|
||||||
dir = info.slantX > 0 ? 3.0f : 1.0f;
|
dir = info.slantX > 0 ? 3.0f : 1.0f;
|
||||||
else
|
else
|
||||||
dir = info.slantZ > 0 ? 2.0f : 0.0f;
|
dir = info.slantZ > 0 ? 2.0f : 0.0f;
|
||||||
dir *= PI * 0.5f;
|
dir *= PI * 0.5f;
|
||||||
|
|
||||||
int aIndex = ANIM_SLIDE_FORTH;
|
int aIndex = ANIM_SLIDE_FORTH;
|
||||||
if (fabsf(shortAngle(dir, angle.y)) > PI * 0.5f) {
|
if (fabsf(shortAngle(dir, angle.y)) > PI * 0.5f) {
|
||||||
aIndex = ANIM_SLIDE_BACK;
|
aIndex = ANIM_SLIDE_BACK;
|
||||||
dir += PI;
|
dir += PI;
|
||||||
}
|
|
||||||
|
|
||||||
angle.y = dir;
|
|
||||||
animation.setAnim(aIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
angle.y = dir;
|
||||||
|
if (animation.index != aIndex)
|
||||||
|
animation.setAnim(aIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int getStateSlide() {
|
virtual int getStateSlide() {
|
||||||
|
Reference in New Issue
Block a user