-
Notifications
You must be signed in to change notification settings - Fork 0
/
stage.c
120 lines (96 loc) · 2.59 KB
/
stage.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include "stage.h"
#include <stdio.h>
#include <tari/animation.h>
#include <tari/stagehandler.h>
#include <tari/input.h>
#include <tari/sound.h>
#include "preciouspeople.h"
static struct {
int planeID;
int realPlaneID;
int mBGTexture;
int mRealTexture;
double mShakeMaximum;
Vector3D mStageOffset;
int mIsReal;
} gData;
void increaseScreenShake() {
gData.mShakeMaximum += 10;
setStageHandlerMaximumScreenShake(gData.mShakeMaximum);
}
void resetScreenShakeLimit()
{
gData.mShakeMaximum = 10;
gData.mShakeMaximum += 10 * (5 - getPreciousPeopleAmount());
setStageHandlerMaximumScreenShake(gData.mShakeMaximum);
}
static void loadStage(void* tData) {
(void)tData;
gData.mStageOffset = makePosition(-300, -300, 0);
setStageHandlerNoDelayedLoading();
setStageHandlerTweening();
gData.planeID = addScrollingBackground(1, 1);
gData.realPlaneID = addScrollingBackground(1, 1);
gData.mBGTexture = addBackgroundElement(gData.planeID, gData.mStageOffset, "assets/stage/BG.pkg", createOneFrameAnimation());
gData.mRealTexture = addBackgroundElement(gData.realPlaneID, gData.mStageOffset, "assets/stage/REAL.pkg", createOneFrameAnimation());
setScrollingBackgroundInvisible(gData.realPlaneID);
setStageCameraRange(makeGeoRectangle(0,0,320,1080));
gData.mShakeMaximum = 0;
increaseScreenShake();
playTrack(3);
gData.mIsReal = 0;
}
void setStageReal() {
if (gData.mIsReal) return;
setScrollingBackgroundVisible(gData.realPlaneID);
setScrollingBackgroundInvisible(gData.planeID);
pauseTrack();
gData.mIsReal = 1;
}
void setStageUnreal() {
if (!gData.mIsReal) return;
setScrollingBackgroundVisible(gData.planeID);
setScrollingBackgroundInvisible(gData.realPlaneID);
resumeTrack();
gData.mIsReal = 0;
}
void invertStageReality()
{
if (gData.mIsReal) setStageUnreal();
else setStageReal();
}
ActorBlueprint StageBP = {
.mLoad = loadStage,
.mUnload = NULL,
.mIsActive = NULL
};
Position* getStagePositionReference()
{
return getScrollingBackgroundPositionReference(gData.planeID);
}
void drawBloodOnStage(Position p, Color c)
{
if (c == COLOR_RED) {
c = COLOR_DARK_RED;
}
else if (c == COLOR_BLUE) {
c = COLOR_DARK_BLUE;
}
else if (c == COLOR_GREEN) {
c = COLOR_DARK_GREEN;
}
else if (c == COLOR_YELLOW) {
c = COLOR_DARK_YELLOW;
}
TextureData* tex;
if (gData.mIsReal) {
tex = getBackgroundElementTextureData(gData.realPlaneID, gData.mRealTexture);
c = COLOR_WHITE;
return;
}
else {
tex = getBackgroundElementTextureData(gData.planeID, gData.mBGTexture);
}
p = vecSub(p, gData.mStageOffset);
drawColoredRectangleToTexture(tex[0], c, makeRectangle((int)p.x, (int)p.y, 2, 2));
}