Skip to content

Commit

Permalink
XEEN: Implement screen shaking
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jan 27, 2018
1 parent 540f472 commit 12eacaf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
1 change: 0 additions & 1 deletion engines/xeen/combat.cpp
Expand Up @@ -144,7 +144,6 @@ void Combat::giveCharDamage(int damage, DamageType attackType, int charIndex) {
EventsManager &events = *_vm->_events;
Interface &intf = *_vm->_interface;
Party &party = *_vm->_party;
Scripts &scripts = *_vm->_scripts;
Sound &sound = *_vm->_sound;
Windows &windows = *_vm->_windows;
int charIndex1 = charIndex + 1;
Expand Down
29 changes: 24 additions & 5 deletions engines/xeen/interface.cpp
Expand Up @@ -620,7 +620,6 @@ void Interface::doStepCode() {
Combat &combat = *_vm->_combat;
Map &map = *_vm->_map;
Party &party = *_vm->_party;
Scripts &scripts = *_vm->_scripts;
int damage = 0;

party._stepped = true;
Expand Down Expand Up @@ -692,7 +691,6 @@ void Interface::startFalling(bool flag) {
Combat &combat = *_vm->_combat;
Map &map = *_vm->_map;
Party &party = *_vm->_party;
Scripts &scripts = *_vm->_scripts;
bool isDarkCc = _vm->_files->_isDarkCc;

if (isDarkCc && party._gameFlags[1][118]) {
Expand Down Expand Up @@ -1279,7 +1277,6 @@ void Interface::draw3d(bool updateFlag, bool pauseFlag) {
}

void Interface::handleFalling() {
EventsManager &events = *g_vm->_events;
Party &party = *_vm->_party;
Screen &screen = *_vm->_screen;
Sound &sound = *_vm->_sound;
Expand Down Expand Up @@ -1337,8 +1334,30 @@ void Interface::fall(int yp) {
w.blitFrom(_fallSurface, Common::Rect(0, yp, SCENE_WIDTH, yp + SCENE_HEIGHT), Common::Point(8, 8));
}

void Interface::shake(int time) {
// TODO
void Interface::shake(int count) {
Screen &screen = *g_vm->_screen;
byte b;

for (int idx = 0; idx < count * 2; ++idx) {
for (int yp = 0; yp < screen.h; ++yp) {
byte *lineP = (byte *)screen.getBasePtr(0, yp);
if (idx % 2) {
// Shift back right
b = lineP[SCREEN_WIDTH - 1];
Common::copy_backward(lineP, lineP + SCREEN_WIDTH - 1, lineP + SCREEN_WIDTH);
lineP[0] = b;
} else {
// Scroll left one pixel
b = lineP[0];
Common::copy(lineP + 1, lineP + SCREEN_WIDTH, lineP);
lineP[SCREEN_WIDTH - 1] = b;
}
}

screen.markAllDirty();
screen.update();
g_system->delayMillis(5);
}
}

void Interface::assembleBorder() {
Expand Down
3 changes: 2 additions & 1 deletion engines/xeen/interface.h
Expand Up @@ -144,8 +144,9 @@ class Interface: public ButtonContainer, public InterfaceScene,

/**
* Shake the screen
* @param count Number of times
*/
void shake(int time);
void shake(int count);

/**
* Select next character or monster to be attacking
Expand Down

0 comments on commit 12eacaf

Please sign in to comment.