Update demo2
This commit is contained in:
parent
c7e8638db7
commit
74907ece37
1 changed files with 26 additions and 26 deletions
52
demo2.cpp
52
demo2.cpp
|
@ -10,8 +10,6 @@
|
||||||
#define FPS 60
|
#define FPS 60
|
||||||
#define PLAYER_SPEED (UNITS_PER_SQUARE * 3)
|
#define PLAYER_SPEED (UNITS_PER_SQUARE * 3)
|
||||||
|
|
||||||
#define SUBSAMPLE 1
|
|
||||||
|
|
||||||
#include "general.hpp"
|
#include "general.hpp"
|
||||||
|
|
||||||
#define LEVEL_X_RES 32
|
#define LEVEL_X_RES 32
|
||||||
|
@ -28,22 +26,24 @@ Sprite sprites[SPRITES];
|
||||||
|
|
||||||
const unsigned char level[] =
|
const unsigned char level[] =
|
||||||
{
|
{
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,
|
/* 10 12 14 16 18 20 22 24 26 28 30
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,
|
0 1 2 3 4 5 6 7 8 9 11 13 15 17 19 21 23 25 27 29 31 */
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0, // 0
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0, // 1
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, // 2
|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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 10
|
||||||
0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,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,0,0,0,0, // 11
|
||||||
0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
1,3,1,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 12
|
||||||
0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 13
|
||||||
|
0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 14
|
||||||
|
0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 // 15
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned char texture1[] =
|
const unsigned char texture1[] =
|
||||||
|
@ -482,6 +482,8 @@ Unit textureAt(int16_t x, int16_t y)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t cFloor, cCeiling;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Function for drawing a single pixel (like fragment shader).
|
Function for drawing a single pixel (like fragment shader).
|
||||||
*/
|
*/
|
||||||
|
@ -495,10 +497,10 @@ inline void pixelFunc(PixelInfo pixel)
|
||||||
if (pixel.isWall)
|
if (pixel.isWall)
|
||||||
{
|
{
|
||||||
c = sampleImage(textures[pixel.hit.type],pixel.hit.textureCoord,pixel.textureCoordY);
|
c = sampleImage(textures[pixel.hit.type],pixel.hit.textureCoord,pixel.textureCoordY);
|
||||||
c = addIntensity(c,pixel.hit.direction % 2 == 0 ? 2 : 0);
|
c = addIntensity(c,2 - pixel.depth / (UNITS_PER_SQUARE * 2) + (pixel.hit.direction % 2 == 0 ? 2 : 0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
c = pixel.isFloor ? 100 : 50;
|
c = pixel.isFloor ? cFloor: cCeiling;
|
||||||
|
|
||||||
uint8_t *buf = pokitto.display.screenbuffer;
|
uint8_t *buf = pokitto.display.screenbuffer;
|
||||||
|
|
||||||
|
@ -560,8 +562,10 @@ pokitto.display.print(player.mCamera.direction);
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
pokitto.begin();
|
initGeneral();
|
||||||
initPalette();
|
|
||||||
|
cFloor = rgbToIndex(0,1,1);
|
||||||
|
cCeiling = rgbToIndex(1,0,1);
|
||||||
|
|
||||||
player.setPositionSquare(6,5);
|
player.setPositionSquare(6,5);
|
||||||
player.mCamera.height = CAMERA_COLL_HEIGHT_BELOW;
|
player.mCamera.height = CAMERA_COLL_HEIGHT_BELOW;
|
||||||
|
@ -571,10 +575,6 @@ int main()
|
||||||
sprites[2] = Sprite(sprite2,15,19,1,150);
|
sprites[2] = Sprite(sprite2,15,19,1,150);
|
||||||
sprites[2].mHeight -= UNITS_PER_SQUARE / 2;
|
sprites[2].mHeight -= UNITS_PER_SQUARE / 2;
|
||||||
|
|
||||||
pokitto.display.persistence = 1;
|
|
||||||
pokitto.setFrameRate(FPS);
|
|
||||||
pokitto.display.setFont(fontTiny);
|
|
||||||
|
|
||||||
uint32_t previousTime = 0;
|
uint32_t previousTime = 0;
|
||||||
uint32_t dt;
|
uint32_t dt;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue