- debug::println(char*, float)
- Gràfic del balunet - Paleta afegida - sprite en altura correcta - sprite amb diferent textura - transparencies en el sprite - Makefile pa que JDes no haja de fer search en el chat cada volta
This commit is contained in:
@@ -59,6 +59,14 @@ namespace debug
|
|||||||
newline();
|
newline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void println(const char *label, float value)
|
||||||
|
{
|
||||||
|
print(label);
|
||||||
|
print(" ");
|
||||||
|
print(value);
|
||||||
|
newline();
|
||||||
|
}
|
||||||
|
|
||||||
void print(int value)
|
void print(int value)
|
||||||
{
|
{
|
||||||
char temp[20];
|
char temp[20];
|
||||||
|
|||||||
19
main.cpp
19
main.cpp
@@ -22,6 +22,7 @@ SDL_Texture *sdl_texture;
|
|||||||
|
|
||||||
Uint32 *palette;
|
Uint32 *palette;
|
||||||
Uint8 *gif;
|
Uint8 *gif;
|
||||||
|
Uint8 *spr;
|
||||||
Uint8 screen[320*240];
|
Uint8 screen[320*240];
|
||||||
float depth_buffer[320*240];
|
float depth_buffer[320*240];
|
||||||
|
|
||||||
@@ -105,7 +106,7 @@ void putpd(int x, int y, Uint8 color, float depth)
|
|||||||
|
|
||||||
void putps(int x, int y, Uint8 color, float depth)
|
void putps(int x, int y, Uint8 color, float depth)
|
||||||
{
|
{
|
||||||
if (x<0 || y<0 || x>=320 || y>=240) return;
|
if (x<0 || y<0 || x>=320 || y>=240 || color==0) return;
|
||||||
if (depth_buffer[x+y*320]>=depth)
|
if (depth_buffer[x+y*320]>=depth)
|
||||||
{
|
{
|
||||||
screen[x+y*320]=color;
|
screen[x+y*320]=color;
|
||||||
@@ -429,6 +430,16 @@ int main(int argc, char *argv[])
|
|||||||
palette = LoadPalette(buffer);
|
palette = LoadPalette(buffer);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
||||||
|
f = fopen("player1.gif", "rb");
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
filesize = ftell(f);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
buffer = (Uint8*)malloc(filesize);
|
||||||
|
fread(buffer, filesize, 1, f);
|
||||||
|
fclose(f);
|
||||||
|
spr = LoadGif(buffer, &w, &h);
|
||||||
|
free(buffer);
|
||||||
|
|
||||||
// [DEBUG] Paleta per al depth buffer
|
// [DEBUG] Paleta per al depth buffer
|
||||||
//for(int i=0;i<256;++i) palette[i] = (255-i) | ((255-i)<<8) | ((255-i)<<16);
|
//for(int i=0;i<256;++i) palette[i] = (255-i) | ((255-i)<<8) | ((255-i)<<16);
|
||||||
|
|
||||||
@@ -535,7 +546,9 @@ int main(int argc, char *argv[])
|
|||||||
const float d = distance(position, enemy);// * SDL_cosf(a_inc*DEG_TO_RAD);
|
const float d = distance(position, enemy);// * SDL_cosf(a_inc*DEG_TO_RAD);
|
||||||
float dist = d * SDL_cosf(angle_to_enemy*DEG_TO_RAD);
|
float dist = d * SDL_cosf(angle_to_enemy*DEG_TO_RAD);
|
||||||
float wall_height = (32.0f*277)/dist;
|
float wall_height = (32.0f*277)/dist;
|
||||||
debug::print("enemy in fov: "); debug::print(angle_to_enemy); debug::newline();
|
float wall_start = 120-(wall_height/32.0f)*(32.0f-(height-sectors[0].floor_height));
|
||||||
|
debug::println("enemy height: ", wall_height);
|
||||||
|
debug::println("enemy start: ", wall_start);
|
||||||
int column = int((angle_to_enemy+32.0f)/0.2f);
|
int column = int((angle_to_enemy+32.0f)/0.2f);
|
||||||
for (int i=0; i<wall_height;++i)
|
for (int i=0; i<wall_height;++i)
|
||||||
{
|
{
|
||||||
@@ -545,7 +558,7 @@ int main(int argc, char *argv[])
|
|||||||
for (int j=0;j<wall_height;++j)
|
for (int j=0;j<wall_height;++j)
|
||||||
{
|
{
|
||||||
int ty = j * 32 / wall_height;
|
int ty = j * 32 / wall_height;
|
||||||
putps(c, 120-(wall_height/2)+j, gif[tx+ty*64], d);
|
putps(c, wall_start+j, spr[tx+ty*32], d); //120-(wall_height/2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
player1.gif
Normal file
BIN
player1.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
259
wolf.pal
Normal file
259
wolf.pal
Normal file
@@ -0,0 +1,259 @@
|
|||||||
|
JASC-PAL
|
||||||
|
0100
|
||||||
|
256
|
||||||
|
0 0 0
|
||||||
|
0 0 168
|
||||||
|
0 168 0
|
||||||
|
0 168 168
|
||||||
|
168 0 0
|
||||||
|
168 0 168
|
||||||
|
168 84 0
|
||||||
|
168 168 168
|
||||||
|
84 84 84
|
||||||
|
84 84 252
|
||||||
|
84 252 84
|
||||||
|
84 252 252
|
||||||
|
252 84 84
|
||||||
|
252 84 252
|
||||||
|
252 252 84
|
||||||
|
252 252 252
|
||||||
|
236 236 236
|
||||||
|
220 220 220
|
||||||
|
208 208 208
|
||||||
|
192 192 192
|
||||||
|
180 180 180
|
||||||
|
168 168 168
|
||||||
|
152 152 152
|
||||||
|
140 140 140
|
||||||
|
124 124 124
|
||||||
|
112 112 112
|
||||||
|
100 100 100
|
||||||
|
84 84 84
|
||||||
|
72 72 72
|
||||||
|
56 56 56
|
||||||
|
44 44 44
|
||||||
|
32 32 32
|
||||||
|
252 0 0
|
||||||
|
236 0 0
|
||||||
|
224 0 0
|
||||||
|
212 0 0
|
||||||
|
200 0 0
|
||||||
|
188 0 0
|
||||||
|
176 0 0
|
||||||
|
164 0 0
|
||||||
|
152 0 0
|
||||||
|
136 0 0
|
||||||
|
124 0 0
|
||||||
|
112 0 0
|
||||||
|
100 0 0
|
||||||
|
88 0 0
|
||||||
|
76 0 0
|
||||||
|
64 0 0
|
||||||
|
252 216 216
|
||||||
|
252 184 184
|
||||||
|
252 156 156
|
||||||
|
252 124 124
|
||||||
|
252 92 92
|
||||||
|
252 64 64
|
||||||
|
252 32 32
|
||||||
|
252 0 0
|
||||||
|
252 168 92
|
||||||
|
252 152 64
|
||||||
|
252 136 32
|
||||||
|
252 120 0
|
||||||
|
228 108 0
|
||||||
|
204 96 0
|
||||||
|
180 84 0
|
||||||
|
156 76 0
|
||||||
|
252 252 216
|
||||||
|
252 252 184
|
||||||
|
252 252 156
|
||||||
|
252 252 124
|
||||||
|
252 248 92
|
||||||
|
252 244 64
|
||||||
|
252 244 32
|
||||||
|
252 244 0
|
||||||
|
228 216 0
|
||||||
|
204 196 0
|
||||||
|
180 172 0
|
||||||
|
156 156 0
|
||||||
|
132 132 0
|
||||||
|
112 108 0
|
||||||
|
88 84 0
|
||||||
|
64 64 0
|
||||||
|
208 252 92
|
||||||
|
196 252 64
|
||||||
|
180 252 32
|
||||||
|
160 252 0
|
||||||
|
144 228 0
|
||||||
|
128 204 0
|
||||||
|
116 180 0
|
||||||
|
96 156 0
|
||||||
|
216 252 216
|
||||||
|
188 252 184
|
||||||
|
156 252 156
|
||||||
|
128 252 124
|
||||||
|
96 252 92
|
||||||
|
64 252 64
|
||||||
|
32 252 32
|
||||||
|
0 252 0
|
||||||
|
0 252 0
|
||||||
|
0 236 0
|
||||||
|
0 224 0
|
||||||
|
0 212 0
|
||||||
|
4 200 0
|
||||||
|
4 188 0
|
||||||
|
4 176 0
|
||||||
|
4 164 0
|
||||||
|
4 152 0
|
||||||
|
4 136 0
|
||||||
|
4 124 0
|
||||||
|
4 112 0
|
||||||
|
4 100 0
|
||||||
|
4 88 0
|
||||||
|
4 76 0
|
||||||
|
4 64 0
|
||||||
|
216 252 252
|
||||||
|
184 252 252
|
||||||
|
156 252 252
|
||||||
|
124 252 248
|
||||||
|
92 252 252
|
||||||
|
64 252 252
|
||||||
|
32 252 252
|
||||||
|
0 252 252
|
||||||
|
0 228 228
|
||||||
|
0 204 204
|
||||||
|
0 180 180
|
||||||
|
0 156 156
|
||||||
|
0 132 132
|
||||||
|
0 112 112
|
||||||
|
0 88 88
|
||||||
|
0 64 64
|
||||||
|
92 188 252
|
||||||
|
64 176 252
|
||||||
|
32 168 252
|
||||||
|
0 156 252
|
||||||
|
0 140 228
|
||||||
|
0 124 204
|
||||||
|
0 108 180
|
||||||
|
0 92 156
|
||||||
|
216 216 252
|
||||||
|
184 188 252
|
||||||
|
156 156 252
|
||||||
|
124 128 252
|
||||||
|
92 96 252
|
||||||
|
64 64 252
|
||||||
|
32 36 252
|
||||||
|
0 4 252
|
||||||
|
0 0 252
|
||||||
|
0 0 236
|
||||||
|
0 0 224
|
||||||
|
0 0 212
|
||||||
|
0 0 200
|
||||||
|
0 0 188
|
||||||
|
0 0 176
|
||||||
|
0 0 164
|
||||||
|
0 0 152
|
||||||
|
0 0 136
|
||||||
|
0 0 124
|
||||||
|
0 0 112
|
||||||
|
0 0 100
|
||||||
|
0 0 88
|
||||||
|
0 0 76
|
||||||
|
0 0 64
|
||||||
|
40 40 40
|
||||||
|
252 224 52
|
||||||
|
252 212 36
|
||||||
|
252 204 24
|
||||||
|
252 192 8
|
||||||
|
252 180 0
|
||||||
|
180 32 252
|
||||||
|
168 0 252
|
||||||
|
152 0 228
|
||||||
|
128 0 204
|
||||||
|
116 0 180
|
||||||
|
96 0 156
|
||||||
|
80 0 132
|
||||||
|
68 0 112
|
||||||
|
52 0 88
|
||||||
|
40 0 64
|
||||||
|
252 216 252
|
||||||
|
252 184 252
|
||||||
|
252 156 252
|
||||||
|
252 124 252
|
||||||
|
252 92 252
|
||||||
|
252 64 252
|
||||||
|
252 32 252
|
||||||
|
252 0 252
|
||||||
|
224 0 228
|
||||||
|
200 0 204
|
||||||
|
180 0 180
|
||||||
|
156 0 156
|
||||||
|
132 0 132
|
||||||
|
108 0 112
|
||||||
|
88 0 88
|
||||||
|
64 0 64
|
||||||
|
252 232 220
|
||||||
|
252 224 208
|
||||||
|
252 216 196
|
||||||
|
252 212 188
|
||||||
|
252 204 176
|
||||||
|
252 196 164
|
||||||
|
252 188 156
|
||||||
|
252 184 144
|
||||||
|
252 176 128
|
||||||
|
252 164 112
|
||||||
|
252 156 96
|
||||||
|
240 148 92
|
||||||
|
232 140 88
|
||||||
|
220 136 84
|
||||||
|
208 128 80
|
||||||
|
200 124 76
|
||||||
|
188 120 72
|
||||||
|
180 112 68
|
||||||
|
168 104 64
|
||||||
|
160 100 60
|
||||||
|
156 96 56
|
||||||
|
144 92 52
|
||||||
|
136 88 48
|
||||||
|
128 80 44
|
||||||
|
116 76 40
|
||||||
|
108 72 36
|
||||||
|
92 64 32
|
||||||
|
84 60 28
|
||||||
|
72 56 24
|
||||||
|
64 48 24
|
||||||
|
56 44 20
|
||||||
|
40 32 12
|
||||||
|
96 0 100
|
||||||
|
0 100 100
|
||||||
|
0 96 96
|
||||||
|
0 0 28
|
||||||
|
0 0 44
|
||||||
|
48 36 16
|
||||||
|
72 0 72
|
||||||
|
80 0 80
|
||||||
|
0 0 52
|
||||||
|
28 28 28
|
||||||
|
76 76 76
|
||||||
|
92 92 92
|
||||||
|
64 64 64
|
||||||
|
48 48 48
|
||||||
|
52 52 52
|
||||||
|
216 244 244
|
||||||
|
184 232 232
|
||||||
|
156 220 220
|
||||||
|
116 200 200
|
||||||
|
72 192 192
|
||||||
|
32 180 180
|
||||||
|
32 176 176
|
||||||
|
0 164 164
|
||||||
|
0 152 152
|
||||||
|
0 140 140
|
||||||
|
0 132 132
|
||||||
|
0 124 124
|
||||||
|
0 120 120
|
||||||
|
0 116 116
|
||||||
|
0 112 112
|
||||||
|
0 108 108
|
||||||
|
152 0 136
|
||||||
Reference in New Issue
Block a user