Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Credits/TAEmerald.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: TAEmerald Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectTAEmerald *TAEmerald;
11
12
void TAEmerald_Update(void)
13
{
14
RSDK_THIS(TAEmerald);
15
16
StateMachine_Run(self->state);
17
}
18
19
void TAEmerald_LateUpdate(void) {}
20
21
void TAEmerald_StaticUpdate(void) {}
22
23
void TAEmerald_Draw(void)
24
{
25
RSDK_THIS(TAEmerald);
26
27
RSDK.SetActivePalette(3, 0, ScreenInfo->size.y);
28
RSDK.DrawSprite(&self->animator, NULL, false);
29
}
30
31
void TAEmerald_Create(void *data)
32
{
33
RSDK_THIS(TAEmerald);
34
35
if (!SceneInfo->inEditor) {
36
self->originPos = self->position;
37
self->angle = 16 * self->color;
38
self->visible = true;
39
self->drawGroup = 1;
40
self->active = ACTIVE_NORMAL;
41
self->updateRange.x = 0x800000;
42
self->updateRange.y = 0x800000;
43
44
self->state = TAEmerald_State_Oscillate;
45
RSDK.SetSpriteAnimation(TAEmerald->aniFrames, 7, &self->animator, true, self->color);
46
47
if (SaveGame_GetSaveRAM() && SaveGame_GetEmerald(self->color)) {
48
self->visible = false;
49
}
50
}
51
}
52
53
void TAEmerald_StageLoad(void) { TAEmerald->aniFrames = RSDK.LoadSpriteAnimation("Special/Results.bin", SCOPE_STAGE); }
54
55
void TAEmerald_State_Oscillate(void)
56
{
57
RSDK_THIS(TAEmerald);
58
59
self->position.y = (RSDK.Sin256(self->angle) << 11) + self->originPos.y;
60
self->angle = (self->angle + 4) & 0xFF;
61
}
62
63
void TAEmerald_State_MoveCircle(void)
64
{
65
RSDK_THIS(TAEmerald);
66
67
if (self->timer > 0) {
68
self->timer--;
69
}
70
else {
71
if (self->direction) {
72
self->angle += 2;
73
74
if (self->angle >= 0) {
75
self->direction = FLIP_NONE;
76
self->state = StateMachine_None;
77
}
78
}
79
else {
80
self->angle -= 2;
81
82
if (self->angle <= -0x80) {
83
self->direction = FLIP_X;
84
self->state = StateMachine_None;
85
}
86
}
87
88
self->rotation = 4 * self->angle;
89
self->position.x = 0x4800 * RSDK.Cos256(self->angle) + self->originPos.x;
90
self->position.y = 0x4800 * RSDK.Sin256(self->angle) + self->originPos.y;
91
}
92
}
93
94
#if GAME_INCLUDE_EDITOR
95
void TAEmerald_EditorDraw(void)
96
{
97
RSDK_THIS(TAEmerald);
98
99
RSDK.SetSpriteAnimation(TAEmerald->aniFrames, 7, &self->animator, true, self->color);
100
RSDK.DrawSprite(&self->animator, NULL, false);
101
}
102
103
void TAEmerald_EditorLoad(void)
104
{
105
TAEmerald->aniFrames = RSDK.LoadSpriteAnimation("Special/Results.bin", SCOPE_STAGE);
106
107
RSDK_ACTIVE_VAR(TAEmerald, color);
108
RSDK_ENUM_VAR("Green", CHAOSEMERALD_GREEN);
109
RSDK_ENUM_VAR("Yellow", CHAOSEMERALD_YELLOW);
110
RSDK_ENUM_VAR("Blue", CHAOSEMERALD_BLUE);
111
RSDK_ENUM_VAR("Purple", CHAOSEMERALD_PURPLE);
112
RSDK_ENUM_VAR("Gray", CHAOSEMERALD_GRAY);
113
RSDK_ENUM_VAR("Cyan", CHAOSEMERALD_CYAN);
114
RSDK_ENUM_VAR("Red", CHAOSEMERALD_RED);
115
}
116
#endif
117
118
void TAEmerald_Serialize(void) { RSDK_EDITABLE_VAR(TAEmerald, VAR_UINT8, color); }
119
120