Distinguish clearly the two enums related to speed

This commit is contained in:
cbt6
2021-11-03 02:51:30 +08:00
parent 3f5f057ebe
commit 3556024a06
2 changed files with 18 additions and 18 deletions
+5 -5
View File
@@ -17,11 +17,11 @@ struct BikeHistoryInputInfo
// Player speeds // Player speeds
enum enum
{ {
SPEED_STANDING, BIKE_SPEED_STANDING,
SPEED_NORMAL, BIKE_SPEED_NORMAL,
SPEED_FAST, BIKE_SPEED_FAST,
SPEED_FASTER, BIKE_SPEED_FASTER,
SPEED_FASTEST, BIKE_SPEED_FASTEST,
}; };
// mach bike transitions enum // mach bike transitions enum
+13 -13
View File
@@ -108,7 +108,7 @@ static u8 (*const sAcroBikeInputHandlers[])(u8 *, u16, u16) =
}; };
// used with bikeFrameCounter from mach bike // used with bikeFrameCounter from mach bike
static const u16 sMachBikeSpeeds[] = {SPEED_NORMAL, SPEED_FAST, SPEED_FASTEST}; static const u16 sMachBikeSpeeds[] = {BIKE_SPEED_NORMAL, BIKE_SPEED_FAST, BIKE_SPEED_FASTEST};
// this is a list of timers to compare against later, terminated with 0. the only timer being compared against is 4 frames in this list. // this is a list of timers to compare against later, terminated with 0. the only timer being compared against is 4 frames in this list.
static const u8 sAcroBikeJumpTimerList[] = {4, 0}; static const u8 sAcroBikeJumpTimerList[] = {4, 0};
@@ -147,7 +147,7 @@ static u8 GetMachBikeTransition(u8 *dirTraveling)
if (*dirTraveling == 0) if (*dirTraveling == 0)
{ {
*dirTraveling = direction; // update the direction, since below we either faced a direction or we started moving. *dirTraveling = direction; // update the direction, since below we either faced a direction or we started moving.
if (gPlayerAvatar.bikeSpeed == SPEED_STANDING) if (gPlayerAvatar.bikeSpeed == BIKE_SPEED_STANDING)
{ {
gPlayerAvatar.runningState = NOT_MOVING; gPlayerAvatar.runningState = NOT_MOVING;
return MACH_TRANS_FACE_DIRECTION; return MACH_TRANS_FACE_DIRECTION;
@@ -159,7 +159,7 @@ static u8 GetMachBikeTransition(u8 *dirTraveling)
// we need to check if the last traveled direction changed from the new direction as well as ensuring that we dont update the state while the player is moving: see the else check. // we need to check if the last traveled direction changed from the new direction as well as ensuring that we dont update the state while the player is moving: see the else check.
if (*dirTraveling != direction && gPlayerAvatar.runningState != MOVING) if (*dirTraveling != direction && gPlayerAvatar.runningState != MOVING)
{ {
if (gPlayerAvatar.bikeSpeed != SPEED_STANDING) if (gPlayerAvatar.bikeSpeed != BIKE_SPEED_STANDING)
{ {
*dirTraveling = direction; // implement the new direction *dirTraveling = direction; // implement the new direction
gPlayerAvatar.runningState = MOVING; gPlayerAvatar.runningState = MOVING;
@@ -246,7 +246,7 @@ static void MachBikeTransition_TrySlowDown(u8 direction)
{ {
u8 collision; u8 collision;
if (gPlayerAvatar.bikeSpeed != SPEED_STANDING) if (gPlayerAvatar.bikeSpeed != BIKE_SPEED_STANDING)
gPlayerAvatar.bikeFrameCounter = --gPlayerAvatar.bikeSpeed; gPlayerAvatar.bikeFrameCounter = --gPlayerAvatar.bikeSpeed;
collision = GetBikeCollision(direction); collision = GetBikeCollision(direction);
@@ -306,7 +306,7 @@ static u8 AcroBikeHandleInputNormal(u8 *newDirection, u16 newKeys, u16 heldKeys)
return ACRO_TRANS_FACE_DIRECTION; return ACRO_TRANS_FACE_DIRECTION;
} }
} }
if (*newDirection == direction && (heldKeys & B_BUTTON) && gPlayerAvatar.bikeSpeed == SPEED_STANDING) if (*newDirection == direction && (heldKeys & B_BUTTON) && gPlayerAvatar.bikeSpeed == BIKE_SPEED_STANDING)
{ {
gPlayerAvatar.bikeSpeed++; gPlayerAvatar.bikeSpeed++;
gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING; gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING;
@@ -342,7 +342,7 @@ static u8 AcroBikeHandleInputTurning(u8 *newDirection, u16 newKeys, u16 heldKeys
if (*newDirection == AcroBike_GetJumpDirection()) if (*newDirection == AcroBike_GetJumpDirection())
{ {
Bike_SetBikeStill(); // Bike_SetBikeStill sets speed to standing, but the next line immediately overrides it. could have just reset acroBikeState to 0 here instead of wasting a jump. Bike_SetBikeStill(); // Bike_SetBikeStill sets speed to standing, but the next line immediately overrides it. could have just reset acroBikeState to 0 here instead of wasting a jump.
gPlayerAvatar.bikeSpeed = SPEED_NORMAL; gPlayerAvatar.bikeSpeed = BIKE_SPEED_NORMAL;
if (*newDirection == GetOppositeDirection(direction)) if (*newDirection == GetOppositeDirection(direction))
{ {
// do a turn jump. // do a turn jump.
@@ -775,7 +775,7 @@ static void AcroBike_TryHistoryUpdate(u16 newKeys, u16 heldKeys) // newKeys is u
else else
{ {
Bike_UpdateDirTimerHistory(direction); Bike_UpdateDirTimerHistory(direction);
gPlayerAvatar.bikeSpeed = SPEED_STANDING; gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING;
} }
direction = heldKeys & (A_BUTTON | B_BUTTON | SELECT_BUTTON | START_BUTTON); // directions is reused for some reason. direction = heldKeys & (A_BUTTON | B_BUTTON | SELECT_BUTTON | START_BUTTON); // directions is reused for some reason.
@@ -787,7 +787,7 @@ static void AcroBike_TryHistoryUpdate(u16 newKeys, u16 heldKeys) // newKeys is u
else else
{ {
Bike_UpdateABStartSelectHistory(direction); Bike_UpdateABStartSelectHistory(direction);
gPlayerAvatar.bikeSpeed = SPEED_STANDING; gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING;
} }
} }
@@ -994,7 +994,7 @@ void BikeClearState(int newDirHistory, int newAbStartHistory)
gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
gPlayerAvatar.newDirBackup = DIR_NONE; gPlayerAvatar.newDirBackup = DIR_NONE;
gPlayerAvatar.bikeFrameCounter = 0; gPlayerAvatar.bikeFrameCounter = 0;
gPlayerAvatar.bikeSpeed = SPEED_STANDING; gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING;
gPlayerAvatar.directionHistory = newDirHistory; gPlayerAvatar.directionHistory = newDirHistory;
gPlayerAvatar.abStartSelectHistory = newAbStartHistory; gPlayerAvatar.abStartSelectHistory = newAbStartHistory;
@@ -1014,7 +1014,7 @@ void Bike_UpdateBikeCounterSpeed(u8 counter)
static void Bike_SetBikeStill(void) static void Bike_SetBikeStill(void)
{ {
gPlayerAvatar.bikeFrameCounter = 0; gPlayerAvatar.bikeFrameCounter = 0;
gPlayerAvatar.bikeSpeed = SPEED_STANDING; gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING;
} }
s16 GetPlayerSpeed(void) s16 GetPlayerSpeed(void)
@@ -1027,11 +1027,11 @@ s16 GetPlayerSpeed(void)
if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE) if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE)
return machSpeeds[gPlayerAvatar.bikeFrameCounter]; return machSpeeds[gPlayerAvatar.bikeFrameCounter];
else if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE) else if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE)
return SPEED_FASTER; return BIKE_SPEED_FASTER;
else if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_DASH)) else if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_DASH))
return SPEED_FAST; return BIKE_SPEED_FAST;
else else
return SPEED_NORMAL; return BIKE_SPEED_NORMAL;
} }
void Bike_HandleBumpySlopeJump(void) void Bike_HandleBumpySlopeJump(void)