Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/SSZ/Constellation.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: Constellation Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectConstellation *Constellation;
11
12
void Constellation_Update(void)
13
{
14
RSDK_THIS(Constellation);
15
16
RSDK.ProcessAnimation(&self->animator);
17
}
18
19
void Constellation_LateUpdate(void) {}
20
21
void Constellation_StaticUpdate(void) {}
22
23
void Constellation_Draw(void)
24
{
25
RSDK_THIS(Constellation);
26
27
RSDKScreenInfo *screen = &ScreenInfo[SceneInfo->currentScreenID];
28
Vector2 drawPos;
29
30
drawPos.y = self->originPos.y - ((screen->position.y * Constellation->background1->parallaxFactor / 256) << 16);
31
drawPos.x = ((((self->position.x >> 16) - screen->position.x - (screen->size.x >> 1)) << 7) / (256 - self->scrollInfo->parallaxFactor)) << 16;
32
drawPos.x += screen->size.x << 15;
33
RSDK.DrawSprite(&self->animator, &drawPos, true);
34
}
35
36
void Constellation_Create(void *data)
37
{
38
RSDK_THIS(Constellation);
39
40
self->originPos = self->position;
41
self->active = ACTIVE_BOUNDS;
42
self->drawGroup = 1;
43
self->visible = true;
44
self->drawFX = FX_FLIP;
45
self->updateRange.x = 0x800000;
46
self->updateRange.y = 0x3000000;
47
48
if (!SceneInfo->inEditor)
49
Constellation_SetupInfo();
50
51
RSDK.SetSpriteAnimation(Constellation->aniFrames, self->shape, &self->animator, true, 0);
52
}
53
54
void Constellation_StageLoad(void)
55
{
56
Constellation->aniFrames = RSDK.LoadSpriteAnimation("SSZ1/Constellation.bin", SCOPE_STAGE);
57
58
Constellation->background1 = RSDK.GetTileLayer(RSDK.GetTileLayerID("Background 1"));
59
}
60
61
void Constellation_SetupInfo(void)
62
{
63
RSDK_THIS(Constellation);
64
65
TileLayer *background1 = RSDK.GetTileLayer(RSDK.GetTileLayerID("Background 1"));
66
67
int32 id = MIN(self->originPos.y >> 3, 20);
68
self->scrollInfo = &background1->scrollInfo[id];
69
70
if (self->scrollInfo) {
71
int32 factor = self->scrollInfo->parallaxFactor;
72
if (factor > 0)
73
self->updateRange.x += ((ScreenInfo->size.x << 8) / factor) << 16;
74
}
75
}
76
77
#if GAME_INCLUDE_EDITOR
78
void Constellation_EditorDraw(void)
79
{
80
RSDK_THIS(Constellation);
81
82
RSDK.SetSpriteAnimation(Constellation->aniFrames, self->shape, &self->animator, true, 0);
83
84
RSDK.DrawSprite(&self->animator, NULL, false);
85
}
86
87
void Constellation_EditorLoad(void)
88
{
89
Constellation->aniFrames = RSDK.LoadSpriteAnimation("SSZ1/Constellation.bin", SCOPE_STAGE);
90
91
RSDK_ACTIVE_VAR(Constellation, shape);
92
RSDK_ENUM_VAR("Sonic", CONSTELLATION_SONIC);
93
RSDK_ENUM_VAR("Vase", CONSTELLATION_VASE);
94
RSDK_ENUM_VAR("Berries", CONSTELLATION_BERRIES);
95
RSDK_ENUM_VAR("Lyre", CONSTELLATION_LYRE);
96
RSDK_ENUM_VAR("Helmet", CONSTELLATION_HELMET);
97
98
RSDK_ACTIVE_VAR(Constellation, direction);
99
RSDK_ENUM_VAR("Right", FLIP_NONE);
100
RSDK_ENUM_VAR("Left", FLIP_X);
101
}
102
#endif
103
104
void Constellation_Serialize(void)
105
{
106
RSDK_EDITABLE_VAR(Constellation, VAR_UINT8, direction);
107
RSDK_EDITABLE_VAR(Constellation, VAR_UINT8, shape);
108
}
109
110