Update
This commit is contained in:
parent
c3f588031f
commit
d54399f7a3
4 changed files with 43 additions and 32 deletions
27
demo1.cpp
27
demo1.cpp
|
@ -727,16 +727,7 @@ inline void pixelFunc(PixelInfo *pixel)
|
||||||
rgbToIndex(intensity/2,intensity,intensity/3) :
|
rgbToIndex(intensity/2,intensity,intensity/3) :
|
||||||
rgbToIndex(intensity,intensity/2,0);
|
rgbToIndex(intensity,intensity/2,0);
|
||||||
|
|
||||||
uint8_t *buf = pokitto.display.screenbuffer;
|
putSubsampledPixel // macro
|
||||||
|
|
||||||
buf += pixel->position.x * SUBSAMPLE;
|
|
||||||
buf += pixel->position.y * SCREEN_WIDTH;
|
|
||||||
|
|
||||||
#pragma unroll
|
|
||||||
for (uint8_t i = 0; i < SUBSAMPLE - 1; ++i)
|
|
||||||
*buf++ = c;
|
|
||||||
|
|
||||||
*buf = c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw()
|
void draw()
|
||||||
|
@ -777,6 +768,20 @@ void draw()
|
||||||
|
|
||||||
previousDepth = pos.depth;
|
previousDepth = pos.depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// uncomment for debuggin camera
|
||||||
|
|
||||||
|
/*
|
||||||
|
pokitto.display.setColor(255);
|
||||||
|
pokitto.display.setCursor(1,1);
|
||||||
|
pokitto.display.print(player.mCamera.position.x);
|
||||||
|
pokitto.display.print(" ");
|
||||||
|
pokitto.display.print(player.mCamera.position.y);
|
||||||
|
pokitto.display.print(" ");
|
||||||
|
pokitto.display.print(player.mCamera.height);
|
||||||
|
pokitto.display.print(" ");
|
||||||
|
pokitto.display.print(player.mCamera.direction);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool runReleased = false; // helper for detecting switching between walk/run
|
bool runReleased = false; // helper for detecting switching between walk/run
|
||||||
|
@ -786,7 +791,7 @@ int main()
|
||||||
initGeneral();
|
initGeneral();
|
||||||
|
|
||||||
player.setPositionSquare(6,4);
|
player.setPositionSquare(6,4);
|
||||||
player.mCamera.direction = 256;
|
player.setPosition(7119,14343,5120,566);
|
||||||
|
|
||||||
sprites[0] = Sprite(sprite1,10,5,1,100);
|
sprites[0] = Sprite(sprite1,10,5,1,100);
|
||||||
sprites[1] = Sprite(sprite1,14,5,1,100);
|
sprites[1] = Sprite(sprite1,14,5,1,100);
|
||||||
|
|
11
demo2.cpp
11
demo2.cpp
|
@ -798,16 +798,7 @@ inline void pixelFunc(PixelInfo *pixel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *buf = pokitto.display.screenbuffer;
|
putSubsampledPixel // macro
|
||||||
|
|
||||||
buf += pixel->position.x * SUBSAMPLE;
|
|
||||||
buf += pixel->position.y * pokitto.display.width;
|
|
||||||
|
|
||||||
#pragma unroll
|
|
||||||
for (uint8_t i = 0; i < SUBSAMPLE - 1; ++i)
|
|
||||||
*buf++ = c;
|
|
||||||
|
|
||||||
*buf = c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw()
|
void draw()
|
||||||
|
|
11
demo3.cpp
11
demo3.cpp
|
@ -230,16 +230,7 @@ inline void pixelFunc(PixelInfo *pixel)
|
||||||
if (intensity != 0)
|
if (intensity != 0)
|
||||||
c = addIntensity(c,intensity);
|
c = addIntensity(c,intensity);
|
||||||
|
|
||||||
uint8_t *buf = pokitto.display.screenbuffer;
|
putSubsampledPixel // macro
|
||||||
|
|
||||||
buf += pixel->position.x * SUBSAMPLE;
|
|
||||||
buf += pixel->position.y * SCREEN_WIDTH;
|
|
||||||
|
|
||||||
#pragma unroll
|
|
||||||
for (uint8_t i = 0; i < SUBSAMPLE - 1; ++i)
|
|
||||||
*buf++ = c;
|
|
||||||
|
|
||||||
*buf = c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool flyBy = true;
|
bool flyBy = true;
|
||||||
|
|
26
general.hpp
26
general.hpp
|
@ -67,6 +67,22 @@ Unit zBuffer[SUBSAMPLED_WIDTH]; ///< 1D z-buffer for visibility determination.
|
||||||
|
|
||||||
unsigned short palette[256];
|
unsigned short palette[256];
|
||||||
|
|
||||||
|
// helper macro for fast pixel drawing
|
||||||
|
#ifdef POK_SIM
|
||||||
|
#define putSubsampledPixel\
|
||||||
|
pokitto.display.drawPixel(pixel->position.x * SUBSAMPLE,pixel->position.y,c);\
|
||||||
|
pokitto.display.drawPixel(pixel->position.x * SUBSAMPLE + 1,pixel->position.y,c);
|
||||||
|
#else
|
||||||
|
// this code breaks the simulator
|
||||||
|
#define putSubsampledPixel\
|
||||||
|
uint8_t *buf = pokitto.display.screenbuffer;\
|
||||||
|
buf += pixel->position.x * SUBSAMPLE;\
|
||||||
|
buf += pixel->position.y * SCREEN_WIDTH;\
|
||||||
|
for (uint8_t i = 0; i < SUBSAMPLE - 1; ++i)\
|
||||||
|
*buf++ = c;\
|
||||||
|
*buf = c;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gets (the index of) color by specified RGB components.
|
Gets (the index of) color by specified RGB components.
|
||||||
|
|
||||||
|
@ -250,6 +266,14 @@ public:
|
||||||
mCamera.position.y = y;
|
mCamera.position.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPosition(Unit x, Unit y, Unit z, Unit direction)
|
||||||
|
{
|
||||||
|
mCamera.position.x = x;
|
||||||
|
mCamera.position.y = y;
|
||||||
|
mCamera.height = z;
|
||||||
|
mCamera.direction = direction;
|
||||||
|
}
|
||||||
|
|
||||||
void setPositionSquare(int16_t squareX, int16_t squareY)
|
void setPositionSquare(int16_t squareX, int16_t squareY)
|
||||||
{
|
{
|
||||||
setPosition(
|
setPosition(
|
||||||
|
@ -295,7 +319,7 @@ public:
|
||||||
Unit prevHeight = mCamera.height;
|
Unit prevHeight = mCamera.height;
|
||||||
|
|
||||||
moveCameraWithCollision(&mCamera,moveOffset,mVericalSpeed,
|
moveCameraWithCollision(&mCamera,moveOffset,mVericalSpeed,
|
||||||
floorHeightFunction, ceilingHeightFunction, computeHeight ? 1 : 0);
|
floorHeightFunction, ceilingHeightFunction, computeHeight ? 1 : 0, 0);
|
||||||
|
|
||||||
Unit heightDiff = mCamera.height - prevHeight;
|
Unit heightDiff = mCamera.height - prevHeight;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue