From 69fac865ee55631e29a5bcfd7df5f47b972b55d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sun, 9 Sep 2018 19:11:44 +0200 Subject: [PATCH] Fix texturing --- demo2.cpp | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++-- general.hpp | 2 +- 2 files changed, 90 insertions(+), 3 deletions(-) diff --git a/demo2.cpp b/demo2.cpp index cab238e..09619a4 100644 --- a/demo2.cpp +++ b/demo2.cpp @@ -40,7 +40,7 @@ const unsigned char level[] = 0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,1,1,1,0,1,1,1,1,1,0,0,1,1,1, // 9 0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1, // 10 0,0,0,0,3,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,1,0,0,0,0,0,3,0,1, // 11 - 1,3,1,0,1,1,1,1,1,1,2,0,2,2,3,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1, // 12 + 1,3,1,0,1,1,4,4,4,1,2,0,2,2,3,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1, // 12 0,0,0,0,0,0,0,0,0,1,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,1, // 13 0,3,0,3,0,3,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, // 14 0,0,0,0,0,0,0,0,0,1,0,0,0,0,2,0,0,0,0,0,0,0,0,1,0,3,0,3,0,3,0,1 // 15 @@ -307,6 +307,93 @@ const unsigned char texture3[] = ,0x09,0x09,0x11,0x08 }; +const unsigned char texture4[] = +{ 32, 36 // width, height + ,0x00,0x09,0x00,0x00,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0x51,0x09,0xbd,0xbd + ,0xbd,0xa3,0x09,0xa3,0xa3,0xa3,0xa3,0xa3,0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x59 + ,0x59,0x59,0x61,0x09,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0x59,0x09,0x09 + ,0x00,0x08,0x00,0x00,0x21,0x21,0x21,0x21,0x21,0x09,0xa3,0xa3,0xa3,0xa3 + ,0xa3,0xa3,0xa3,0x51,0x09,0x59,0x61,0x61,0x61,0x61,0x61,0x09,0xa3,0xa3 + ,0xa3,0xa3,0xa3,0xa3,0xa3,0x59,0x09,0x09,0x00,0x09,0x00,0x00,0x21,0x21 + ,0x21,0x21,0x21,0x21,0x09,0xa3,0xa3,0xa3,0xa3,0xa3,0x51,0x09,0x59,0x61 + ,0x61,0x61,0x61,0x61,0x61,0x61,0x09,0xa3,0xa3,0xa3,0xa3,0xa3,0x51,0x11 + ,0x09,0x09,0x00,0x09,0x00,0x00,0x21,0x21,0x21,0x21,0x21,0x21,0x09,0xa3 + ,0x51,0x51,0x51,0x51,0x51,0x09,0x59,0x61,0x61,0x61,0x61,0x61,0x61,0x61 + ,0x09,0xa3,0x51,0x51,0x51,0x51,0x51,0x59,0x09,0x09,0x00,0x09,0x00,0x00 + ,0x21,0x21,0x21,0x21,0x21,0x21,0x19,0x09,0x09,0x09,0x09,0x09,0x09,0x59 + ,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0xa3,0x09,0x09,0x09,0x09,0x09 + ,0x09,0x59,0x09,0x09,0x00,0x09,0x00,0x00,0x21,0x21,0x21,0x21,0x21,0x19 + ,0x09,0xbd,0xbd,0xbd,0xbd,0xbd,0xa3,0x09,0x61,0x61,0x61,0x61,0x61,0x61 + ,0x61,0x9b,0x09,0x59,0x59,0x59,0x59,0x59,0x61,0x59,0x09,0x09,0x00,0x09 + ,0x00,0x00,0x21,0x21,0x21,0x21,0x19,0x09,0xbd,0xa3,0xa3,0xa3,0xa3,0xa3 + ,0xa3,0x09,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x9b,0x59,0x61,0x61,0x61 + ,0x61,0x61,0x61,0x59,0x09,0x09,0x00,0x09,0x00,0x00,0x21,0x21,0x21,0x21 + ,0x19,0x09,0xbd,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0x09,0x61,0x61,0x61 + ,0x61,0x61,0xa3,0x09,0x59,0x61,0x61,0x61,0x61,0x61,0x61,0x59,0x09,0x09 + ,0x00,0x09,0x00,0x00,0x19,0x19,0x19,0x19,0x09,0xbd,0xa3,0xa3,0xa3,0xa3 + ,0xa3,0xa3,0xa3,0xa3,0x09,0x61,0xa3,0xa3,0xa3,0xa3,0x09,0x59,0x61,0x61 + ,0x61,0x61,0x61,0x61,0x61,0x59,0x09,0x09,0x00,0x09,0x00,0x00,0x09,0x09 + ,0x09,0x09,0xbd,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0x09 + ,0x09,0x09,0x09,0x09,0x59,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x59 + ,0x09,0x09,0x00,0x09,0x00,0x00,0x59,0x59,0x59,0x61,0x09,0xa3,0xa3,0xa3 + ,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0x51,0x09,0x59,0x59,0x59,0x61,0x09,0x61 + ,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x59,0x09,0x09,0x00,0x09,0x00,0x00 + ,0x61,0x61,0x61,0x61,0x61,0x09,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0x51 + ,0x09,0x59,0x61,0x61,0x61,0x61,0x61,0x09,0x61,0x61,0x61,0x61,0x61,0x61 + ,0x61,0x11,0x09,0x09,0x00,0x09,0x00,0x00,0x61,0x61,0x61,0x61,0x61,0x09 + ,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0x51,0x09,0x59,0x61,0x61,0x61,0x61 + ,0x61,0x09,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x59,0x09,0x09,0x00,0x09 + ,0x00,0x00,0x61,0x61,0x61,0x61,0x61,0x61,0x09,0xa3,0xa3,0xa3,0xa3,0xa3 + ,0x51,0x09,0x59,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x09,0x61,0x61,0x61 + ,0x61,0x61,0xa3,0x59,0x09,0x09,0x00,0x08,0x00,0x00,0x61,0x61,0x61,0x61 + ,0x61,0x61,0x09,0xa3,0x51,0x51,0x51,0x51,0x51,0x09,0x59,0x61,0x61,0x61 + ,0x61,0x61,0x61,0x61,0x09,0x61,0xa3,0xa3,0xa3,0xa3,0xa3,0x59,0x09,0x09 + ,0x00,0x09,0x00,0x00,0x61,0x61,0x61,0x61,0x61,0x61,0xa3,0x09,0x09,0x09 + ,0x09,0x09,0x09,0x59,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0x61,0xa3,0x09 + ,0x09,0x09,0x09,0x09,0x09,0x59,0x09,0x09,0x00,0x08,0x00,0x00,0x61,0x61 + ,0x61,0x61,0x61,0xa3,0x09,0xbd,0xbd,0xbd,0xbd,0xbd,0xa3,0x09,0x61,0x61 + ,0x61,0x61,0x61,0x61,0x61,0xa3,0x09,0xbd,0xbd,0xbd,0xbd,0xbd,0xa3,0x59 + ,0x09,0x09,0x00,0x09,0x00,0x00,0x61,0x61,0x61,0x61,0xa3,0x09,0xbd,0xa3 + ,0xa3,0xa3,0xa3,0xa3,0xa3,0x09,0x61,0x61,0x61,0x61,0x61,0x61,0xa3,0x09 + ,0xbd,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0x59,0x09,0x09,0x00,0x09,0x00,0x00 + ,0xa3,0xa3,0xa3,0xa3,0xa3,0x09,0xbd,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3 + ,0x09,0x61,0xa3,0xa3,0xa3,0xa3,0xa3,0x09,0xbd,0xa3,0xa3,0xa3,0xa3,0xa3 + ,0xa3,0x59,0x09,0x09,0x00,0x09,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0xbd + ,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0x51,0x09,0x09,0x09,0x09,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0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0xa3,0x09,0x09,0x09,0x09,0x09 + ,0x09,0x59,0x09,0x09 +}; + const unsigned char sprite1[] = { 32, 32 // width, height ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00 @@ -463,7 +550,7 @@ const unsigned char sprite2[] = ,0x07,0x07 }; -const unsigned char *textures[] = {texture1, texture2, texture3}; +const unsigned char *textures[] = {texture1, texture2, texture3, texture4}; Unit floorHeightAt(int16_t x, int16_t y) { diff --git a/general.hpp b/general.hpp index 2aed030..df63115 100644 --- a/general.hpp +++ b/general.hpp @@ -126,7 +126,7 @@ inline uint8_t sampleImage(const unsigned char *image, Unit x, Unit y) y = wrap(y,UNITS_PER_SQUARE); int32_t index = - image[1] * ((image[1] * x) / UNITS_PER_SQUARE) + (image[0] * y) / + image[1] * ((image[0] * x) / UNITS_PER_SQUARE) + (image[0] * y) / UNITS_PER_SQUARE; return image[2 + index];