summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp30
-rw-r--r--src/renderer.cpp6
2 files changed, 29 insertions, 7 deletions
diff --git a/src/game.cpp b/src/game.cpp index 9d557e3..08c96ee 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -283,6 +283,7 @@ void Game::recalculateRender() {
283 { 283 {
284 if (map.at(x,y).dirtyRender) { 284 if (map.at(x,y).dirtyRender) {
285 map.at(x,y).dirtyRender = false; 285 map.at(x,y).dirtyRender = false;
286 map.at(x,y).renderId = -1;
286 287
287 if (map.tile(x,y) == Tile::Floor) { 288 if (map.tile(x,y) == Tile::Floor) {
288 int renderDesc = 0; 289 int renderDesc = 0;
@@ -313,12 +314,11 @@ void Game::recalculateRender() {
313 map.at(x,y).sign = false; 314 map.at(x,y).sign = false;
314 } 315 }
315 } else { 316 } else {
316 map.at(x,y).renderId = -1;
317 map.at(x,y).sign = false; 317 map.at(x,y).sign = false;
318 } 318 }
319 } else if (map.tile(x,y) == Tile::Wall) { 319 } else if (map.tile(x,y) == Tile::Wall) {
320 static bool initWalls = false; 320 static bool initWalls = false;
321 static std::vector<int> wallRenders(256, TilesetIndex(0, 0)); 321 static std::vector<int> wallRenders(256, TilesetIndex(21, 12));
322 if (!initWalls) { 322 if (!initWalls) {
323 initWalls = true; 323 initWalls = true;
324 324
@@ -327,41 +327,51 @@ void Game::recalculateRender() {
327 wallRenders[0b00111100] = TilesetIndex(16, 14); 327 wallRenders[0b00111100] = TilesetIndex(16, 14);
328 wallRenders[0b00011110] = TilesetIndex(16, 14); 328 wallRenders[0b00011110] = TilesetIndex(16, 14);
329 wallRenders[0b00111110] = TilesetIndex(16, 14); 329 wallRenders[0b00111110] = TilesetIndex(16, 14);
330 wallRenders[0b00111101] = TilesetIndex(16, 14);
331 wallRenders[0b10011101] = TilesetIndex(16, 14);
330 332
331 wallRenders[0b00011111] = TilesetIndex(17, 14); 333 wallRenders[0b00011111] = TilesetIndex(17, 14);
332 wallRenders[0b10011111] = TilesetIndex(17, 14); 334 wallRenders[0b10011111] = TilesetIndex(17, 14);
333 wallRenders[0b00111111] = TilesetIndex(17, 14); 335 wallRenders[0b00111111] = TilesetIndex(17, 14);
334 wallRenders[0b10111111] = TilesetIndex(17, 14); 336 wallRenders[0b10111111] = TilesetIndex(17, 14);
337 wallRenders[0b01011111] = TilesetIndex(17, 14);
335 338
336 wallRenders[0b00000111] = TilesetIndex(18, 14); 339 wallRenders[0b00000111] = TilesetIndex(18, 14);
337 wallRenders[0b00001111] = TilesetIndex(18, 14); 340 wallRenders[0b00001111] = TilesetIndex(18, 14);
338 wallRenders[0b10000111] = TilesetIndex(18, 14); 341 wallRenders[0b10000111] = TilesetIndex(18, 14);
339 wallRenders[0b10001111] = TilesetIndex(18, 14); 342 wallRenders[0b10001111] = TilesetIndex(18, 14);
343 wallRenders[0b10101111] = TilesetIndex(18, 14);
340 344
341 wallRenders[0b01111100] = TilesetIndex(16, 15); 345 wallRenders[0b01111100] = TilesetIndex(16, 15);
342 wallRenders[0b11111100] = TilesetIndex(16, 15); 346 wallRenders[0b11111100] = TilesetIndex(16, 15);
343 wallRenders[0b01111110] = TilesetIndex(16, 15); 347 wallRenders[0b01111110] = TilesetIndex(16, 15);
344 wallRenders[0b11111110] = TilesetIndex(16, 15); 348 wallRenders[0b11111110] = TilesetIndex(16, 15);
349 wallRenders[0b01111101] = TilesetIndex(16, 15);
345 350
346 wallRenders[0b11000111] = TilesetIndex(18, 15); 351 wallRenders[0b11000111] = TilesetIndex(18, 15);
347 wallRenders[0b11001111] = TilesetIndex(18, 15); 352 wallRenders[0b11001111] = TilesetIndex(18, 15);
348 wallRenders[0b11100111] = TilesetIndex(18, 15); 353 wallRenders[0b11100111] = TilesetIndex(18, 15);
349 wallRenders[0b11101111] = TilesetIndex(18, 15); 354 wallRenders[0b11101111] = TilesetIndex(18, 15);
355 wallRenders[0b11010111] = TilesetIndex(18, 15);
350 356
351 wallRenders[0b01110000] = TilesetIndex(16, 16); 357 wallRenders[0b01110000] = TilesetIndex(16, 16);
352 wallRenders[0b01111000] = TilesetIndex(16, 16); 358 wallRenders[0b01111000] = TilesetIndex(16, 16);
353 wallRenders[0b11110000] = TilesetIndex(16, 16); 359 wallRenders[0b11110000] = TilesetIndex(16, 16);
354 wallRenders[0b11111000] = TilesetIndex(16, 16); 360 wallRenders[0b11111000] = TilesetIndex(16, 16);
361 wallRenders[0b11111010] = TilesetIndex(16, 16);
355 362
356 wallRenders[0b11110001] = TilesetIndex(17, 16); 363 wallRenders[0b11110001] = TilesetIndex(17, 16);
357 wallRenders[0b11110011] = TilesetIndex(17, 16); 364 wallRenders[0b11110011] = TilesetIndex(17, 16);
358 wallRenders[0b11111001] = TilesetIndex(17, 16); 365 wallRenders[0b11111001] = TilesetIndex(17, 16);
359 wallRenders[0b11111011] = TilesetIndex(17, 16); 366 wallRenders[0b11111011] = TilesetIndex(17, 16);
367 wallRenders[0b11110101] = TilesetIndex(17, 16);
360 368
361 wallRenders[0b11000001] = TilesetIndex(18, 16); 369 wallRenders[0b11000001] = TilesetIndex(18, 16);
362 wallRenders[0b11000011] = TilesetIndex(18, 16); 370 wallRenders[0b11000011] = TilesetIndex(18, 16);
363 wallRenders[0b11100001] = TilesetIndex(18, 16); 371 wallRenders[0b11100001] = TilesetIndex(18, 16);
364 wallRenders[0b11100011] = TilesetIndex(18, 16); 372 wallRenders[0b11100011] = TilesetIndex(18, 16);
373 wallRenders[0b11001001] = TilesetIndex(18, 16);
374 wallRenders[0b11011001] = TilesetIndex(18, 16);
365 375
366 376
367 wallRenders[0b11110111] = TilesetIndex(21, 14); 377 wallRenders[0b11110111] = TilesetIndex(21, 14);
@@ -382,8 +392,20 @@ void Game::recalculateRender() {
382 392
383 map.at(x,y).renderId = wallRenders.at(renderDesc); 393 map.at(x,y).renderId = wallRenders.at(renderDesc);
384 394
385 if (wallRenders.at(renderDesc) == 0 && renderDesc != 255) { 395 if (wallRenders.at(renderDesc) == TilesetIndex(21, 12) && renderDesc != 255) {
386 std::cout << renderDesc << std::endl; 396 //std::cout << renderDesc << std::endl;
397 std::cout << ((renderDesc & (1 << 7)) ? 'X' : 'O');
398 std::cout << ((renderDesc & (1 << 6)) ? 'X' : 'O');
399 std::cout << ((renderDesc & (1 << 5)) ? 'X' : 'O');
400 std::cout << std::endl;
401 std::cout << ((renderDesc & (1 << 0)) ? 'X' : 'O');
402 std::cout << ' ';
403 std::cout << ((renderDesc & (1 << 4)) ? 'X' : 'O');
404 std::cout << " " << renderDesc << std::endl;
405 std::cout << ((renderDesc & (1 << 1)) ? 'X' : 'O');
406 std::cout << ((renderDesc & (1 << 2)) ? 'X' : 'O');
407 std::cout << ((renderDesc & (1 << 3)) ? 'X' : 'O');
408 std::cout << std::endl;
387 } 409 }
388 } 410 }
389 } 411 }
diff --git a/src/renderer.cpp b/src/renderer.cpp index 9744e70..10027dd 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp
@@ -173,7 +173,7 @@ void Renderer::renderGame(
173 173
174 if (draw) 174 if (draw)
175 { 175 {
176 if (game.map.tile(x,y) != Tile::Wall) { 176 /*if (game.map.tile(x,y) != Tile::Wall)*/ {
177 SDL_Rect tileRect {17 * 16, 15 * 16, 16, 16}; 177 SDL_Rect tileRect {17 * 16, 15 * 16, 16, 16};
178 SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect); 178 SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect);
179 179
@@ -182,7 +182,7 @@ void Renderer::renderGame(
182 tileRect.y = game.map.at(x,y).renderId / 25 * 16; 182 tileRect.y = game.map.at(x,y).renderId / 25 * 16;
183 SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect); 183 SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect);
184 } 184 }
185 } else { 185 }/* else {
186 SDL_Rect tileRect { 186 SDL_Rect tileRect {
187 game.map.at(x,y).renderId % 25 * 16, 187 game.map.at(x,y).renderId % 25 * 16,
188 game.map.at(x,y).renderId / 25 * 16, 188 game.map.at(x,y).renderId / 25 * 16,
@@ -190,7 +190,7 @@ void Renderer::renderGame(
190 16}; 190 16};
191 191
192 SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect); 192 SDL_RenderCopy(ren_.get(), tileset_.get(), &tileRect, &rect);
193 } 193 }*/
194 194
195 if (game.map.tile(x,y) == Tile::Lamp) { 195 if (game.map.tile(x,y) == Tile::Lamp) {
196 SDL_RenderCopy(ren_.get(), lamp_.get(), nullptr, &rect); 196 SDL_RenderCopy(ren_.get(), lamp_.get(), nullptr, &rect);