ref: e04f4184f4ec34c621e3d9bcdec6af442c4dbdf5
parent: d6d063ab9a6f4ebd16c9901017fc1160ec8438dc
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sun Nov 17 09:29:25 EST 2019
Clean-up BossFrog.cpp Also removed SECONDS_TO_FRAMES because Pixel inconsistently times to 50FPS and 60FPS, making assumptions like this too shaky.
--- a/src/BossFrog.cpp
+++ b/src/BossFrog.cpp
@@ -210,7 +210,9 @@
boss->act_wait = 0;
// Fallthrough
case BALFROG_FLICKER:
- if (++boss->act_wait / 2 % 2)
+ ++boss->act_wait;
+
+ if (boss->act_wait / 2 % 2)
boss->ani_no = BALFROG_SPRITE_MOUTH_OPEN_CROUCHING;
else
boss->ani_no = BALFROG_SPRITE_NOTHING;
@@ -224,7 +226,9 @@
boss->xm = 0;
// Fallthrough
case BALFROG_INITIALIZE_HOP_1:
- if (++boss->act_wait > SECONDS_TO_FRAMES(1))
+ ++boss->act_wait;
+
+ if (boss->act_wait > 50)
{
boss->act_no = BALFROG_INITIALIZE_HOP_2;
boss->ani_wait = 0;
@@ -234,7 +238,9 @@
break;
case BALFROG_INITIALIZE_HOP_2:
- if (++boss->ani_wait > 10)
+ ++boss->ani_wait;
+
+ if (boss->ani_wait > 10)
{
boss->act_no = BALFROG_HOP;
boss->ani_wait = 0;
@@ -244,7 +250,9 @@
break;
case BALFROG_HOP:
- if (++boss->ani_wait > 4)
+ ++boss->ani_wait;
+
+ if (boss->ani_wait > 4)
{
boss->act_no = BALFROG_MIDAIR;
boss->ani_no = BALFROG_SPRITE_JUMPING;
@@ -311,9 +319,10 @@
// Fallthrough
case BALFROG_LAND:
++boss->act_wait;
- boss->xm = 8 * boss->xm / 9;
- if (boss->act_wait > SECONDS_TO_FRAMES(1))
+ boss->xm = (boss->xm * 8) / 9;
+
+ if (boss->act_wait > 50)
{
boss->ani_no = BALFROG_SPRITE_MOUTH_BARELY_OPEN_CROUCHING;
boss->ani_wait = 0;
@@ -323,7 +332,9 @@
break;
case BALFROG_INITIALIZE_SHOOT:
- if (++boss->ani_wait > 4)
+ ++boss->ani_wait;
+
+ if (boss->ani_wait > 4)
{
boss->act_no = BALFROG_SHOOT;
boss->act_wait = 0;
@@ -336,7 +347,7 @@
break;
case BALFROG_SHOOT:
- if (boss->shock)
+ if (boss->shock != 0)
{
if (boss->count2++ / 2 % 2)
boss->ani_no = BALFROG_SPRITE_MOUTH_OPEN_CROUCHING_FLASHING;
@@ -349,9 +360,11 @@
boss->ani_no = BALFROG_SPRITE_MOUTH_OPEN_CROUCHING;
}
- boss->xm = 10 * boss->xm / 11;
+ boss->xm = (boss->xm * 10) / 11;
- if (++boss->act_wait > 16)
+ ++boss->act_wait;
+
+ if (boss->act_wait > 16)
{
boss->act_wait = 0;
--boss->count1;
@@ -386,7 +399,9 @@
break;
case BALFROG_AFTER_SHOOT_WAIT:
- if (++boss->ani_wait > 10)
+ ++boss->ani_wait;
+
+ if (boss->ani_wait > 10)
{
if (++gBoss[1].count1 > 2)
{
@@ -411,7 +426,9 @@
boss->xm = 0;
// Fallthrough
case BALFROG_INITIALIZE_LEAP_2:
- if (++boss->act_wait > SECONDS_TO_FRAMES(1))
+ ++boss->act_wait;
+
+ if (boss->act_wait > 50)
{
boss->act_no = BALFROG_INITIALIZE_LEAP_3;
boss->ani_wait = 0;
@@ -421,7 +438,9 @@
break;
case BALFROG_INITIALIZE_LEAP_3:
- if (++boss->ani_wait > 20)
+ ++boss->ani_wait;
+
+ if (boss->ani_wait > 20)
{
boss->act_no = BALFROG_LEAP;
boss->ani_wait = 0;
@@ -431,7 +450,9 @@
break;
case BALFROG_LEAP:
- if (++boss->ani_wait > 4)
+ ++boss->ani_wait;
+
+ if (boss->ani_wait > 4)
{
boss->act_no = BALFROG_LEAP_MIDAIR;
boss->ani_no = BALFROG_SPRITE_JUMPING;
@@ -491,7 +512,9 @@
gBoss[2].cond = 0;
// Fallthrough
case BALFROG_DIE_FLASHING:
- if (++boss->act_wait % 5 == 0)
+ ++boss->act_wait;
+
+ if (boss->act_wait % 5 == 0)
SetNpChar(NPC_SMOKE, boss->x + PIXELS_TO_UNITS(Random(-12, 12)), boss->y + PIXELS_TO_UNITS(Random(-12, 12)), Random(-341, 341), Random(PIXELS_TO_UNITS(-3), 0), DIR_LEFT, NULL, 0x100);
if (boss->act_wait / 2 % 2)
@@ -499,7 +522,7 @@
else
boss->x += PIXELS_TO_UNITS(1);
- if (boss->act_wait > SECONDS_TO_FRAMES(2))
+ if (boss->act_wait > 100)
{
boss->act_wait = 0;
boss->act_no = BALFROG_REVERT;
@@ -508,7 +531,9 @@
break;
case BALFROG_REVERT:
- if (++boss->act_wait / 2 % 2)
+ ++boss->act_wait;
+
+ if (boss->act_wait / 2 % 2)
{
boss->view.front = PIXELS_TO_UNITS(20);
boss->view.top = PIXELS_TO_UNITS(12);
@@ -528,7 +553,7 @@
if (boss->act_wait % 9 == 0)
SetNpChar(NPC_SMOKE, boss->x + PIXELS_TO_UNITS(Random(-12, 12)), boss->y + PIXELS_TO_UNITS(Random(-12, 12)), Random(-341, 341), Random(PIXELS_TO_UNITS(-3), 0), DIR_LEFT, NULL, 0x100);
- if (boss->act_wait > SECONDS_TO_FRAMES(3))
+ if (boss->act_wait > 150)
{
boss->act_no = BALFROG_NOP_START;
boss->hit.bottom = PIXELS_TO_UNITS(12);
@@ -550,7 +575,9 @@
break;
case BALFROG_GO_INTO_CEILING:
- if (++boss->act_wait > 30)
+ ++boss->act_wait;
+
+ if (boss->act_wait > 30)
{
boss->ani_no = BALFROG_SPRITE_BALROG_JUMPING;
boss->ym = PIXELS_TO_UNITS(-5);
--- a/src/CommonDefines.h
+++ b/src/CommonDefines.h
@@ -10,9 +10,6 @@
#define TILES_TO_UNITS(x) ((int)((x) * (0x200 * 0x10)))
#define UNITS_TO_TILES(x) ((int)((x) / (0x200 * 0x10)))
-#define SECONDS_TO_FRAMES(x) ((int)((x) * 50))
-#define FRAMES_TO_SECONDS(x) ((int)((x) / 50))
-
enum Collisions
{
COLL_LEFT_WALL = 1, // Touching a left wall