Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Credits/AnimalHBH.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: AnimalHBH Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectAnimalHBH *AnimalHBH;
11
12
void AnimalHBH_Update(void)
13
{
14
RSDK_THIS(AnimalHBH);
15
16
self->position.x -= 0x10000;
17
18
int32 pos = self->position.x - (ScreenInfo->position.x << 16) - (ScreenInfo->center.x << 16);
19
20
if (pos < 0)
21
pos = ((ScreenInfo->position.x + ScreenInfo->center.x) << 16) - self->position.x;
22
23
if (pos < 0x800000)
24
AnimalHBH->colorCount = 0x20 * self->type;
25
26
if (!self->type) {
27
++self->timer;
28
if ((ControllerInfo->keyA.press || ControllerInfo->keyStart.press))
29
self->timer = 1400;
30
31
if (self->timer == 1400) {
32
EntityFXFade *fxFade = CREATE_ENTITY(FXFade, NULL, self->position.x, self->position.y);
33
fxFade->speedIn = 12;
34
fxFade->wait = 240;
35
}
36
37
if (self->timer == 1536) {
38
RSDK.SetScene("Presentation", "Menu");
39
RSDK.LoadScene();
40
}
41
42
if (AnimalHBH->currentColor < AnimalHBH->colorCount)
43
AnimalHBH->currentColor++;
44
45
RSDK.SetPaletteEntry(1, 1, RSDK.GetPaletteEntry(5, AnimalHBH->currentColor));
46
}
47
}
48
49
void AnimalHBH_LateUpdate(void) {}
50
51
void AnimalHBH_StaticUpdate(void) {}
52
53
void AnimalHBH_Draw(void)
54
{
55
RSDK_THIS(AnimalHBH);
56
57
Vector2 drawPos;
58
drawPos.x = 2 * (self->position.x - ((ScreenInfo->position.x + ScreenInfo->center.x) << 15));
59
drawPos.y = self->position.y;
60
61
RSDK.SetActivePalette(1, 0, ScreenInfo->size.y);
62
RSDK.DrawSprite(&self->silhouetteAnimator, &drawPos, false);
63
64
RSDK.SetActivePalette(4, 0, ScreenInfo->size.y);
65
RSDK.DrawSprite(&self->animalHBHAnimator, NULL, false);
66
67
RSDK.SetActivePalette(1, 0, ScreenInfo->size.y);
68
}
69
70
void AnimalHBH_Create(void *data)
71
{
72
RSDK_THIS(AnimalHBH);
73
74
if (!SceneInfo->inEditor) {
75
self->visible = true;
76
self->drawGroup = 2;
77
self->active = ACTIVE_NORMAL;
78
self->updateRange.x = 0x800000;
79
self->updateRange.y = 0x800000;
80
81
RSDK.SetSpriteAnimation(AnimalHBH->aniFrames, self->type, &self->animalHBHAnimator, true, 0);
82
RSDK.SetSpriteAnimation(AnimalHBH->silhouetteFrames, self->type, &self->silhouetteAnimator, true, 0);
83
}
84
}
85
86
void AnimalHBH_StageLoad(void)
87
{
88
AnimalHBH->aniFrames = RSDK.LoadSpriteAnimation("Credits/AnimalHBH.bin", SCOPE_STAGE);
89
AnimalHBH->silhouetteFrames = RSDK.LoadSpriteAnimation("Credits/Silhouettes.bin", SCOPE_STAGE);
90
91
AnimalHBH->currentColor = 0;
92
AnimalHBH->colorCount = 0;
93
}
94
95
#if GAME_INCLUDE_EDITOR
96
void AnimalHBH_EditorDraw(void)
97
{
98
RSDK_THIS(AnimalHBH);
99
RSDK.SetSpriteAnimation(AnimalHBH->aniFrames, self->type, &self->animalHBHAnimator, true, 0);
100
101
RSDK.DrawSprite(&self->animalHBHAnimator, NULL, false);
102
}
103
104
void AnimalHBH_EditorLoad(void) { AnimalHBH->aniFrames = RSDK.LoadSpriteAnimation("Credits/AnimalHBH.bin", SCOPE_STAGE); }
105
#endif
106
107
void AnimalHBH_Serialize(void) { RSDK_EDITABLE_VAR(AnimalHBH, VAR_UINT8, type); }
108
109