Add sprite distance
This commit is contained in:
parent
4f1cb9aaaa
commit
0b0ade51b8
1 changed files with 4 additions and 0 deletions
4
game.cpp
4
game.cpp
|
@ -26,6 +26,7 @@
|
||||||
#define MIDDLE_COLUMN (SCREEN_WIDTH / 2)
|
#define MIDDLE_COLUMN (SCREEN_WIDTH / 2)
|
||||||
|
|
||||||
#define SPRITES 3
|
#define SPRITES 3
|
||||||
|
#define SPRITE_MAX_DISTANCE 5 * UNITS_PER_SQUARE
|
||||||
|
|
||||||
Pokitto::Core p;
|
Pokitto::Core p;
|
||||||
|
|
||||||
|
@ -699,6 +700,9 @@ void draw()
|
||||||
|
|
||||||
for (uint8_t i = 0; i < SPRITES; ++i)
|
for (uint8_t i = 0; i < SPRITES; ++i)
|
||||||
{
|
{
|
||||||
|
if (dist(sprites[i].mPosition,player.mCamera.position) > SPRITE_MAX_DISTANCE)
|
||||||
|
continue;
|
||||||
|
|
||||||
PixelInfo pos = mapToScreen(sprites[i].mPosition,sprites[i].mHeight,player.mCamera);
|
PixelInfo pos = mapToScreen(sprites[i].mPosition,sprites[i].mHeight,player.mCamera);
|
||||||
|
|
||||||
if (pos.depth > 0)
|
if (pos.depth > 0)
|
||||||
|
|
Loading…
Reference in a new issue