Commit 1383f928 authored by newspaz's avatar newspaz

Okay, with this update I am going to declare special behaviors fixed. Even...

Okay, with this update I am going to declare special behaviors fixed. Even though you might not believe me, because this is the fourth time I am making such a claim. This time I'm dangerously close to what the real game does ;-)

anim.cpp
*) Changed the getOffset accessor to add the default 32 pixel offset if it should be there.

bridge.cpp
*) Because of the change in anim.cpp I could remove the default 32 pixel offset I added earlier.

event.h, event.cpp
*) Changed the overlap method to include the offset if necessary.

eventframe.cpp
*) Changed the step method and removed the default 32 pixel offset I added earlier.
*) Changed the draw method slightly so when offsets should be ignored, that actually is the case.

parent eadb31ed
......@@ -29,6 +29,7 @@
Anim::Anim () {
frame = 0;
yOffset = 0;
ignoreDefaultYOffset = false;
return;
......@@ -109,6 +110,9 @@ fixed Anim::getShootY () {
fixed Anim::getOffset () {
if (!ignoreDefaultYOffset && yOffset == 0)
return ITOF(yOffset) + TTOF(1);
return ITOF(yOffset);
}
......
......@@ -49,7 +49,7 @@ Bridge::Bridge (unsigned char gX, unsigned char gY) {
flashTime = 0;
// Bridges should ignore the default yOffsets
dontUseAnimOffset(true);
dontUseAnimOffset();
// leftDipX and rightDipX used to store leftmost and rightmost player on bridge
// Start with minimum values
......
......@@ -64,7 +64,7 @@ Event::Event (unsigned char gX, unsigned char gY) {
onlyLAnimOffset = false;
onlyRAnimOffset = false;
disableAnimOffset = false;
noAnimOffset = false;
switch (getProperty(E_BEHAVIOUR)) {
......@@ -72,7 +72,7 @@ Event::Event (unsigned char gX, unsigned char gY) {
case 4: // Walk from side to side and down hills
animType = E_LEFTANIM;
useRightAnimOffset(true);
useRightAnimOffset();
break;
......@@ -80,7 +80,7 @@ Event::Event (unsigned char gX, unsigned char gY) {
case 7: // Flying snake behavior
animType = E_LEFTANIM;
dontUseAnimOffset(true);
dontUseAnimOffset();
break;
......@@ -98,7 +98,7 @@ Event::Event (unsigned char gX, unsigned char gY) {
case 26: // Flip animation
animType = E_RIGHTANIM;
useLeftAnimOffset(true);
useLeftAnimOffset();
break;
......@@ -234,10 +234,14 @@ fixed Event::getHeight () {
bool Event::overlap (fixed left, fixed top, fixed width, fixed height) {
fixed offset = 0;
if (getAnim(animType) && noAnimOffset)
offset = getAnim(animType)->getOffset();
return (x + getWidth() >= left) &&
(x < left + width) &&
(y >= top) &&
(y - getHeight() < top + height);
(y + offset >= top) &&
(y + offset - getHeight() < top + height);
}
......
......@@ -87,9 +87,9 @@ class Event : public Movable {
unsigned char animType; // E_LEFTANIM, etc, or 0
unsigned char frame;
unsigned int flashTime;
bool noAnimOffset;
bool onlyLAnimOffset;
bool onlyRAnimOffset;
bool disableAnimOffset;
Event ();
......@@ -98,9 +98,9 @@ class Event : public Movable {
fixed getWidth ();
fixed getHeight ();
signed char* prepareStep (unsigned int ticks, int msps);
void useLeftAnimOffset (bool enable);
void useRightAnimOffset (bool enable);
void dontUseAnimOffset (bool enable);
void useLeftAnimOffset ();
void useRightAnimOffset ();
void dontUseAnimOffset ();
public:
Event (unsigned char gX, unsigned char gY);
......
......@@ -53,7 +53,6 @@ signed char* Event::prepareStep (unsigned int ticks, int msps) {
// If the event has been removed from the grid, destroy it
if (!set) return NULL;
// If the event and its origin are off-screen, the event is not in the
// process of self-destruction, remove it
if ((animType != E_LFINISHANIM) && (animType != E_RFINISHANIM) &&
......@@ -103,7 +102,6 @@ Event* Event::step (unsigned int ticks, int msps) {
width = getWidth();
height = getHeight();
// Handle behaviour
switch (set[E_BEHAVIOUR]) {
......@@ -163,9 +161,11 @@ Event* Event::step (unsigned int ticks, int msps) {
case 6:
int count = level->path[set[E_MULTIPURPOSE]].node;
// Use the path from the level file
dx = TTOF(gridX) + ITOF(level->path[set[E_MULTIPURPOSE]].x[level->path[set[E_MULTIPURPOSE]].node]) - x;
dy = TTOF(gridY) + ITOF(level->path[set[E_MULTIPURPOSE]].y[level->path[set[E_MULTIPURPOSE]].node]) - y + TTOF(1);
dx = TTOF(gridX) + ITOF(level->path[set[E_MULTIPURPOSE]].x[count]) - x;
dy = TTOF(gridY) + ITOF(level->path[set[E_MULTIPURPOSE]].y[count]) - y;
dx = ((dx << 10) / msps) * set[E_MOVEMENTSP];
dy = ((dy << 10) / msps) * set[E_MOVEMENTSP];
......@@ -539,6 +539,7 @@ Event* Event::step (unsigned int ticks, int msps) {
}
dx /= set[E_MOVEMENTSP];
dy /= set[E_MOVEMENTSP];
x += (dx * msps) >> 10;
......@@ -882,10 +883,16 @@ Event* Event::step (unsigned int ticks, int msps) {
levelPlayer = players[count].getLevelPlayer();
// Check if the player is touching the event
fixed offset = 0;
if (getAnim(animType) && noAnimOffset)
offset = getAnim(animType)->getOffset();
if (set[E_MODIFIER] == 6) {
if (width && height &&
levelPlayer->overlap(x, y - height, width - F8, F8) &&
levelPlayer->overlap(x, y + offset - height, width - F8, F8) &&
(levelPlayer->getY() <= F8 + ((PYS_FALL * msps) >> 10) + y - height) &&
!level->checkMaskDown(levelPlayer->getX() + PXO_MID, PYO_TOP + y - height)) {
......@@ -900,7 +907,7 @@ Event* Event::step (unsigned int ticks, int msps) {
// Check if the player is touching the event
if (width && height &&
levelPlayer->overlap(x, y - height, width, height)) {
levelPlayer->overlap(x, y + offset - height, width, height)) {
// If the player picks up the event, destroy it
if (levelPlayer->touchEvent(gridX, gridY, ticks, msps))
......@@ -964,7 +971,7 @@ void Event::draw (unsigned int ticks, int change) {
anim = level->getAnim(set[animType] + 128);
// Explosions may only occur with finish animations
if (animType == E_RFINISHANIM || animType == E_LFINISHANIM) drawExplosion = true;
drawExplosion = (animType == E_RFINISHANIM || animType == E_LFINISHANIM);
}
else {
......@@ -981,9 +988,9 @@ void Event::draw (unsigned int ticks, int change) {
// Correct the position without altering the animation
if (disableAnimOffset) {
if (noAnimOffset) {
changeY -= anim->getOffset();
changeY += anim->getOffset();
}
else if (onlyLAnimOffset && animType == E_RIGHTANIM) {
......@@ -1090,27 +1097,27 @@ void Event::drawEnergy (unsigned int ticks) {
}
void Event::useLeftAnimOffset(bool enable) {
void Event::useLeftAnimOffset() {
onlyLAnimOffset = enable;
onlyLAnimOffset = true;
return;
}
void Event::useRightAnimOffset(bool enable) {
void Event::useRightAnimOffset() {
onlyRAnimOffset = enable;
onlyRAnimOffset = true;
return;
}
void Event::dontUseAnimOffset(bool enable) {
void Event::dontUseAnimOffset() {
disableAnimOffset = enable;
noAnimOffset = true;
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment