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_KILL_OFFSCREEN (2 << 15)
|
||||||
#define EF_ALWAYS_PROCESS (2 << 16)
|
#define EF_ALWAYS_PROCESS (2 << 16)
|
||||||
#define EF_NO_TELEPORT (2 << 17)
|
#define EF_NO_TELEPORT (2 << 17)
|
||||||
|
#define EF_NO_OBSERVE (2 << 18)
|
||||||
|
|
||||||
#define GRAVITY_POWER 0.5f
|
#define GRAVITY_POWER 0.5f
|
||||||
#define FRICTION 0.75f
|
#define FRICTION 0.75f
|
||||||
|
|
|
@ -134,7 +134,6 @@ struct Entity {
|
||||||
int isOnGround;
|
int isOnGround;
|
||||||
int isVisible;
|
int isVisible;
|
||||||
int isMissionTarget;
|
int isMissionTarget;
|
||||||
int observationTime;
|
|
||||||
Entity *riding;
|
Entity *riding;
|
||||||
Entity *owner;
|
Entity *owner;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
|
@ -171,8 +171,6 @@ void doEntities(void)
|
||||||
|
|
||||||
self->tick();
|
self->tick();
|
||||||
|
|
||||||
self->observationTime = limit(self->observationTime - 1, 0, FPS * 5);
|
|
||||||
|
|
||||||
self->isOnGround = 0;
|
self->isOnGround = 0;
|
||||||
|
|
||||||
if (self->dy >= 0 && (!(self->flags & EF_WEIGHTLESS)))
|
if (self->dy >= 0 && (!(self->flags & EF_WEIGHTLESS)))
|
||||||
|
|
|
@ -376,7 +376,7 @@ static void doWorldInProgress(void)
|
||||||
|
|
||||||
if (world.observationTimer > 0)
|
if (world.observationTimer > 0)
|
||||||
{
|
{
|
||||||
if (--world.observationTimer == FPS * 1.5)
|
if (--world.observationTimer == FPS)
|
||||||
{
|
{
|
||||||
world.entityToTrack = world.entitiesToObserve[0];
|
world.entityToTrack = world.entitiesToObserve[0];
|
||||||
|
|
||||||
|
@ -435,30 +435,52 @@ static void handleWidgets(void)
|
||||||
|
|
||||||
static void doWorldObserving(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();
|
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)
|
if (++observationIndex < MAX_ENTS_TO_OBSERVE && world.entitiesToObserve[observationIndex] != NULL)
|
||||||
{
|
{
|
||||||
world.entityToTrack = world.entitiesToObserve[observationIndex];
|
world.entityToTrack = world.entitiesToObserve[observationIndex];
|
||||||
|
|
||||||
world.observationTimer = FPS * 1.5;
|
world.observationTimer = FPS;
|
||||||
}
|
}
|
||||||
else
|
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);
|
memset(world.entitiesToObserve, 0, sizeof(Entity*) * MAX_ENTS_TO_OBSERVE);
|
||||||
world.entityToTrack = (Entity*)world.bob;
|
world.entityToTrack = (Entity*)world.bob;
|
||||||
world.state = WS_IN_PROGRESS;
|
world.state = WS_IN_PROGRESS;
|
||||||
|
@ -466,6 +488,7 @@ static void doWorldObserving(void)
|
||||||
observationIndex = 0;
|
observationIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doWorldPaused(void)
|
static void doWorldPaused(void)
|
||||||
|
@ -696,14 +719,16 @@ void observeActivation(Entity *e)
|
||||||
{
|
{
|
||||||
int i;
|
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++)
|
for (i = 0 ; i < MAX_ENTS_TO_OBSERVE ; i++)
|
||||||
{
|
{
|
||||||
if (world.entitiesToObserve[i] == NULL)
|
if (world.entitiesToObserve[i] == NULL)
|
||||||
{
|
{
|
||||||
world.entitiesToObserve[i] = e;
|
world.entitiesToObserve[i] = e;
|
||||||
world.observationTimer = FPS * 2;
|
world.observationTimer = FPS * 1.5;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (getDistance(e->x, e->y, world.entitiesToObserve[i]->x, world.entitiesToObserve[i]->y) < SCREEN_HEIGHT - 50)
|
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 showWidgetGroup(char *group);
|
||||||
extern void startSectionTransition(void);
|
extern void startSectionTransition(void);
|
||||||
extern void stopMusic(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 App app;
|
||||||
|
extern Camera camera;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
extern Dev dev;
|
extern Dev dev;
|
||||||
extern Entity *self;
|
extern Entity *self;
|
||||||
|
|
Loading…
Reference in New Issue