Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Puyo/PuyoScore.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: PuyoScore Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectPuyoScore *PuyoScore;
11
12
void PuyoScore_Update(void)
13
{
14
RSDK_THIS(PuyoScore);
15
16
self->visible = self->flashing ? !(Zone->timer & 4) : true;
17
}
18
19
void PuyoScore_LateUpdate(void) {}
20
21
void PuyoScore_StaticUpdate(void) {}
22
23
void PuyoScore_Draw(void)
24
{
25
RSDK_THIS(PuyoScore);
26
27
PuyoScore_DrawScore(self->score);
28
}
29
30
void PuyoScore_Create(void *data)
31
{
32
RSDK_THIS(PuyoScore);
33
34
self->active = ACTIVE_NORMAL;
35
self->drawGroup = 10;
36
self->visible = true;
37
self->updateRange.x = 0x800000;
38
self->updateRange.y = 0x800000;
39
}
40
41
void PuyoScore_StageLoad(void) { PuyoScore->aniFrames = RSDK.LoadSpriteAnimation("Puyo/PuyoUI.bin", SCOPE_STAGE); }
42
43
void PuyoScore_DrawScore(int32 score)
44
{
45
RSDK_THIS(PuyoScore);
46
47
char buffer[8];
48
if (self->counter)
49
sprintf_s(buffer, (int32)sizeof(buffer), "%d", score);
50
else
51
sprintf_s(buffer, (int32)sizeof(buffer), "%06d", score);
52
53
Vector2 drawPos = self->position;
54
for (int32 i = 0; i < 6; ++i) {
55
if (!buffer[i])
56
break;
57
58
RSDK.SetSpriteAnimation(PuyoScore->aniFrames, (self->counter != false) + 2, &self->animator, true, (buffer[i] - '0'));
59
RSDK.DrawSprite(&self->animator, &drawPos, false);
60
drawPos.x += 0x80000;
61
}
62
}
63
64
#if GAME_INCLUDE_EDITOR
65
void PuyoScore_EditorDraw(void)
66
{
67
RSDK_THIS(PuyoScore);
68
69
if (self->counter)
70
PuyoScore_DrawScore(self->playerID);
71
else
72
PuyoScore_DrawScore(self->playerID ? 67890 : 12345);
73
}
74
75
void PuyoScore_EditorLoad(void)
76
{
77
PuyoScore->aniFrames = RSDK.LoadSpriteAnimation("Puyo/PuyoUI.bin", SCOPE_STAGE);
78
79
RSDK_ACTIVE_VAR(PuyoScore, playerID);
80
RSDK_ENUM_VAR("Player 1", PUYOGAME_PLAYER1);
81
RSDK_ENUM_VAR("Player 2", PUYOGAME_PLAYER2);
82
}
83
#endif
84
85
void PuyoScore_Serialize(void)
86
{
87
RSDK_EDITABLE_VAR(PuyoScore, VAR_ENUM, playerID);
88
RSDK_EDITABLE_VAR(PuyoScore, VAR_BOOL, counter);
89
}
90
91