Start making the demo lev

This commit is contained in:
Miloslav Číž 2018-09-05 15:59:34 +02:00
parent fd7c28cc7d
commit ec72771e8a

View file

@ -10,6 +10,7 @@
//#define RAYCAST_TINY
#include <stdio.h>
#define VERTICAL_FOV UNITS_PER_SQUARE // for raycastlib
#include "raycastlib.h"
#include "Pokitto.h"
@ -30,6 +31,59 @@ Pokitto::Core p;
Unit zBuffer[SUBSAMPLED_WIDTH];
#define LEVEL_X_RES 29
#define LEVEL_Y_RES 21
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,
40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,40, 2, 2, 2,40,32,32,32,32,32,32,32,48, 2, 2, 2,26,
40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,40, 2, 2, 2,40, 0, 0, 0, 0, 0,32,32,40, 2, 2, 2,26,
40,16,12, 8, 4, 0,48, 0, 0, 0, 0, 0,24, 2,24, 8,24, 0, 0, 9, 9, 0,28,32,48, 2, 2, 2,24,
40,20,48,48,48,48,48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0,24,32,40, 0, 0, 0,24,
40,24,48,40,40,40,40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,20,32,48, 0, 0, 0,24,
40,28,32,32,32,32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 8,16,32,40, 0, 0, 0,24,
40,32,32,32,32,32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,32,32,32,32,32,32,48, 0, 0, 0,24,
40, 0,48,40,40,40,40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,32,-3,-8,-8,-5,-2, 0, 0, 0, 0,24,
40, 0, 3,-8,-8,-8,32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,32,-3,-8,-8, 0, 0, 0, 0, 0, 0,24,
40, 0, 6,-8,-8,-8,32, 0, 0, 0,48,48, 0,48,48, 0, 0,36,32,36,-8,-8, 0, 0, 0, 0, 0, 0,24,
40, 0,48,-8,-8,-8,32,32,32,32,40, 1, 0, 1,40,32,32,32,32,32,-8,-8, 0, 0, 0, 0, 0, 0,24,
40, 0,48,-8,-8,-8,-8,-8,-8,-8,-8, 0, 0, 0,-8,-8,-8,36,32,36,-8,-8, 0, 0, 0, 0, 0, 0,24,
40, 0,48,-8,-8,-8,-8,-8,-8,-8,-8, 0, 0, 0,-8,-8,-8,-8,-8,-8,-8,-8, 0, 0, 0, 0, 0, 0,24,
40, 0,48, 0,-2,-2, 0,-8,-8,-8,-8, 0, 0, 0,-8,-8, 0, 0, 0, 0, 0, 0, 0, 0,24,24,15,24,24,
40, 0, 0, 0,-2,-2, 0, 0, 0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0,24, 0, 0, 0,24,
40, 0, 0, 0,-2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,24, 0, 0, 0,24,
40,24,48,-2,-2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,24,
0,24,48,48,-2,-2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,24,
0,24,48,48,48,-2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,24, 0, 0, 0,24,
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
};
const signed char levelCeiling[] =
{
40,40,40,40,40,40,40,99,99,99,99,99,40,40,40,40,40,40,99,99,99,99,99,99,99,99,99,99,99,
40,99,99,99,99,99,20,99,99,99,99,99,40,99,99,99,99,40,99,99,99,99,99,99,99,99,99,99,99,
40,99,99,99,99,99,20,99,99,99,99,99,40,99,99,99,99,40,99,99,99,99,99,99,99,99,99,99,99,
40,99,99,99,99,99,48,99,99,99,99,99,24,24,24,24,24,40,99,99,99,99,99,99,99,99,99,99,99,
40,99,48,48,48,48,48,99,99,99,99,99,42,42,42,42,42,99,99,99,99,99,99,99,99,99,99,99,99,
40,99,48,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
40,99,48,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
40,99,48,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
40,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
40,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
40,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
40,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
40,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
40,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,24,24,24,24,24,24,
40,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,24,24,24,24,24,24,
40,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,24,24,25,27,29,24,
40,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,24,24,25,27,29,24,
40,24,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,24,24,25,27,29,24,
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,24,24,25,27,29,24,
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,24,24,25,27,29,24,
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,24,24,24,24,24,24
};
const unsigned char image[] =
{ 32, 32 // width, height
,0x12,0x65,0x65,0x6d,0x24,0x64,0x5b,0x12,0x12,0x64,0x5b,0x5b,0x12,0x51
@ -451,23 +505,20 @@ Sprite sprites[SPRITES];
Unit floorHeight(int16_t x, int16_t y)
{
if (x > 12 || y > 12)
return (max(x,y) - 10) * UNITS_PER_SQUARE / 2;
if (x >= 0 && x < LEVEL_X_RES && y >= 0 && y < LEVEL_Y_RES)
return (levelFloor[(LEVEL_Y_RES - y -1) * LEVEL_X_RES + x] * UNITS_PER_SQUARE) / 8;
if (y < 5 && y > 0)
{
return (y > 2 ? x : -x) * UNITS_PER_SQUARE / 2;
}
return ((x < 0 || y < 0 || x > 9 || y > 9) ? 4 : 0) * UNITS_PER_SQUARE / 2;
return 0;
}
Unit ceilingHeight(int16_t x, int16_t y)
{
if (x > 12 || y > 12)
return (10 + (11 - max(x,y))) * UNITS_PER_SQUARE / 2;
signed char v = 99;
return 10 * UNITS_PER_SQUARE;
if (x >= 0 && x < LEVEL_X_RES && y >= 0 && y < LEVEL_Y_RES)
v = levelCeiling[(LEVEL_Y_RES - y -1) * LEVEL_X_RES + x];
return (v * UNITS_PER_SQUARE) / 8;
}
inline void pixelFunc(PixelInfo pixel)
@ -546,9 +597,9 @@ void draw()
p.display.setColor(rgbToIndex(7,7,3));
p.display.setCursor(1,1);
p.display.print(player.mCamera.position.x);
p.display.print(divRoundDown(player.mCamera.position.x,UNITS_PER_SQUARE));
p.display.print(" ");
p.display.print(player.mCamera.position.y);
p.display.print(divRoundDown(player.mCamera.position.y,UNITS_PER_SQUARE));
p.display.print(" ");
p.display.print(player.mCamera.direction);