aboutsummaryrefslogtreecommitdiff
path: root/engines/fullpipe
diff options
context:
space:
mode:
authorEugene Sandulenko2014-02-05 23:51:27 +0200
committerEugene Sandulenko2014-02-05 23:58:43 +0200
commitff50ea73bf98445faf30cfda2482d532ed5c2a38 (patch)
tree9740cee79ec2b1272251140d60262575c8996e56 /engines/fullpipe
parent7ece1b1ea6e10e4f358d86cfdb741dfbfe30eaf3 (diff)
downloadscummvm-rg350-ff50ea73bf98445faf30cfda2482d532ed5c2a38.tar.gz
scummvm-rg350-ff50ea73bf98445faf30cfda2482d532ed5c2a38.tar.bz2
scummvm-rg350-ff50ea73bf98445faf30cfda2482d532ed5c2a38.zip
FULLPIPE: Implement sceneHandler27_knockBats()
Diffstat (limited to 'engines/fullpipe')
-rw-r--r--engines/fullpipe/constants.h1
-rw-r--r--engines/fullpipe/scenes/scene27.cpp52
2 files changed, 51 insertions, 2 deletions
diff --git a/engines/fullpipe/constants.h b/engines/fullpipe/constants.h
index 92d66933af..730dc7194e 100644
--- a/engines/fullpipe/constants.h
+++ b/engines/fullpipe/constants.h
@@ -1102,6 +1102,7 @@ namespace Fullpipe {
#define QU_DRV_GIVEVENT 2040
#define QU_MID_CLEANVENT 4583
#define QU_SC27_SHOWBET 3368
+#define SND_27_026 4127
#define SND_27_027 4128
#define SND_27_044 4687
#define ST_BTA_FALL 2054
diff --git a/engines/fullpipe/scenes/scene27.cpp b/engines/fullpipe/scenes/scene27.cpp
index ef765bed09..6ca0cb8fc0 100644
--- a/engines/fullpipe/scenes/scene27.cpp
+++ b/engines/fullpipe/scenes/scene27.cpp
@@ -362,8 +362,56 @@ bool sceneHandler27_batCalcDistance(int bat1, int bat2) {
return sqrt(ax * ax * 0.25 + ay * ay) * 54.0 > sqrt(dx * dx + dy * dy);
}
-void sceneHandler27_knockBats(int bat1, int bat2) {
- warning("STUB: sceneHandler27_knockBats()");
+void sceneHandler27_knockBats(int bat1n, int bat2n) {
+ Bat *bat1 = g_vars->scene27_bats[bat1n];
+ Bat *bat2 = g_vars->scene27_bats[bat2n];
+
+ if (0.0 != bat1->power) {
+ double rndF = (double)g_fp->_rnd->getRandomNumber(32767) * 0.0000009155552842799158 - 0.015
+ + atan2(bat2->currX - bat1->currX, bat2->currY - bat1->currY);
+ double rndCos = cos(rndF);
+ double rndSin = sin(rndF);
+
+ double pow1x = cos(bat1->field_10 - rndF) * (double)((int)(bat2->currX - bat1->currX) >= 0 ? 1 : -1) * bat1->power;
+ double pow1y = sin(bat1->field_10 - rndF) * (double)((int)(bat2->currY - bat1->currY) >= 0 ? 1 : -1) * bat1->power;
+
+ bat1->powerCos -= pow1x * 1.1;
+ bat1->powerSin -= pow1y * 1.1;
+
+ rndF = ((double)g_fp->_rnd->getRandomNumber(32767) * 0.0000009155552842799158 - 0.015
+ + atan2(bat1->currX - bat2->currX, bat1->currY - bat2->currY));
+ double pow2x = cos(bat2->field_10 - rndF) * (double)((int)(bat1->currX - bat2->currX) >= 0 ? 1 : -1) * bat2->power;
+ double pow2y = sin(bat2->field_10 - rndF) * (double)((int)(bat1->currY - bat2->currY) >= 0 ? 1 : -1) * bat2->power;
+
+ bat2->powerCos -= pow2x * 1.1;
+ bat2->powerSin -= pow2y * 1.1;
+
+ 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 -= cos(bat1->field_10) * (dist + 1.0);
+ bat1->currY -= sin(bat1->field_10) * (dist + 1.0);
+ bat1->powerCos += pow2x * 0.64;
+
+ if (bat1->currX <= 500.0)
+ bat1->powerSin = 0.0;
+ else
+ bat1->powerSin += pow2y * 0.64;
+
+ bat1->field_10 = atan2(bat1->powerCos, bat1->powerSin);
+ bat1->power = sqrt(bat1->powerCos * bat1->powerCos + bat1->powerSin * bat1->powerSin);
+ bat2->powerCos += pow1x * 0.64;
+
+ if (bat2->currX <= 500.0)
+ bat2->powerSin = 0;
+ else
+ bat2->powerSin += pow1y * 0.64;
+
+ bat2->field_10 = atan2(bat2->powerCos, bat2->powerSin);
+ bat2->power = sqrt(bat2->powerCos * bat2->powerCos + bat2->powerSin * bat2->powerSin);
+
+ g_fp->playSound(SND_27_026, 0);
+ }
}
void sceneHandler27_batSetColors(int batn) {