diff options
author | Eugene Sandulenko | 2016-09-09 10:29:48 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-09-09 10:59:11 +0200 |
commit | 96e418743a6b92e184ff50a3ac06332510f7c257 (patch) | |
tree | 609322db870705bea524fd32dcf02a4ff9da04f5 /engines/fullpipe/scenes | |
parent | 71d20da1e50f436a5a112ed9fce7ea55852dd9c6 (diff) | |
download | scummvm-rg350-96e418743a6b92e184ff50a3ac06332510f7c257.tar.gz scummvm-rg350-96e418743a6b92e184ff50a3ac06332510f7c257.tar.bz2 scummvm-rg350-96e418743a6b92e184ff50a3ac06332510f7c257.zip |
FULLPIPE: Further work on scene27 bats knocking logic
Diffstat (limited to 'engines/fullpipe/scenes')
-rw-r--r-- | engines/fullpipe/scenes/scene27.cpp | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/engines/fullpipe/scenes/scene27.cpp b/engines/fullpipe/scenes/scene27.cpp index f236fcc0f9..21c82096d5 100644 --- a/engines/fullpipe/scenes/scene27.cpp +++ b/engines/fullpipe/scenes/scene27.cpp @@ -39,9 +39,8 @@ namespace Fullpipe { struct Bat { StaticANIObject *ani; - int field_4; double power; - double field_10; + double angle; double currX; double currY; double powerCos; @@ -227,10 +226,12 @@ void sceneHandler27_maidSwab() { } void sceneHandler27_startBat(StaticANIObject *bat) { + debugC(2, kDebugSceneLogic, "scene27: startBat"); + Bat *newbat = new Bat; newbat->power = g_vars->scene27_launchPhase * 2.5 + 8.0; - newbat->field_10 = 0; + newbat->angle = 0; newbat->ani = bat; newbat->powerCos = newbat->power * cos(0.0); newbat->powerSin = newbat->power * sin(0.0); @@ -292,7 +293,7 @@ void sceneHandler27_wipeDo() { for (uint i = 0; i < g_vars->scene27_bats.size(); i++) { if (g_vars->scene27_bats[i]->currX < 800.0) { - g_vars->scene27_bats[i]->field_10 = atan2(520.0 - g_vars->scene27_bats[i]->currY, 800.0 - g_vars->scene27_bats[i]->currX); + g_vars->scene27_bats[i]->angle = atan2(520.0 - g_vars->scene27_bats[i]->currY, 800.0 - g_vars->scene27_bats[i]->currX); g_vars->scene27_bats[i]->power += 1.0; } } @@ -334,42 +335,59 @@ void sceneHandler27_knockBats(int bat1n, int bat2n) { Bat *bat1 = g_vars->scene27_bats[bat1n]; Bat *bat2 = g_vars->scene27_bats[bat2n]; + debugC(2, kDebugSceneLogic, "scene27: knockBats(%d, %d)", bat1n, bat2n); + if (0.0 != bat1->power) { double rndF = (double)g_fp->_rnd->getRandomNumber(32767) * 0.0000009155552842799158 - 0.015 + atan2(bat2->currY - bat1->currY, bat2->currX - bat1->currX); double rndCos = cos(rndF); double rndSin = sin(rndF); - double pow1x = cos(bat1->field_10 - rndF) * (double)((bat2->currX - bat1->currX) >= 0 ? 1 : -1) * bat1->power; - double pow1y = sin(bat1->field_10 - rndF) * (double)((bat2->currY - bat1->currY) >= 0 ? 1 : -1) * bat1->power; + double pow1x = cos(bat1->angle - rndF) * (double)((bat2->currX - bat1->currX) >= 0 ? 1 : -1) * bat1->power; + double pow1y = sin(bat1->angle - rndF) * (double)((bat2->currY - bat1->currY) >= 0 ? 1 : -1) * bat1->power; + + debugC(3, kDebugSceneLogic, "scene27: knockBats: bat1 from: powerCos: %f powerSin: %f, power: %f, angle: %f", + bat1->powerCos, bat1->powerSin, bat1->power, bat1->angle); bat1->powerCos -= pow1x * 1.1; bat1->powerSin -= pow1y * 1.1; + debugC(3, kDebugSceneLogic, "scene27: knockBats: bat1 to: powerCos: %f powerSin: %f", bat1->powerCos, bat1->powerSin); + rndF = ((double)g_fp->_rnd->getRandomNumber(32767) * 0.0000009155552842799158 - 0.015 + atan2(bat1->currY - bat2->currY, bat1->currX - bat2->currX)); - double pow2x = cos(bat2->field_10 - rndF) * (double)((bat1->currX - bat2->currX) >= 0 ? 1 : -1) * bat2->power; - double pow2y = sin(bat2->field_10 - rndF) * (double)((bat1->currY - bat2->currY) >= 0 ? 1 : -1) * bat2->power; + double pow2x = cos(bat2->angle - rndF) * (double)((bat1->currX - bat2->currX) >= 0 ? 1 : -1) * bat2->power; + double pow2y = sin(bat2->angle - rndF) * (double)((bat1->currY - bat2->currY) >= 0 ? 1 : -1) * bat2->power; + + debugC(3, kDebugSceneLogic, "scene27: knockBats: bat2 from: powerCos: %f powerSin: %f, power: %f, angle: %f", + bat2->powerCos, bat2->powerSin, bat2->power, bat2->angle); bat2->powerCos -= pow2x * 1.1; bat2->powerSin -= pow2y * 1.1; + debugC(3, kDebugSceneLogic, "scene27: knockBats: bat2 to: powerCos: %f powerSin: %f", bat2->powerCos, bat2->powerSin); + double dy = bat1->currY - bat2->currY; double dx = bat1->currX - bat2->currX; - double dist = (sqrt(rndSin * rndSin * 0.25 + rndCos * rndCos) * 54.0 - sqrt(dx * dx + dy * dy)) / cos(rndF - bat1->field_10); - bat1->currX = (double)bat1->currX - cos(bat1->field_10) * (dist + 1.0); - bat1->currY = (double)bat1->currY - sin(bat1->field_10) * (dist + 1.0); + double dist = (sqrt(rndSin * rndSin * 0.25 + rndCos * rndCos) * 54.0 - sqrt(dx * dx + dy * dy)) / cos(rndF - bat1->angle); + bat1->currX = (double)bat1->currX - cos(bat1->angle) * (dist + 1.0); + bat1->currY = (double)bat1->currY - sin(bat1->angle) * (dist + 1.0); bat1->powerCos += pow2x * 0.64; + debugC(3, kDebugSceneLogic, "scene27: knockBats: bat1 x: %g y: %g", bat1->currX, bat1->currY); + if (bat1->currX <= 500.0) bat1->powerSin = 0.0; else bat1->powerSin += pow2y * 0.64; - bat1->field_10 = atan2(bat1->powerSin, bat1->powerCos); + bat1->angle = atan2(bat1->powerSin, bat1->powerCos); bat1->power = sqrt(bat1->powerCos * bat1->powerCos + bat1->powerSin * bat1->powerSin); + debugC(3, kDebugSceneLogic, "scene27: knockBats: bat1 corrected: powerCos: %f powerSin: %f, power: %f, angle: %f", + bat1->powerCos, bat1->powerSin, bat1->power, bat1->angle); + bat2->powerCos += pow1x * 0.64; if (bat2->currX <= 500.0) @@ -377,9 +395,12 @@ void sceneHandler27_knockBats(int bat1n, int bat2n) { else bat2->powerSin += pow1y * 0.64; - bat2->field_10 = atan2(bat2->powerSin, bat2->powerCos); + bat2->angle = atan2(bat2->powerSin, bat2->powerCos); bat2->power = sqrt(bat2->powerCos * bat2->powerCos + bat2->powerSin * bat2->powerSin); + debugC(3, kDebugSceneLogic, "scene27: knockBats: bat2 corrected: powerCos: %f powerSin: %f, power: %f, angle: %f", + bat2->powerCos, bat2->powerSin, bat2->power, bat2->angle); + g_fp->playSound(SND_27_026, 0); } } @@ -541,22 +562,22 @@ void sceneHandler27_animateBats() { for (uint i = 0; i < g_vars->scene27_bats.size(); i++) { Bat *bat = g_vars->scene27_bats[i]; - bat->currX = cos(bat->field_10) * bat->power + bat->currX; - bat->currY = sin(bat->field_10) * bat->power + bat->currY; + bat->currX = cos(bat->angle) * bat->power + bat->currX; + bat->currY = sin(bat->angle) * bat->power + bat->currY; bat->ani->setOXY((int)bat->currX, (int)bat->currY); bat->ani->_priority = (int)(600.0 - bat->currY); double powerDelta; - if (cos(bat->field_10) >= 0.0 || bat->currX >= 362.0) + if (cos(bat->angle) >= 0.0 || bat->currX >= 362.0) powerDelta = bat->power * 0.035; else powerDelta = bat->power * 0.4; bat->power -= powerDelta; - bat->powerCos = cos(bat->field_10) * bat->power; - bat->powerSin = sin(bat->field_10) * bat->power; + bat->powerCos = cos(bat->angle) * bat->power; + bat->powerSin = sin(bat->angle) * bat->power; if (bat->power >= 0.5) g_vars->scene27_knockCount++; |