Skip to content

Commit

Permalink
AVALANCHE: Implement, rename, move zonk() and connected functions.
Browse files Browse the repository at this point in the history
Implementations: zonk(), zl().
Renames: zonk() -> thunder(), zl() -> drawLightning().
Moved: the 2 above from Pingo to Animation.
Addition: GraphicManager::drawLine().
  • Loading branch information
uruk committed Jan 15, 2014
1 parent b5b0aa2 commit 96d4b67
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 12 deletions.
44 changes: 44 additions & 0 deletions engines/avalanche/animation.cpp
Expand Up @@ -1399,6 +1399,50 @@ void Animation::handleMoveKey(const Common::Event &event) {
}
}

/**
* Draws a part of the lightning bolt for thunder().
* @remarks Originally called 'zl'
*/
void Animation::drawLightning(int16 x1, int16 y1, int16 x2, int16 y2) {
_vm->_graphics->drawLine(x1, y1 - 1, x2, y2 - 1, 1, 3, kColorBlue);
_vm->_graphics->drawLine(x1, y1, x2, y2, 1, 1, kColorLightcyan);
}

/**
* Plays the actual thunder animation when Avvy (the player) swears too much.
* @remarks Originally called 'zonk'
*/
void Animation::thunder() {
_vm->_graphics->setBackgroundColor(kColorYellow);

_vm->_graphics->saveScreen();

int x = _vm->_animation->_sprites[0]->_x + _vm->_animation->_sprites[0]->_xLength / 2;
int y = _vm->_animation->_sprites[0]->_y;

for (int i = 0; i < 256; i++) {
_vm->_sound->playNote(270 - i, 1);

drawLightning(640, 0, 0, y / 4);
drawLightning(0, y / 4, 640, y / 2);
drawLightning(640, y / 2, x, y);
_vm->_graphics->refreshScreen();

_vm->_sound->playNote(2700 - 10 * i, 5);
_vm->_system->delayMillis(5);
_vm->_sound->playNote(270 - i, 1);

_vm->_graphics->restoreScreen();
_vm->_sound->playNote(2700 - 10 * i, 5);
_vm->_system->delayMillis(5);
}

_vm->_graphics->restoreScreen();
_vm->_graphics->removeBackup();

_vm->_graphics->setBackgroundColor(kColorBlack);
}

void Animation::setDirection(Direction dir) {
_direction = dir;
}
Expand Down
4 changes: 4 additions & 0 deletions engines/avalanche/animation.h
Expand Up @@ -125,6 +125,10 @@ class Animation {
void handleMoveKey(const Common::Event &event);
void hideInCupboard();

// These 2 functions are responsible for playing the thunder animation when the player swears too much.
void drawLightning(int16 x1, int16 y1, int16 x2, int16 y2);
void thunder();

void setDirection(Direction dir);
void setOldDirection(Direction dir);
Direction getDirection();
Expand Down
4 changes: 4 additions & 0 deletions engines/avalanche/graphics.cpp
Expand Up @@ -281,6 +281,10 @@ Common::Point GraphicManager::drawArc(Graphics::Surface &surface, int16 x, int16
return endPoint;
}

void GraphicManager::drawLine(int x1, int y1, int x2, int y2, int penX, int penY, Color color) {
_surface.drawThickLine(x1, y1, x2, y2, penX, penY, color);
}

Common::Point GraphicManager::drawScreenArc(int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color) {
return drawArc(_surface, x, y, stAngle, endAngle, radius, color);
}
Expand Down
3 changes: 2 additions & 1 deletion engines/avalanche/graphics.h
Expand Up @@ -58,6 +58,7 @@ class GraphicManager {
void loadDigits();
void loadMouse(byte which);

void drawLine(int x1, int y1, int x2, int y2, int penX, int penY, Color color);
Common::Point drawScreenArc(int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color);
void drawPieSlice(int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color);
void drawTriangle(Common::Point *p, Color color);
Expand Down Expand Up @@ -115,8 +116,8 @@ class GraphicManager {
void getNaturalPicture(SpriteType &sprite);

void saveScreen();
void removeBackup();
void restoreScreen();
void removeBackup();

private:
static const uint16 kBackgroundWidth = kScreenWidth;
Expand Down
2 changes: 1 addition & 1 deletion engines/avalanche/parser.cpp
Expand Up @@ -2108,7 +2108,7 @@ void Parser::doThat() {
}
break;
default: {
_vm->_pingo->zonk();
_vm->_animation->thunder();
Common::String tmpStr = Common::String::format("A crack of lightning shoots from the sky, and fries you." \
"%c%c(`Such is the anger of the gods, Avvy!\")", kControlNewLine, kControlNewLine);
_vm->_dialogs->displayText(tmpStr);
Expand Down
8 changes: 0 additions & 8 deletions engines/avalanche/pingo.cpp
Expand Up @@ -60,14 +60,6 @@ void Pingo::wobble() {
warning("STUB: Pingo::wobble()");
}

void Pingo::zl(int16 x1, int16 y1, int16 x2, int16 y2) {
warning("STUB: Pingo::zl()");
}

void Pingo::zonk() {
warning("STUB: Pingo::zonk()");
}

void Pingo::winningPic() {
Common::File f;
_vm->fadeOut();
Expand Down
2 changes: 0 additions & 2 deletions engines/avalanche/pingo.h
Expand Up @@ -44,14 +44,12 @@ class Pingo {
void copy03();
void copyPage(byte frp, byte top);
void wobble();
void zonk();
void winningPic();

private:
AvalancheEngine *_vm;

void dPlot(int16 x, int16 y, Common::String z);
void zl(int16 x1, int16 y1, int16 x2, int16 y2);
};

} // End of namespace Avalanche.
Expand Down

0 comments on commit 96d4b67

Please sign in to comment.