Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/UFO/UFO_SpeedLines.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: UFO_SpeedLines Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectUFO_SpeedLines *UFO_SpeedLines;
11
12
void UFO_SpeedLines_Update(void) {}
13
14
void UFO_SpeedLines_LateUpdate(void)
15
{
16
RSDK_THIS(UFO_SpeedLines);
17
18
EntityUFO_Player *player = RSDK_GET_ENTITY(SLOT_PLAYER1, UFO_Player);
19
20
if (UFO_Setup->machLevel > 1 && player->groundVel > 0xC0000) {
21
self->visible = true;
22
23
for (int32 l = 0; l < UFO_SPEEDLINES_LINE_COUNT; ++l) {
24
if (self->lineAlpha[l] < 0x100)
25
self->lineAlpha[l] += 0x20;
26
27
if (self->lineX[l] >= player->position.x - 0x800000) {
28
if (self->lineX[l] > 0x800000 + player->position.x) {
29
self->lineX[l] -= 0x1000000;
30
self->lineAlpha[l] = 0;
31
}
32
}
33
else {
34
self->lineX[l] += 0x1000000;
35
self->lineAlpha[l] = 0;
36
}
37
38
if (self->lineZ[l] < player->position.y - 0x800000) {
39
self->lineZ[l] += 0x1000000;
40
self->lineAlpha[l] = 0;
41
}
42
else if (self->lineZ[l] > 0x800000 + player->position.y) {
43
self->lineZ[l] -= 0x1000000;
44
self->lineAlpha[l] = 0;
45
}
46
}
47
}
48
else {
49
for (int32 l = 0; l < UFO_SPEEDLINES_LINE_COUNT; ++l) {
50
if (self->lineAlpha[l] <= 0)
51
self->visible = false;
52
else
53
self->lineAlpha[l] -= 8;
54
}
55
}
56
}
57
58
void UFO_SpeedLines_StaticUpdate(void) {}
59
60
void UFO_SpeedLines_Draw(void)
61
{
62
RSDK_THIS(UFO_SpeedLines);
63
64
Matrix *m = &UFO_Camera->matWorld;
65
66
for (int32 l = 0; l < UFO_SPEEDLINES_LINE_COUNT; ++l) {
67
int32 x = self->lineX[l] >> 8;
68
int32 y = self->lineY[l] >> 8;
69
int32 z = self->lineZ[l] >> 8;
70
71
int32 depth = m->values[2][3] + (y * m->values[2][1] >> 8) + (z * m->values[2][2] >> 8) + (x * m->values[2][0] >> 8);
72
if (depth >= 0x400) {
73
int32 drawY = m->values[1][3] + (y * m->values[1][1] >> 8) + (z * m->values[1][2] >> 8) + (x * m->values[1][0] >> 8);
74
int32 drawX = m->values[0][3] + (y * m->values[0][1] >> 8) + (z * m->values[0][2] >> 8) + (x * m->values[0][0] >> 8);
75
76
RSDK.DrawLine(ScreenInfo->center.x + (drawX << 8) / depth, ScreenInfo->center.y - (drawY << 8) / depth,
77
ScreenInfo->center.x + (drawX << 8) / (depth + 0x2000), ScreenInfo->center.y - (drawY << 8) / (depth + 0x2000), 0xD0E0F0,
78
self->lineAlpha[l], INK_ALPHA, true);
79
}
80
}
81
}
82
83
void UFO_SpeedLines_Create(void *data)
84
{
85
RSDK_THIS(UFO_SpeedLines);
86
if (!SceneInfo->inEditor) {
87
self->visible = true;
88
self->drawFX = FX_SCALE | FX_FLIP;
89
self->drawGroup = 5;
90
self->active = ACTIVE_NORMAL;
91
92
EntityUFO_Player *player = RSDK_GET_ENTITY(SLOT_PLAYER1, UFO_Player);
93
94
for (int32 l = 0; l < UFO_SPEEDLINES_LINE_COUNT; ++l) {
95
self->lineX[l] = player->position.x + RSDK.Rand(-0x800000, 0x800000);
96
self->lineY[l] = RSDK.Rand(0x100000, 0x1000000);
97
self->lineZ[l] = player->position.y + RSDK.Rand(-0x800000, 0x800000);
98
}
99
}
100
}
101
102
void UFO_SpeedLines_StageLoad(void) { RSDK.ResetEntitySlot(SLOT_UFO_SPEEDLINES, UFO_SpeedLines->classID, NULL); }
103
104
#if GAME_INCLUDE_EDITOR
105
void UFO_SpeedLines_EditorDraw(void) {}
106
107
void UFO_SpeedLines_EditorLoad(void) {}
108
#endif
109
110
void UFO_SpeedLines_Serialize(void) {}
111
112