Path: blob/master/SonicMania/Objects/Common/FlingRamp.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: FlingRamp Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectFlingRamp *FlingRamp;1011void FlingRamp_Update(void)12{13RSDK_THIS(FlingRamp);1415foreach_active(Player, player)16{17if (player->onGround) {18bool32 left = self->direction == FLIP_NONE || self->direction == FLIP_X;19bool32 right = self->direction == FLIP_NONE || self->direction == FLIP_Y;2021if (left && !(player->direction & FLIP_X) && player->velocity.x >= 0x40000) {22if (Player_CheckCollisionTouch(player, self, &FlingRamp->hitboxRamp)) {23player->velocity.x += TO_FIXED(4);24player->velocity.y = -TO_FIXED(7);2526// Bug Details:27// this one's the same bug I detailed in SPZ/RockemSockem and was shown off in SDCC 201728// if you glide into the fling ramp as knux the state wont be set to air so you'll be gliding with SPRINGCS anim playing29// Fix: set the state to Player_State_Air (see fix commented below)30// player->state = Player_State_Air;31player->onGround = false;32RSDK.SetSpriteAnimation(player->aniFrames, ANI_SPRING_CS, &player->animator, true, 0);33}34}35else if (right && (player->direction & FLIP_X) && player->velocity.x <= -0x40000) {36if (Player_CheckCollisionTouch(player, self, &FlingRamp->hitboxRamp)) {37player->velocity.x -= TO_FIXED(4);38player->velocity.y = -TO_FIXED(7);3940// Bug Details:41// this one's the same bug I detailed in SPZ/RockemSockem and was shown off in SDCC 201742// if you glide into the fling ramp as knux the state wont be set to air so you'll be gliding with SPRINGCS anim playing43// Fix: set the state to Player_State_Air (see fix commented below)44// player->state = Player_State_Air;45player->onGround = false;46RSDK.SetSpriteAnimation(player->aniFrames, ANI_SPRING_CS, &player->animator, true, 0);47}48}49}50}51}5253void FlingRamp_LateUpdate(void) {}5455void FlingRamp_StaticUpdate(void) {}5657void FlingRamp_Draw(void) {}5859void FlingRamp_Create(void *data)60{61RSDK_THIS(FlingRamp);6263if (!SceneInfo->inEditor) {64self->active = ACTIVE_BOUNDS;65self->visible = false;66}67}6869void FlingRamp_StageLoad(void)70{71FlingRamp->hitboxRamp.left = -16;72FlingRamp->hitboxRamp.top = -16;73FlingRamp->hitboxRamp.right = 16;74FlingRamp->hitboxRamp.bottom = 16;75}7677#if GAME_INCLUDE_EDITOR78void FlingRamp_EditorDraw(void)79{80RSDK_THIS(FlingRamp);8182Animator animator;83RSDK.SetSpriteAnimation(FlingRamp->hitboxRamp.left, 0, &animator, true, 6);84RSDK.DrawSprite(&animator, NULL, false);8586if (showGizmos()) {87RSDK_DRAWING_OVERLAY(true);8889if (self->direction < FLIP_Y)90DrawHelpers_DrawArrow(self->position.x, self->position.y, self->position.x - 0x300000, self->position.y, 0xFFFF00, INK_NONE, 0xFF);9192if (self->direction != FLIP_X)93DrawHelpers_DrawArrow(self->position.x, self->position.y, self->position.x + 0x300000, self->position.y, 0xFFFF00, INK_NONE, 0xFF);9495RSDK_DRAWING_OVERLAY(false);96}97}9899void FlingRamp_EditorLoad(void)100{101FlingRamp->hitboxRamp.left = RSDK.LoadSpriteAnimation("Editor/EditorIcons.bin", SCOPE_STAGE);102103RSDK_ACTIVE_VAR(FlingRamp, direction);104RSDK_ENUM_VAR("Omni", FLIP_NONE);105RSDK_ENUM_VAR("Right", FLIP_X);106RSDK_ENUM_VAR("Left", FLIP_Y);107}108#endif109110void FlingRamp_Serialize(void) { RSDK_EDITABLE_VAR(FlingRamp, VAR_UINT8, direction); }111112113