Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/AIZ/FernParallax.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: FernParallax Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
#if MANIA_USE_PLUS
11
ObjectFernParallax *FernParallax;
12
13
void FernParallax_Update(void) {}
14
15
void FernParallax_LateUpdate(void) {}
16
17
void FernParallax_StaticUpdate(void) {}
18
19
void FernParallax_Draw(void)
20
{
21
RSDK_THIS(FernParallax);
22
RSDKScreenInfo *screen = &ScreenInfo[SceneInfo->currentScreenID];
23
24
int32 screenX = (screen->position.x + screen->center.x) << 16;
25
int32 screenY = (screen->position.y + screen->center.y) << 16;
26
27
Vector2 drawPos;
28
drawPos.x = self->position.x + ((self->position.x - screenX) << self->parallaxFactor.x);
29
drawPos.y = self->position.y + ((self->position.y - screenY) << self->parallaxFactor.y);
30
31
Hitbox *otherHitbox = RSDK.GetHitbox(&self->animator, 0);
32
33
Hitbox thisHitbox;
34
thisHitbox.left = -screen->center.x;
35
thisHitbox.right = screen->center.x;
36
thisHitbox.top = -screen->center.y;
37
thisHitbox.bottom = screen->center.y;
38
39
EntityBase *screenBuffer = &FernParallax->entityBuffer[0];
40
screenBuffer->position.x = screenX;
41
screenBuffer->position.y = screenY;
42
43
EntityBase *entityBuffer = &FernParallax->entityBuffer[1];
44
entityBuffer->position.x = drawPos.x;
45
entityBuffer->position.y = drawPos.y;
46
47
if (RSDK.CheckObjectCollisionTouchBox(screenBuffer, &thisHitbox, entityBuffer, otherHitbox)) {
48
int32 bottom = ((screen->size.y + screen->position.y) << 16) - (otherHitbox->bottom << 16) - drawPos.y;
49
if (bottom > 0)
50
drawPos.y += bottom - (bottom >> 3);
51
}
52
RSDK.DrawSprite(&self->animator, &drawPos, false);
53
}
54
55
void FernParallax_Create(void *data)
56
{
57
RSDK_THIS(FernParallax);
58
self->active = ACTIVE_NORMAL;
59
self->visible = true;
60
self->drawGroup = Zone->objectDrawGroup[1] + 1;
61
RSDK.SetSpriteAnimation(FernParallax->aniFrames, self->aniID, &self->animator, true, 0);
62
}
63
64
void FernParallax_StageLoad(void)
65
{
66
FernParallax->aniFrames = RSDK.LoadSpriteAnimation("AIZ/Decoration.bin", SCOPE_STAGE);
67
memset(FernParallax->entityBuffer, 0, sizeof(FernParallax->entityBuffer));
68
}
69
70
#if GAME_INCLUDE_EDITOR
71
void FernParallax_EditorDraw(void)
72
{
73
RSDK_THIS(FernParallax);
74
RSDK.DrawSprite(&self->animator, NULL, false);
75
}
76
77
void FernParallax_EditorLoad(void)
78
{
79
FernParallax->aniFrames = RSDK.LoadSpriteAnimation("AIZ/Decoration.bin", SCOPE_STAGE);
80
81
RSDK_ACTIVE_VAR(FernParallax, aniID);
82
RSDK_ENUM_VAR("Leaf 1", AIZ_DECOR_LEAF1);
83
RSDK_ENUM_VAR("Leaf 2", AIZ_DECOR_LEAF2);
84
RSDK_ENUM_VAR("Leaf 3", AIZ_DECOR_LEAF3);
85
RSDK_ENUM_VAR("Leaf 4", AIZ_DECOR_LEAF4);
86
}
87
#endif
88
89
void FernParallax_Serialize(void)
90
{
91
RSDK_EDITABLE_VAR(FernParallax, VAR_UINT8, aniID);
92
RSDK_EDITABLE_VAR(FernParallax, VAR_VECTOR2, parallaxFactor);
93
}
94
#endif
95
96