Path: blob/master/SonicMania/Objects/SSZ/Constellation.c
338 views
// ---------------------------------------------------------------------1// RSDK Project: Sonic Mania2// Object Description: Constellation Object3// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges4// Decompiled by: Rubberduckycooly & RMGRich5// ---------------------------------------------------------------------67#include "Game.h"89ObjectConstellation *Constellation;1011void Constellation_Update(void)12{13RSDK_THIS(Constellation);1415RSDK.ProcessAnimation(&self->animator);16}1718void Constellation_LateUpdate(void) {}1920void Constellation_StaticUpdate(void) {}2122void Constellation_Draw(void)23{24RSDK_THIS(Constellation);2526RSDKScreenInfo *screen = &ScreenInfo[SceneInfo->currentScreenID];27Vector2 drawPos;2829drawPos.y = self->originPos.y - ((screen->position.y * Constellation->background1->parallaxFactor / 256) << 16);30drawPos.x = ((((self->position.x >> 16) - screen->position.x - (screen->size.x >> 1)) << 7) / (256 - self->scrollInfo->parallaxFactor)) << 16;31drawPos.x += screen->size.x << 15;32RSDK.DrawSprite(&self->animator, &drawPos, true);33}3435void Constellation_Create(void *data)36{37RSDK_THIS(Constellation);3839self->originPos = self->position;40self->active = ACTIVE_BOUNDS;41self->drawGroup = 1;42self->visible = true;43self->drawFX = FX_FLIP;44self->updateRange.x = 0x800000;45self->updateRange.y = 0x3000000;4647if (!SceneInfo->inEditor)48Constellation_SetupInfo();4950RSDK.SetSpriteAnimation(Constellation->aniFrames, self->shape, &self->animator, true, 0);51}5253void Constellation_StageLoad(void)54{55Constellation->aniFrames = RSDK.LoadSpriteAnimation("SSZ1/Constellation.bin", SCOPE_STAGE);5657Constellation->background1 = RSDK.GetTileLayer(RSDK.GetTileLayerID("Background 1"));58}5960void Constellation_SetupInfo(void)61{62RSDK_THIS(Constellation);6364TileLayer *background1 = RSDK.GetTileLayer(RSDK.GetTileLayerID("Background 1"));6566int32 id = MIN(self->originPos.y >> 3, 20);67self->scrollInfo = &background1->scrollInfo[id];6869if (self->scrollInfo) {70int32 factor = self->scrollInfo->parallaxFactor;71if (factor > 0)72self->updateRange.x += ((ScreenInfo->size.x << 8) / factor) << 16;73}74}7576#if GAME_INCLUDE_EDITOR77void Constellation_EditorDraw(void)78{79RSDK_THIS(Constellation);8081RSDK.SetSpriteAnimation(Constellation->aniFrames, self->shape, &self->animator, true, 0);8283RSDK.DrawSprite(&self->animator, NULL, false);84}8586void Constellation_EditorLoad(void)87{88Constellation->aniFrames = RSDK.LoadSpriteAnimation("SSZ1/Constellation.bin", SCOPE_STAGE);8990RSDK_ACTIVE_VAR(Constellation, shape);91RSDK_ENUM_VAR("Sonic", CONSTELLATION_SONIC);92RSDK_ENUM_VAR("Vase", CONSTELLATION_VASE);93RSDK_ENUM_VAR("Berries", CONSTELLATION_BERRIES);94RSDK_ENUM_VAR("Lyre", CONSTELLATION_LYRE);95RSDK_ENUM_VAR("Helmet", CONSTELLATION_HELMET);9697RSDK_ACTIVE_VAR(Constellation, direction);98RSDK_ENUM_VAR("Right", FLIP_NONE);99RSDK_ENUM_VAR("Left", FLIP_X);100}101#endif102103void Constellation_Serialize(void)104{105RSDK_EDITABLE_VAR(Constellation, VAR_UINT8, direction);106RSDK_EDITABLE_VAR(Constellation, VAR_UINT8, shape);107}108109110