Add sprite
This commit is contained in:
parent
b398ecf241
commit
6ad2165a40
1 changed files with 12 additions and 3 deletions
15
game.cpp
15
game.cpp
|
@ -343,6 +343,9 @@ void drawSprite(const unsigned char *sprite, int16_t x, int16_t y, int16_t size)
|
||||||
{
|
{
|
||||||
// TODO: optimize
|
// TODO: optimize
|
||||||
|
|
||||||
|
x -= size / 2;
|
||||||
|
y -= size / 2;
|
||||||
|
|
||||||
Unit step = UNITS_PER_SQUARE / size;
|
Unit step = UNITS_PER_SQUARE / size;
|
||||||
|
|
||||||
uint8_t c;
|
uint8_t c;
|
||||||
|
@ -418,9 +421,9 @@ public:
|
||||||
|
|
||||||
Character()
|
Character()
|
||||||
{
|
{
|
||||||
mCamera.position.x = UNITS_PER_SQUARE * 4;
|
mCamera.position.x = UNITS_PER_SQUARE * 1;
|
||||||
mCamera.position.y = UNITS_PER_SQUARE * 5;
|
mCamera.position.y = UNITS_PER_SQUARE * 5;
|
||||||
mCamera.direction = 0;
|
mCamera.direction = 200;
|
||||||
mCamera.fovAngle = UNITS_PER_SQUARE / 4;
|
mCamera.fovAngle = UNITS_PER_SQUARE / 4;
|
||||||
mCamera.height = UNITS_PER_SQUARE / 2;
|
mCamera.height = UNITS_PER_SQUARE / 2;
|
||||||
mCamera.resolution.x = 110 / SUBSAMPLE;
|
mCamera.resolution.x = 110 / SUBSAMPLE;
|
||||||
|
@ -486,7 +489,13 @@ void draw()
|
||||||
|
|
||||||
render(player.mCamera,heightFunc,pixelFunc,c);
|
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()
|
int main()
|
||||||
|
|
Loading…
Reference in a new issue