-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbackgrounds.cpp
More file actions
165 lines (148 loc) · 5.61 KB
/
Copy pathbackgrounds.cpp
File metadata and controls
165 lines (148 loc) · 5.61 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include "level_enums.hpp"
#include "global_vars.h"
#include "loadg.h"
#include "main.h"
#include "backgrounds.h"
//背景
int BackgroundCount;
int BackgroundX[BACKGROUND_MAX], BackgroundY[BACKGROUND_MAX];
EBackgroundType BackgroundType[BACKGROUND_MAX];
//+KZ: value is set but never used
//int BackgroundWidth[BACKGROUND_MAX], BackgroundHeight[BACKGROUND_MAX];
void RenderBackground()
{
// 背景 (Background)
for (t = 0; t < BACKGROUND_MAX; t++)
{
xx[0] = BackgroundX[t] - fx;
xx[1] = BackgroundY[t] - fy;
//+KZ: added some checks because this gets out of bounds in level 1-4
//+KZ later: ....wait this code is useless, we set xx[2] and xx[3] just after this
/*if (ntype[t] < nmax)
{
xx[2] = BackgroundWidth[ntype[t]] * 100;
xx[3] = BackgroundHeight[ntype[t]] * 100;
}*/
xx[2] = 16000;
xx[3] = 16000;
if (xx[0] + xx[2] >= -10 && xx[0] <= fxmax && xx[1] + xx[3] >= -10 && xx[3] <= fymax)
{
if (BackgroundType[t] != EBackgroundType::CASTLE)
{
//+KZ: so.. this draws the broken grass in 3-1, did it even work correctly in any syobon action version?
// Changed code to use custom sprites in SyobonKZ
switch (LevelType)
{
case ELevelType::ICY:
if(BackgroundType[t] == EBackgroundType::GRASS)
{
drawimage(Sliced_GFX_KZ[0], xx[0] / 100, xx[1] / 100);
}
else if(BackgroundType[t] == EBackgroundType::CLOUD)
{
drawimage(Sliced_GFX_KZ[1], xx[0] / 100, xx[1] / 100);
}
break;
case ELevelType::OVERWORLD:
case ELevelType::UNDERGROUND:
case ELevelType::SKY:
case ELevelType::CASTLE:
case ELevelType::KAIZO_SYOBON_OVERWORLD_SLIP:
//Original code is like this
drawimage(Sliced_GFX[(int)BackgroundType[t]][4],
xx[0] / 100, xx[1] / 100);
break;
}
}
else
{
drawimage(Sliced_GFX[(int)EBackgroundType::CASTLE][4],
xx[0] / 100 - 5, xx[1] / 100);
}
// 51
if (BackgroundType[t] == EBackgroundType::TEXT_51)
{
DrawFormatString(xx[0] / 100,
xx[1] / 100,
GetColor(255, 255, 255), "51");
}
if (BackgroundType[t] == EBackgroundType::TEXT_GAME_CLEAR)
DrawFormatString(xx[0] / 100,
xx[1] / 100,
GetColor(255, 255,
255),
"ゲームクリアー");
if (BackgroundType[t] == EBackgroundType::TEXT_THANKS_FOR_PLAYING)
DrawFormatString(xx[0] / 100,
xx[1] / 100,
GetColor(255, 255,
255),
"プレイしてくれてありがとー");
if(currentGame != ESyobonActionGame::SHOBON_NO_ACTION_1_AND_2)
{
switch(BackgroundType[t])
{
case EBackgroundType::SA3_FAKE_GROUND_TOP:
{
int offset_index = 0;
if (LevelType == ELevelType::UNDERGROUND)
{
offset_index = 30;
}
if (LevelType == ELevelType::CASTLE)
{
offset_index = 60;
}
if (LevelType == ELevelType::ICY)
{
offset_index = 90;
}
DrawGraphZ((BackgroundX[t] - fx) / 100, (BackgroundY[t] - fy) / 100, Sliced_GFX[offset_index + 5 /* GROUND_TOP */][1]);
break;
}
default:
break;
}
}
}
} // t
}
int CreateBackground(double PosX, double PosY, EBackgroundType Type, int index)
{
PosX *= BLOCK_DEFAULT_SIZE;
PosY *= BLOCK_DEFAULT_SIZE;
PosY -= 12; //stage() does -12 to blocks, lets be consistent
//the game simulates floating point numbers
//by multiplying all positions by 100
PosX *= 100;
PosY *= 100;
if(index < 0)
{
//use BackgroundCount to keep compat with legacy background creation
index = BackgroundCount++;
if(BackgroundCount == BACKGROUND_MAX)
BackgroundCount = 0;
}
if(index >= 0 && index < BACKGROUND_MAX)
{
BackgroundX[index] = PosX;
BackgroundY[index] = PosY;
BackgroundType[index] = Type;
}
else
{
fprintf(stderr, "CreateBackground - Could not create extra graphic %d at %d %d! (index %d)", Type, (int)PosX, (int)PosY, index);
}
return index;
}
void ClearAllBackgrounds()
{
for(int index = 0; index < BACKGROUND_MAX; index++)
{
BackgroundX[index] = std::numeric_limits<int>::min();
BackgroundY[index] = std::numeric_limits<int>::min();
//game wont render a invalid type
BackgroundType[index] = (EBackgroundType)std::numeric_limits<int>::max();
}
BackgroundCount = 0;
}