Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Common/FlingRamp.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: FlingRamp Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectFlingRamp *FlingRamp;
11
12
void FlingRamp_Update(void)
13
{
14
RSDK_THIS(FlingRamp);
15
16
foreach_active(Player, player)
17
{
18
if (player->onGround) {
19
bool32 left = self->direction == FLIP_NONE || self->direction == FLIP_X;
20
bool32 right = self->direction == FLIP_NONE || self->direction == FLIP_Y;
21
22
if (left && !(player->direction & FLIP_X) && player->velocity.x >= 0x40000) {
23
if (Player_CheckCollisionTouch(player, self, &FlingRamp->hitboxRamp)) {
24
player->velocity.x += TO_FIXED(4);
25
player->velocity.y = -TO_FIXED(7);
26
27
// Bug Details:
28
// this one's the same bug I detailed in SPZ/RockemSockem and was shown off in SDCC 2017
29
// if you glide into the fling ramp as knux the state wont be set to air so you'll be gliding with SPRINGCS anim playing
30
// Fix: set the state to Player_State_Air (see fix commented below)
31
// player->state = Player_State_Air;
32
player->onGround = false;
33
RSDK.SetSpriteAnimation(player->aniFrames, ANI_SPRING_CS, &player->animator, true, 0);
34
}
35
}
36
else if (right && (player->direction & FLIP_X) && player->velocity.x <= -0x40000) {
37
if (Player_CheckCollisionTouch(player, self, &FlingRamp->hitboxRamp)) {
38
player->velocity.x -= TO_FIXED(4);
39
player->velocity.y = -TO_FIXED(7);
40
41
// Bug Details:
42
// this one's the same bug I detailed in SPZ/RockemSockem and was shown off in SDCC 2017
43
// if you glide into the fling ramp as knux the state wont be set to air so you'll be gliding with SPRINGCS anim playing
44
// Fix: set the state to Player_State_Air (see fix commented below)
45
// player->state = Player_State_Air;
46
player->onGround = false;
47
RSDK.SetSpriteAnimation(player->aniFrames, ANI_SPRING_CS, &player->animator, true, 0);
48
}
49
}
50
}
51
}
52
}
53
54
void FlingRamp_LateUpdate(void) {}
55
56
void FlingRamp_StaticUpdate(void) {}
57
58
void FlingRamp_Draw(void) {}
59
60
void FlingRamp_Create(void *data)
61
{
62
RSDK_THIS(FlingRamp);
63
64
if (!SceneInfo->inEditor) {
65
self->active = ACTIVE_BOUNDS;
66
self->visible = false;
67
}
68
}
69
70
void FlingRamp_StageLoad(void)
71
{
72
FlingRamp->hitboxRamp.left = -16;
73
FlingRamp->hitboxRamp.top = -16;
74
FlingRamp->hitboxRamp.right = 16;
75
FlingRamp->hitboxRamp.bottom = 16;
76
}
77
78
#if GAME_INCLUDE_EDITOR
79
void FlingRamp_EditorDraw(void)
80
{
81
RSDK_THIS(FlingRamp);
82
83
Animator animator;
84
RSDK.SetSpriteAnimation(FlingRamp->hitboxRamp.left, 0, &animator, true, 6);
85
RSDK.DrawSprite(&animator, NULL, false);
86
87
if (showGizmos()) {
88
RSDK_DRAWING_OVERLAY(true);
89
90
if (self->direction < FLIP_Y)
91
DrawHelpers_DrawArrow(self->position.x, self->position.y, self->position.x - 0x300000, self->position.y, 0xFFFF00, INK_NONE, 0xFF);
92
93
if (self->direction != FLIP_X)
94
DrawHelpers_DrawArrow(self->position.x, self->position.y, self->position.x + 0x300000, self->position.y, 0xFFFF00, INK_NONE, 0xFF);
95
96
RSDK_DRAWING_OVERLAY(false);
97
}
98
}
99
100
void FlingRamp_EditorLoad(void)
101
{
102
FlingRamp->hitboxRamp.left = RSDK.LoadSpriteAnimation("Editor/EditorIcons.bin", SCOPE_STAGE);
103
104
RSDK_ACTIVE_VAR(FlingRamp, direction);
105
RSDK_ENUM_VAR("Omni", FLIP_NONE);
106
RSDK_ENUM_VAR("Right", FLIP_X);
107
RSDK_ENUM_VAR("Left", FLIP_Y);
108
}
109
#endif
110
111
void FlingRamp_Serialize(void) { RSDK_EDITABLE_VAR(FlingRamp, VAR_UINT8, direction); }
112
113