Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-2-2013-Decompilation
Path: blob/main/RSDKv4/NativeObjects/MultiplayerButton.cpp
817 views
1
#include "RetroEngine.hpp"
2
3
void MultiplayerButton_Create(void *objPtr)
4
{
5
RSDK_THIS(MultiplayerButton);
6
self->textureCircle = LoadTexture("Data/Game/Menu/Circle.png", TEXFMT_RGBA4444);
7
8
int texture = LoadTexture("Data/Game/Menu/Intro.png", TEXFMT_RGBA4444);
9
self->meshVS = LoadMesh("Data/Game/Models/2PVS.bin", texture);
10
self->x = 0.0;
11
self->y = 16.0;
12
self->z = 160.0;
13
self->r = 0xFF;
14
self->g = 0xFF;
15
self->b = 0x00;
16
self->labelPtr = CREATE_ENTITY(TextLabel);
17
self->labelPtr->fontID = FONT_HEADING;
18
self->labelPtr->scale = 0.15;
19
self->labelPtr->alpha = 0;
20
self->labelPtr->state = TEXTLABEL_STATE_IDLE;
21
SetStringToFont(self->labelPtr->text, str2PlayerVS, FONT_HEADING);
22
self->labelPtr->alignPtr(self->labelPtr, ALIGN_CENTER);
23
}
24
void MultiplayerButton_Main(void *objPtr)
25
{
26
RSDK_THIS(MultiplayerButton);
27
28
#if RETRO_USE_NETWORKING
29
if (self->connectTimer) {
30
self->connectTimer += Engine.deltaTime;
31
if (self->connectTimer >= 0.7f) {
32
self->connectTimer = 0;
33
}
34
}
35
#endif
36
if (self->visible) {
37
if (self->scale < 0.2) {
38
self->scale += ((0.25 - self->scale) / ((60.0 * Engine.deltaTime) * 16.0));
39
if (self->scale > 0.2)
40
self->scale = 0.2;
41
}
42
SetRenderBlendMode(RENDER_BLEND_ALPHA);
43
SetRenderVertexColor(self->r, self->g, self->b);
44
RenderImage(self->x, self->y, self->z, self->scale, self->scale, 256.0, 256.0, 512.0, 512.0, 0.0, 0.0, 255, self->textureCircle);
45
SetRenderVertexColor(0xFF, 0xFF, 0xFF);
46
SetRenderBlendMode(RENDER_BLEND_NONE);
47
48
self->angle -= Engine.deltaTime;
49
if (self->angle < -M_PI_2)
50
self->angle += M_PI_2;
51
52
NewRenderState();
53
MatrixRotateXYZF(&self->renderMatrix, 0.0, self->angle, 0.0);
54
MatrixTranslateXYZF(&self->matrixTemp, self->x, self->y, self->z - 8.0);
55
MatrixMultiplyF(&self->renderMatrix, &self->matrixTemp);
56
SetRenderMatrix(&self->renderMatrix);
57
RenderMesh(self->meshVS, MESH_NORMALS, true);
58
SetRenderMatrix(NULL);
59
60
NativeEntity_TextLabel *label = self->labelPtr;
61
label->x = self->x;
62
label->y = self->y - 72.0;
63
label->z = self->z;
64
if (label->x <= -8.0 || label->x >= 8.0) {
65
if (label->alpha > 0)
66
label->alpha -= 8;
67
}
68
else {
69
if (label->alpha < 0x100)
70
label->alpha += 8;
71
}
72
#if RETRO_USE_NETWORKING
73
if (!Engine.onlineActive && self->labelPtr->state == TEXTLABEL_STATE_BLINK_FAST && !self->connectTimer) {
74
self->connectTimer = 0.1f;
75
DisconnectNetwork();
76
InitNetwork(); // let's see if we can turn it on
77
}
78
#endif
79
}
80
}
81
82