Add sprite

This commit is contained in:
Miloslav Číž 2018-09-04 11:42:05 +02:00
parent b398ecf241
commit 6ad2165a40

View file

@ -343,6 +343,9 @@ void drawSprite(const unsigned char *sprite, int16_t x, int16_t y, int16_t size)
{
// TODO: optimize
x -= size / 2;
y -= size / 2;
Unit step = UNITS_PER_SQUARE / size;
uint8_t c;
@ -418,9 +421,9 @@ public:
Character()
{
mCamera.position.x = UNITS_PER_SQUARE * 4;
mCamera.position.x = UNITS_PER_SQUARE * 1;
mCamera.position.y = UNITS_PER_SQUARE * 5;
mCamera.direction = 0;
mCamera.direction = 200;
mCamera.fovAngle = UNITS_PER_SQUARE / 4;
mCamera.height = UNITS_PER_SQUARE / 2;
mCamera.resolution.x = 110 / SUBSAMPLE;
@ -486,7 +489,13 @@ void draw()
render(player.mCamera,heightFunc,pixelFunc,c);
drawSprite(sprite,20,20,40);
Vector2D v;
v.x = 5 * UNITS_PER_SQUARE;
v.y = 7 * UNITS_PER_SQUARE;
PixelInfo pos = mapToScreen(v,UNITS_PER_SQUARE / 4,player.mCamera);
if (pos.depth > 0)
drawSprite(sprite,pos.position.x,pos.position.y,perspectiveScale(32,pos.depth));
}
int main()