From 7102535deb6ff2a80b0eb1e4103dcb745a386ede Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Mon, 29 Sep 2025 14:16:56 +0200 Subject: [PATCH] =?UTF-8?q?-=20debug::println(char*,=20float)=20-=20Gr?= =?UTF-8?q?=C3=A0fic=20del=20balunet=20-=20Paleta=20afegida=20-=20sprite?= =?UTF-8?q?=20en=20altura=20correcta=20-=20sprite=20amb=20diferent=20textu?= =?UTF-8?q?ra=20-=20transparencies=20en=20el=20sprite=20-=20Makefile=20pa?= =?UTF-8?q?=20que=20JDes=20no=20haja=20de=20fer=20search=20en=20el=20chat?= =?UTF-8?q?=20cada=20volta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 + jdebug.cpp | 8 ++ main.cpp | 19 +++- player1.gif | Bin 0 -> 1134 bytes wolf.pal | 259 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 285 insertions(+), 3 deletions(-) create mode 100644 Makefile create mode 100644 player1.gif create mode 100644 wolf.pal diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4b1df4c --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +build: + g++ -g *.cpp -lSDL3 -o wolf diff --git a/jdebug.cpp b/jdebug.cpp index 5cb0d2c..0a7c94f 100644 --- a/jdebug.cpp +++ b/jdebug.cpp @@ -59,6 +59,14 @@ namespace debug newline(); } + void println(const char *label, float value) + { + print(label); + print(" "); + print(value); + newline(); + } + void print(int value) { char temp[20]; diff --git a/main.cpp b/main.cpp index 6f74499..3d53542 100644 --- a/main.cpp +++ b/main.cpp @@ -22,6 +22,7 @@ SDL_Texture *sdl_texture; Uint32 *palette; Uint8 *gif; +Uint8 *spr; Uint8 screen[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) { - 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) { screen[x+y*320]=color; @@ -429,6 +430,16 @@ int main(int argc, char *argv[]) palette = LoadPalette(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 //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); float dist = d * SDL_cosf(angle_to_enemy*DEG_TO_RAD); 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); for (int i=0; in1!K!sMu#lHIw~I8f#u~4B33su6C3U%KF!h^k>endR*4Y^hW#6bjjFR@Zg2 zGaipeqfu2=6-Dv;{pOe;2yVCA;c)OgPrxiN4NL-gAOoa;1P})zfC?yp9}oc#zyK;1 zDV-)wBUL3yBF1PQgpv})8AW*NMmYdOhVFyr0a1}CO{5X2^qWL;jOKWnL%9ee2mJsv z4dF1907M@cLxH3mF`f7!LadCCfuIgqLy?LZN^7KrNR>%q#CYOivR|+Omj{;tmjagn z7Y7#sr-D~J1AtOb(1Z6Zz$0!w|ghHD9(<@RX zDwZO?Ldcs}J(+GnSK5+~vmt+rCc9&jDX<9#hQ!EI$utJ`sR^K1ZDR~pJnM4QocTWwDH7s zcWL&spB{bTvc?Oc{5=nL>{@=yt&^3*<&Kw^-MOpf_=$&wS1-A}OWX9!_055sJJ)4i zeDdUbem3x@^vP{|M|X~;YIbB@D<*1N2Ua$GaB$}Cy({>pzSvuKVLyv4<+Ev)oJaWy)?MGhU`o_~Uiw}%0@BR8%{d1+s?ZJ1qu8cL* zE^852$$>uWy*K1~vP0uTwU>{2dain`b?}atE*KB|+&ZD%zq5U8YTL%)vG)C|!n;D2xmjHGE literal 0 HcmV?d00001 diff --git a/wolf.pal b/wolf.pal new file mode 100644 index 0000000..9292ed6 --- /dev/null +++ b/wolf.pal @@ -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