From 6ad2165a404ae0206996457bee681d439bf7ff76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Tue, 4 Sep 2018 11:42:05 +0200 Subject: [PATCH] Add sprite --- game.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/game.cpp b/game.cpp index e0b3f65..5a3d7b5 100644 --- a/game.cpp +++ b/game.cpp @@ -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()