Path: blob/master/SonicMania/Objects/AIZ/FernParallax.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: FernParallax Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89#if MANIA_USE_PLUS10ObjectFernParallax *FernParallax;1112void FernParallax_Update(void) {}1314void FernParallax_LateUpdate(void) {}1516void FernParallax_StaticUpdate(void) {}1718void FernParallax_Draw(void)19{20RSDK_THIS(FernParallax);21RSDKScreenInfo *screen = &ScreenInfo[SceneInfo->currentScreenID];2223int32 screenX = (screen->position.x + screen->center.x) << 16;24int32 screenY = (screen->position.y + screen->center.y) << 16;2526Vector2 drawPos;27drawPos.x = self->position.x + ((self->position.x - screenX) << self->parallaxFactor.x);28drawPos.y = self->position.y + ((self->position.y - screenY) << self->parallaxFactor.y);2930Hitbox *otherHitbox = RSDK.GetHitbox(&self->animator, 0);3132Hitbox thisHitbox;33thisHitbox.left = -screen->center.x;34thisHitbox.right = screen->center.x;35thisHitbox.top = -screen->center.y;36thisHitbox.bottom = screen->center.y;3738EntityBase *screenBuffer = &FernParallax->entityBuffer[0];39screenBuffer->position.x = screenX;40screenBuffer->position.y = screenY;4142EntityBase *entityBuffer = &FernParallax->entityBuffer[1];43entityBuffer->position.x = drawPos.x;44entityBuffer->position.y = drawPos.y;4546if (RSDK.CheckObjectCollisionTouchBox(screenBuffer, &thisHitbox, entityBuffer, otherHitbox)) {47int32 bottom = ((screen->size.y + screen->position.y) << 16) - (otherHitbox->bottom << 16) - drawPos.y;48if (bottom > 0)49drawPos.y += bottom - (bottom >> 3);50}51RSDK.DrawSprite(&self->animator, &drawPos, false);52}5354void FernParallax_Create(void *data)55{56RSDK_THIS(FernParallax);57self->active = ACTIVE_NORMAL;58self->visible = true;59self->drawGroup = Zone->objectDrawGroup[1] + 1;60RSDK.SetSpriteAnimation(FernParallax->aniFrames, self->aniID, &self->animator, true, 0);61}6263void FernParallax_StageLoad(void)64{65FernParallax->aniFrames = RSDK.LoadSpriteAnimation("AIZ/Decoration.bin", SCOPE_STAGE);66memset(FernParallax->entityBuffer, 0, sizeof(FernParallax->entityBuffer));67}6869#if GAME_INCLUDE_EDITOR70void FernParallax_EditorDraw(void)71{72RSDK_THIS(FernParallax);73RSDK.DrawSprite(&self->animator, NULL, false);74}7576void FernParallax_EditorLoad(void)77{78FernParallax->aniFrames = RSDK.LoadSpriteAnimation("AIZ/Decoration.bin", SCOPE_STAGE);7980RSDK_ACTIVE_VAR(FernParallax, aniID);81RSDK_ENUM_VAR("Leaf 1", AIZ_DECOR_LEAF1);82RSDK_ENUM_VAR("Leaf 2", AIZ_DECOR_LEAF2);83RSDK_ENUM_VAR("Leaf 3", AIZ_DECOR_LEAF3);84RSDK_ENUM_VAR("Leaf 4", AIZ_DECOR_LEAF4);85}86#endif8788void FernParallax_Serialize(void)89{90RSDK_EDITABLE_VAR(FernParallax, VAR_UINT8, aniID);91RSDK_EDITABLE_VAR(FernParallax, VAR_VECTOR2, parallaxFactor);92}93#endif949596