Skip to content

Commit

Permalink
Better 2D. Moving bombs during hanging part. Pipes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reonu committed Mar 23, 2021
1 parent 6872e5b commit fe7f8fe
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 15 deletions.
2 changes: 1 addition & 1 deletion data/behavior_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ const BehaviorScript bhvWarpPipe[] = {
SET_INT(oIntangibleTimer, 0),
SET_HITBOX(/*Radius*/ 70, /*Height*/ 50),
BEGIN_LOOP(),
CALL_NATIVE(bhv_warp_loop),
CALL_NATIVE(bhv_warp_pipe_loop),
CALL_NATIVE(load_object_collision_model),
END_LOOP(),
};
Expand Down
1 change: 1 addition & 0 deletions src/game/behavior_actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ void bhv_yoshi_loop(void);
void bhv_volcano_trap_loop(void);
void bhv_green_spring_loop(void);
void bhv_green_spring_init(void);
void bhv_warp_pipe_loop(void);

Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx);

Expand Down
32 changes: 27 additions & 5 deletions src/game/behaviors/bowser_bomb.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,39 @@ void bhv_bowser_bomb_loop(void) {
set_camera_shake_from_point(SHAKE_POS_LARGE, o->oPosX, o->oPosY, o->oPosZ);
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
if (o->oBehParams != 0) {
if (o->oBehParams > 5) {
if (o->oTimer >= o->oBehParams) {
o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
o->oPosZ = o->oPosZ - 65;
}
else {
o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
}
else {
o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
if (o->oPosZ < -15000) {
obj_mark_for_deletion(o);
}
}
if (o->oPosZ < -15000) {
obj_mark_for_deletion(o);
if (o->oBehParams == 2) {
if (o->oTimer < 60) {
o->oPosX += 15;
}
else if (o->oTimer < 120) {
o->oPosX -= 15;
}
else {
o->oTimer = -1;
}
}
if (o->oBehParams == 4) {
if (o->oTimer < 60) {
o->oPosX -= 15;
}
else if (o->oTimer < 120) {
o->oPosX += 15;
}
else {
o->oTimer = -1;
}
}

}
Expand Down
1 change: 1 addition & 0 deletions src/game/behaviors/green_spring.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void bhv_green_spring_loop(void) {
if (o->oAction == 1) {
if (o->oTimer < 4) {
o->header.gfx.scale[1] -= 0.125f;
gMarioState->action = ACT_DOUBLE_JUMP;
}
else if (o->oTimer < 8) {
o->header.gfx.scale[1] += 0.125f;
Expand Down
17 changes: 17 additions & 0 deletions src/game/behaviors/warp.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ void bhv_warp_loop(void) {
o->oInteractStatus = 0;
}

void bhv_warp_pipe_loop(void) {
u16 sp6;
if (gCurrLevelNum == LEVEL_BOB && gCurrAreaIndex == 1) {
obj_mark_for_deletion(o);
}

sp6 = (o->oBehParams >> 24) & 0xFF;
if (sp6 == 0)
o->hitboxRadius = 50.0f;
else if (sp6 == 0xFF)
o->hitboxRadius = 10000.0f;
else
o->hitboxRadius = sp6 * 10.0;
o->hitboxHeight = 50.0f;
o->oInteractStatus = 0;
}

void bhv_fading_warp_loop() // identical to the above function except for o->hitboxRadius
{
u16 sp6;
Expand Down
2 changes: 1 addition & 1 deletion src/game/hud.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void render_hud_power_meter(void) {
void render_hud_mario_lives(void) {
print_text(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(22), HUD_TOP_Y, ","); // 'Mario Head' glyph
print_text(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(38), HUD_TOP_Y, "*"); // 'X' glyph
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(54), HUD_TOP_Y, "%d", gMarioState->pos[2]);
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(54), HUD_TOP_Y, "%d", gMarioState->faceAngle[1]);
}

/**
Expand Down
30 changes: 28 additions & 2 deletions src/game/mario.c
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ if (gCurrLevelNum != LEVEL_ENDING) {
}
}
}

extern s16 s8DirModeBaseYaw;

if (gMarioState->action) {
gMarioState->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
Expand All @@ -1742,7 +1742,33 @@ if (gCurrLevelNum != LEVEL_ENDING) {
return 0;
}
if ((gCurrAreaIndex == 5) || (gCurrAreaIndex == 6)) {
gMarioState->pos[0] = 0;
if (!(gMarioState->action & ACT_FLAG_HANGING) && !(gMarioState->action & ACT_READING_SIGN)){
gMarioState->pos[0] = 0;
if ((gMarioState->faceAngle[1] < 0x4000) && (gMarioState->faceAngle[1] > -0x4000)){
gMarioState->faceAngle[1] = 0;
gMarioState->marioBodyState->torsoAngle[1] = 0;
gMarioState->marioBodyState->torsoAngle[2] = 0;
}
else {
gMarioState->faceAngle[1] = 0x8000;
gMarioState->marioBodyState->torsoAngle[1] = 0;
gMarioState->marioBodyState->torsoAngle[2] = 0;
}
if (gMarioState->action == ACT_WALKING) {
if (analog_stick_held_back() && gMarioState->forwardVel < 16.0f && gMarioState->forwardVel > -16.0f) {
if (!(gMarioState->action == ACT_TURNING_AROUND)) {
//set_mario_action(gMarioState, ACT_TURNING_AROUND, 0);
if ((gMarioState->faceAngle[1] < 0x4000) && (gMarioState->faceAngle[1] > -0x4000)){
gMarioState->faceAngle[1] = 0x8000;
}
else {
gMarioState->faceAngle[1] = 0;
}

}
}
}
}
}
// The function can loop through many action shifts in one frame,
// which can lead to unexpected sub-frame behavior. Could potentially hang
Expand Down
4 changes: 2 additions & 2 deletions src/game/mario_actions_automatic.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,15 @@ s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos) {
s32 update_hang_moving(struct MarioState *m) {
s32 stepResult;
Vec3f nextPos;
f32 maxSpeed = 10.0f;
f32 maxSpeed = 12.0f;

m->forwardVel += 1.0f;
if (m->forwardVel > maxSpeed) {
m->forwardVel = maxSpeed;
}

m->faceAngle[1] =
m->intendedYaw - approach_s32((s16)(m->intendedYaw - m->faceAngle[1]), 0, 0x800, 0x800);
m->intendedYaw;

m->slideYaw = m->faceAngle[1];
m->slideVelX = m->forwardVel * sins(m->faceAngle[1]);
Expand Down
8 changes: 4 additions & 4 deletions text/us/dialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ this royal turf? I think\n\
that you cannot!"))

DEFINE_DIALOG(DIALOG_018, 1, 4, 30, 200, _("\
I'm sleeping because...\n\
...I'm sleepy. I don't\n\
like being disturbed.\n\
Please walk quietly."))
Did you know? Hanging\n\
from a ceiling gives\n\
you the power to\n\
move in 3D!"))

DEFINE_DIALOG(DIALOG_019, 1, 2, 30, 200, _("\
Shhh! Please walk\n\
Expand Down

0 comments on commit fe7f8fe

Please sign in to comment.