From 9129659e62787b2457a93b84ad7d59ee8cb0eaaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sat, 8 Sep 2018 15:00:13 +0200 Subject: [PATCH] Move more stuff to general --- demo1.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/demo1.cpp b/demo1.cpp index 6a2ecd8..1bc0a50 100644 --- a/demo1.cpp +++ b/demo1.cpp @@ -9,9 +9,6 @@ #include "general.hpp" -#define SUBSAMPLE 2 -#define SUBSAMPLED_WIDTH (SCREEN_WIDTH / SUBSAMPLE) - #define LEVEL_X_RES 29 #define LEVEL_Y_RES 21 @@ -19,8 +16,10 @@ Player player; #define SPRITES 3 #define SPRITE_MAX_DISTANCE 5 * UNITS_PER_SQUARE + Sprite sprites[SPRITES]; +/// For each level square says the texture index. const unsigned char levelTexture[] = { 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, 3, 3, 2, 2, 2, 2, @@ -46,6 +45,7 @@ const unsigned char levelTexture[] = 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3 }; +/// For each level square says the floor height. const signed char levelFloor[] = { 40,40,40,40,40,40,40,40,48,40,48,40,40,40,40,40,40,48,40,48,40,48,40,48,48,24,24,26,28, @@ -71,6 +71,7 @@ const signed char levelFloor[] = 0,24,24,24,32,32,32,27,24,27,30,34,36,38,36,34,36,34,34,32,32,33,37,39,24,24,24,24,24 }; +/// For each level square says the ceiling height. const signed char levelCeiling[] = { 40,40,40,40,40,40,40,99,99,99,99,36,40,40,40,40,40,36,99,99,99,99,99,99,99,99,99,99,99, @@ -566,7 +567,6 @@ const unsigned char sprite2[] = const unsigned char *textures[] = {texture1, texture2, texture3, texture4}; - Unit textureAt(int16_t x, int16_t y) { if (x >= 0 && x < LEVEL_X_RES && y >= 0 && y < LEVEL_Y_RES) @@ -593,6 +593,9 @@ Unit ceilingHeightAt(int16_t x, int16_t y) return (v * UNITS_PER_SQUARE) / 8; } +/** + Function for drawing a single pixel (like fragment shader). +*/ inline void pixelFunc(PixelInfo pixel) { if (pixel.position.y == MIDDLE_ROW)