Don't use the camera position for entity observation, as it might never finish, due to clipping.
This commit is contained in:
parent
f3cf1ec945
commit
95a4131a99
|
@ -57,6 +57,7 @@ static Texture *atlasTexture;
|
||||||
static Atlas *missionFailed;
|
static Atlas *missionFailed;
|
||||||
static int observationIndex;
|
static int observationIndex;
|
||||||
static int showing;
|
static int showing;
|
||||||
|
static PointF observePos;
|
||||||
|
|
||||||
void initWorld(void)
|
void initWorld(void)
|
||||||
{
|
{
|
||||||
|
@ -379,6 +380,8 @@ static void doWorldInProgress(void)
|
||||||
if (--world.observationTimer == FPS)
|
if (--world.observationTimer == FPS)
|
||||||
{
|
{
|
||||||
world.entityToTrack = world.entitiesToObserve[0];
|
world.entityToTrack = world.entitiesToObserve[0];
|
||||||
|
observePos.x = camera.x;
|
||||||
|
observePos.y = camera.y;
|
||||||
world.state = WS_OBSERVING;
|
world.state = WS_OBSERVING;
|
||||||
pauseSound(1);
|
pauseSound(1);
|
||||||
}
|
}
|
||||||
|
@ -435,7 +438,7 @@ static void handleWidgets(void)
|
||||||
|
|
||||||
static void doWorldObserving(void)
|
static void doWorldObserving(void)
|
||||||
{
|
{
|
||||||
int tx, ty, cx, cy;
|
int tx, ty;
|
||||||
float diffX, diffY;
|
float diffX, diffY;
|
||||||
|
|
||||||
tx = world.entityToTrack->x - (SCREEN_WIDTH / 2);
|
tx = world.entityToTrack->x - (SCREEN_WIDTH / 2);
|
||||||
|
@ -449,43 +452,41 @@ static void doWorldObserving(void)
|
||||||
diffX = MAX(3, MIN(50, diffX));
|
diffX = MAX(3, MIN(50, diffX));
|
||||||
diffY = MAX(3, MIN(50, diffY));
|
diffY = MAX(3, MIN(50, diffY));
|
||||||
|
|
||||||
cx = camera.x;
|
if (observePos.x > tx)
|
||||||
cy = camera.y;
|
|
||||||
|
|
||||||
if (cx > tx)
|
|
||||||
{
|
{
|
||||||
cx -= diffX;
|
observePos.x -= diffX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cx < tx)
|
if (observePos.x < tx)
|
||||||
{
|
{
|
||||||
cx += diffX;
|
observePos.x += diffX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cy > ty)
|
if (observePos.y > ty)
|
||||||
{
|
{
|
||||||
cy -= diffY;
|
observePos.y -= diffY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cy < ty)
|
if (observePos.y < ty)
|
||||||
{
|
{
|
||||||
cy += diffY;
|
observePos.y += diffY;
|
||||||
}
|
}
|
||||||
|
|
||||||
camera.x = cx;
|
camera.x = observePos.x;
|
||||||
camera.y = cy;
|
camera.y = observePos.y;
|
||||||
|
|
||||||
clipCamera();
|
clipCamera();
|
||||||
|
|
||||||
if (collision(cx, cy, MAP_TILE_SIZE, MAP_TILE_SIZE, tx, ty, MAP_TILE_SIZE, MAP_TILE_SIZE))
|
if (collision(observePos.x, observePos.y, MAP_TILE_SIZE, MAP_TILE_SIZE, tx, ty, MAP_TILE_SIZE, MAP_TILE_SIZE))
|
||||||
{
|
{
|
||||||
if (--world.observationTimer <= 0)
|
if (--world.observationTimer <= 0)
|
||||||
{
|
{
|
||||||
if (++observationIndex < MAX_ENTS_TO_OBSERVE && world.entitiesToObserve[observationIndex] != NULL)
|
if (++observationIndex < MAX_ENTS_TO_OBSERVE && world.entitiesToObserve[observationIndex] != NULL)
|
||||||
{
|
{
|
||||||
world.entityToTrack = world.entitiesToObserve[observationIndex];
|
world.entityToTrack = world.entitiesToObserve[observationIndex];
|
||||||
|
|
||||||
world.observationTimer = FPS;
|
world.observationTimer = FPS;
|
||||||
|
observePos.x = camera.x;
|
||||||
|
observePos.y = camera.y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue