Scroll to observing entity.
This commit is contained in:
parent
7a79ef4b53
commit
f634a28127
|
@ -140,6 +140,7 @@ enum
|
|||
#define EF_KILL_OFFSCREEN (2 << 15)
|
||||
#define EF_ALWAYS_PROCESS (2 << 16)
|
||||
#define EF_NO_TELEPORT (2 << 17)
|
||||
#define EF_NO_OBSERVE (2 << 18)
|
||||
|
||||
#define GRAVITY_POWER 0.5f
|
||||
#define FRICTION 0.75f
|
||||
|
|
|
@ -134,7 +134,6 @@ struct Entity {
|
|||
int isOnGround;
|
||||
int isVisible;
|
||||
int isMissionTarget;
|
||||
int observationTime;
|
||||
Entity *riding;
|
||||
Entity *owner;
|
||||
unsigned long flags;
|
||||
|
|
|
@ -171,8 +171,6 @@ void doEntities(void)
|
|||
|
||||
self->tick();
|
||||
|
||||
self->observationTime = limit(self->observationTime - 1, 0, FPS * 5);
|
||||
|
||||
self->isOnGround = 0;
|
||||
|
||||
if (self->dy >= 0 && (!(self->flags & EF_WEIGHTLESS)))
|
||||
|
|
|
@ -376,7 +376,7 @@ static void doWorldInProgress(void)
|
|||
|
||||
if (world.observationTimer > 0)
|
||||
{
|
||||
if (--world.observationTimer == FPS * 1.5)
|
||||
if (--world.observationTimer == FPS)
|
||||
{
|
||||
world.entityToTrack = world.entitiesToObserve[0];
|
||||
|
||||
|
@ -435,30 +435,52 @@ static void handleWidgets(void)
|
|||
|
||||
static void doWorldObserving(void)
|
||||
{
|
||||
int i;
|
||||
int tx, ty;
|
||||
float diffX, diffY;
|
||||
|
||||
cameraTrack(world.entityToTrack);
|
||||
tx = world.entityToTrack->x - (SCREEN_WIDTH / 2);
|
||||
ty = world.entityToTrack->y - (SCREEN_HEIGHT / 2);
|
||||
|
||||
doEntitiesStatic();
|
||||
|
||||
if (--world.observationTimer == 0)
|
||||
diffX = abs(camera.x - tx) / 20;
|
||||
diffY = abs(camera.y - ty) / 20;
|
||||
|
||||
diffX = MAX(3, MIN(50, diffX));
|
||||
diffY = MAX(3, MIN(50, diffY));
|
||||
|
||||
if (camera.x > tx)
|
||||
{
|
||||
camera.x -= diffX;
|
||||
}
|
||||
|
||||
if (camera.x < tx)
|
||||
{
|
||||
camera.x += diffX;
|
||||
}
|
||||
|
||||
if (camera.y > ty)
|
||||
{
|
||||
camera.y -= diffY;
|
||||
}
|
||||
|
||||
if (camera.y < ty)
|
||||
{
|
||||
camera.y += diffY;
|
||||
}
|
||||
|
||||
if (collision(camera.x, camera.y, MAP_TILE_SIZE, MAP_TILE_SIZE, tx, ty, MAP_TILE_SIZE, MAP_TILE_SIZE))
|
||||
{
|
||||
if (--world.observationTimer <= 0)
|
||||
{
|
||||
if (++observationIndex < MAX_ENTS_TO_OBSERVE && world.entitiesToObserve[observationIndex] != NULL)
|
||||
{
|
||||
world.entityToTrack = world.entitiesToObserve[observationIndex];
|
||||
|
||||
world.observationTimer = FPS * 1.5;
|
||||
world.observationTimer = FPS;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0 ; i < MAX_ENTS_TO_OBSERVE ; i++)
|
||||
{
|
||||
if (world.entitiesToObserve[i] != NULL)
|
||||
{
|
||||
world.entitiesToObserve[i]->observationTime = FPS * 5;
|
||||
}
|
||||
}
|
||||
|
||||
memset(world.entitiesToObserve, 0, sizeof(Entity*) * MAX_ENTS_TO_OBSERVE);
|
||||
world.entityToTrack = (Entity*)world.bob;
|
||||
world.state = WS_IN_PROGRESS;
|
||||
|
@ -466,6 +488,7 @@ static void doWorldObserving(void)
|
|||
observationIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void doWorldPaused(void)
|
||||
|
@ -696,14 +719,16 @@ void observeActivation(Entity *e)
|
|||
{
|
||||
int i;
|
||||
|
||||
if (e->observationTime == 0 && !isOnScreen(e))
|
||||
if (!isOnScreen(e) && (!(e->flags & EF_NO_OBSERVE)))
|
||||
{
|
||||
e->flags |= EF_NO_OBSERVE;
|
||||
|
||||
for (i = 0 ; i < MAX_ENTS_TO_OBSERVE ; i++)
|
||||
{
|
||||
if (world.entitiesToObserve[i] == NULL)
|
||||
{
|
||||
world.entitiesToObserve[i] = e;
|
||||
world.observationTimer = FPS * 2;
|
||||
world.observationTimer = FPS * 1.5;
|
||||
return;
|
||||
}
|
||||
else if (getDistance(e->x, e->y, world.entitiesToObserve[i]->x, world.entitiesToObserve[i]->y) < SCREEN_HEIGHT - 50)
|
||||
|
|
|
@ -114,8 +114,10 @@ extern int rrnd(int low, int high);
|
|||
extern void showWidgetGroup(char *group);
|
||||
extern void startSectionTransition(void);
|
||||
extern void stopMusic(void);
|
||||
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
|
||||
|
||||
extern App app;
|
||||
extern Camera camera;
|
||||
extern Colors colors;
|
||||
extern Dev dev;
|
||||
extern Entity *self;
|
||||
|
|
Loading…
Reference in New Issue