Commit 97f10e39 authored by newspaz's avatar newspaz

Changes to show finishing animations with an explosive effect. (e.g. shown...

Changes to show finishing animations with an explosive effect. (e.g. shown when turtles get shot in Diamondus)

eventframe.cpp
*) The drawing routine no longer ignores negative finish animation values. Instead 128 is added.
*) If 128 is added that means an explosive effect should be used. A boolean is set for this.
*) If the boolean is set the finishing animation will be drawn six times. The animation will be moving in a half circle trajectory.
parent ebae1e52
...@@ -922,6 +922,7 @@ void Event::draw (unsigned int ticks, int change) { ...@@ -922,6 +922,7 @@ void Event::draw (unsigned int ticks, int change) {
Anim* anim; Anim* anim;
signed char* set; signed char* set;
bool drawExplosion;
if (next) next->draw(ticks, change); if (next) next->draw(ticks, change);
...@@ -939,11 +940,10 @@ void Event::draw (unsigned int ticks, int change) { ...@@ -939,11 +940,10 @@ void Event::draw (unsigned int ticks, int change) {
// If the event has been removed from the grid, do not show it // If the event has been removed from the grid, do not show it
if (!set) return; if (!set) return;
// Check if the event has anything to draw // Check if the event has anything to draw
if (!animType || (set[animType] < 0)) return; if (!animType) return;
// Decide on the exact frame to draw
if ((animType == E_LFINISHANIM) || (animType == E_RFINISHANIM)) if ((animType == E_LFINISHANIM) || (animType == E_RFINISHANIM))
frame = (ticks + T_FINISH - level->getEventTime(gridX, gridY)) / 40; frame = (ticks + T_FINISH - level->getEventTime(gridX, gridY)) / 40;
else if (set[E_ANIMSP]) else if (set[E_ANIMSP])
...@@ -951,30 +951,80 @@ void Event::draw (unsigned int ticks, int change) { ...@@ -951,30 +951,80 @@ void Event::draw (unsigned int ticks, int change) {
else else
frame = ticks / 20; frame = ticks / 20;
anim = level->getAnim(set[animType]);
anim->setFrame(frame + gridX + gridY, true);
// Calculate new positions
fixed changeX = getDrawX(change);
fixed changeY = getDrawY(change);
// Check if an explosive effect should be drawn
drawExplosion = false;
if (set[animType] < 0) {
anim = level->getAnim(set[animType] + 128);
// Explosions may only occur with finish animations
if (animType == E_RFINISHANIM || animType == E_LFINISHANIM) drawExplosion = true;
}
else {
anim = level->getAnim(set[animType]);
}
// Decide on the frame to draw
anim->setFrame(frame + gridX + gridY, true);
if (ticks < flashTime) anim->flashPalette(0); if (ticks < flashTime) anim->flashPalette(0);
// Correct the position without altering the animation // Correct the position without altering the animation
fixed changeX = getDrawX(change); if (disableAnimOffset) {
fixed changeY = getDrawY(change);
if (disableAnimOffset)
changeY += anim->getOffset(); changeY += anim->getOffset();
if (onlyLAnimOffset && animType == E_RIGHTANIM) { }
else if (onlyLAnimOffset && animType == E_RIGHTANIM) {
changeY += anim->getOffset(); changeY += anim->getOffset();
changeY -= getAnim(E_LEFTANIM)->getOffset(); changeY -= getAnim(E_LEFTANIM)->getOffset();
} }
if (onlyRAnimOffset && animType == E_LEFTANIM) { else if (onlyRAnimOffset && animType == E_LEFTANIM) {
changeY += anim->getOffset(); changeY += anim->getOffset();
changeY -= getAnim(E_RIGHTANIM)->getOffset(); changeY -= getAnim(E_RIGHTANIM)->getOffset();
} }
// Draw the event // Draw the event
anim->draw(changeX, changeY); if (drawExplosion) {
// In case of an explosion
// Determine position in a half circle path
fixed xOffset = fSin(level->getEventTime(gridX, gridY) - ticks) * 48;
fixed yOffset = fCos(level->getEventTime(gridX, gridY) - ticks) * 48;
// Draw the animation in six different positions
anim->draw(changeX - yOffset, changeY - xOffset);
anim->draw(changeX + yOffset, changeY - xOffset);
anim->draw(changeX + ITOF(16) - yOffset, changeY - ITOF(8) - xOffset);
anim->draw(changeX - ITOF(8) + yOffset, changeY - ITOF(16) - xOffset);
anim->draw(changeX + ITOF(12) - yOffset, changeY + ITOF(12) - xOffset);
anim->draw(changeX - ITOF(24) + yOffset, changeY + ITOF(24) - xOffset);
}
else {
// In case an event can be drawn normally
anim->draw(changeX, changeY);
}
if (ticks < flashTime) anim->restorePalette(); if (ticks < flashTime) anim->restorePalette();
......
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