Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/MSZ/PaintingEyes.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: PaintingEyes Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectPaintingEyes *PaintingEyes;
11
12
void PaintingEyes_Update(void)
13
{
14
RSDK_THIS(PaintingEyes);
15
16
foreach_active(Player, player)
17
{
18
if ((player->direction && player->position.x >= self->position.x - 0x80000)
19
|| (!player->direction && player->position.x <= self->position.x + 0x80000)) {
20
if (player->onGround)
21
self->hideEyes = false;
22
else if (self->timer < 30)
23
self->timer = 0;
24
}
25
else
26
self->hideEyes = true;
27
}
28
29
if (self->hideEyes) {
30
if (self->coverPos < 0x80000)
31
self->coverPos += 0x20000;
32
33
self->timer = 0;
34
}
35
else {
36
if (self->timer >= 30) {
37
if (self->coverPos > 0)
38
self->coverPos -= 0x20000;
39
}
40
else {
41
self->timer++;
42
}
43
}
44
}
45
46
void PaintingEyes_LateUpdate(void) {}
47
48
void PaintingEyes_StaticUpdate(void) {}
49
50
void PaintingEyes_Draw(void)
51
{
52
RSDK_THIS(PaintingEyes);
53
54
Vector2 drawPos;
55
drawPos.x = self->position.x + CLAMP(((ScreenInfo->position.x + ScreenInfo->center.x) << 10) - (self->position.x >> 6), -0x10000, 0x10000);
56
drawPos.y = self->position.y + CLAMP(((ScreenInfo->position.y + ScreenInfo->center.y) << 10) - (self->position.y >> 6), -0x10000, 0x10000);
57
RSDK.DrawSprite(&self->irisAnimator, &drawPos, false);
58
59
drawPos.x = self->position.x + CLAMP(((ScreenInfo->position.x + ScreenInfo->center.x) << 11) - (self->position.x >> 5), -0x20000, 0x20000);
60
drawPos.y = self->position.y + CLAMP(((ScreenInfo->position.y + ScreenInfo->center.y) << 11) - (self->position.y >> 5), -0x20000, 0x20000);
61
RSDK.DrawSprite(&self->pupilAnimator, &drawPos, false);
62
63
drawPos.x = self->position.x;
64
drawPos.y = self->position.y + self->coverPos;
65
RSDK.DrawSprite(&self->coverAnimator, &drawPos, false);
66
}
67
68
void PaintingEyes_Create(void *data)
69
{
70
RSDK_THIS(PaintingEyes);
71
72
if (!SceneInfo->inEditor) {
73
RSDK.SetSpriteAnimation(PaintingEyes->aniFrames, 0, &self->coverAnimator, true, 0);
74
RSDK.SetSpriteAnimation(PaintingEyes->aniFrames, 0, &self->irisAnimator, true, 1);
75
RSDK.SetSpriteAnimation(PaintingEyes->aniFrames, 0, &self->pupilAnimator, true, 2);
76
77
self->active = ACTIVE_BOUNDS;
78
self->updateRange.x = 0x100000;
79
self->updateRange.y = 0x100000;
80
self->visible = true;
81
self->drawGroup = Zone->objectDrawGroup[0] - 1;
82
}
83
}
84
85
void PaintingEyes_StageLoad(void) { PaintingEyes->aniFrames = RSDK.LoadSpriteAnimation("MSZ/PaintingEyes.bin", SCOPE_STAGE); }
86
87
#if GAME_INCLUDE_EDITOR
88
void PaintingEyes_EditorDraw(void)
89
{
90
RSDK_THIS(PaintingEyes);
91
92
RSDK.SetSpriteAnimation(PaintingEyes->aniFrames, 0, &self->coverAnimator, false, 0);
93
RSDK.SetSpriteAnimation(PaintingEyes->aniFrames, 0, &self->irisAnimator, false, 1);
94
RSDK.SetSpriteAnimation(PaintingEyes->aniFrames, 0, &self->pupilAnimator, false, 2);
95
96
RSDK.DrawSprite(&self->irisAnimator, NULL, false);
97
RSDK.DrawSprite(&self->pupilAnimator, NULL, false);
98
RSDK.DrawSprite(&self->coverAnimator, NULL, false);
99
}
100
101
void PaintingEyes_EditorLoad(void) { PaintingEyes->aniFrames = RSDK.LoadSpriteAnimation("MSZ/PaintingEyes.bin", SCOPE_STAGE); }
102
#endif
103
104
void PaintingEyes_Serialize(void) {}
105
106