Added Info Point.
This commit is contained in:
parent
e4f9c33c74
commit
5bcebe8b03
|
@ -31,7 +31,7 @@ OBJS += effects.o entities.o explosions.o eyeDroidCommander.o
|
||||||
OBJS += fleshChunk.o frost.o
|
OBJS += fleshChunk.o frost.o
|
||||||
OBJS += game.o
|
OBJS += game.o
|
||||||
OBJS += heart.o hub.o hud.o
|
OBJS += heart.o hub.o hud.o
|
||||||
OBJS += init.o input.o io.o item.o items.o
|
OBJS += init.o infoPoint.o input.o io.o item.o items.o
|
||||||
OBJS += key.o keycard.o
|
OBJS += key.o keycard.o
|
||||||
OBJS += lookup.o
|
OBJS += lookup.o
|
||||||
OBJS += main.o map.o maths.o mia.o
|
OBJS += main.o map.o maths.o mia.o
|
||||||
|
|
|
@ -139,6 +139,10 @@ struct Entity {
|
||||||
int canBeCarried;
|
int canBeCarried;
|
||||||
int canBePickedUp;
|
int canBePickedUp;
|
||||||
int provided;
|
int provided;
|
||||||
|
int firstTouch;
|
||||||
|
float sinVal;
|
||||||
|
int messageTimer;
|
||||||
|
char message[MAX_DESCRIPTION_LENGTH];
|
||||||
long flags;
|
long flags;
|
||||||
SDL_Rect bounds;
|
SDL_Rect bounds;
|
||||||
int sprite[3];
|
int sprite[3];
|
||||||
|
|
|
@ -25,6 +25,8 @@ static void action(void);
|
||||||
|
|
||||||
void initDestructable(Entity *e)
|
void initDestructable(Entity *e)
|
||||||
{
|
{
|
||||||
|
initEntity(e);
|
||||||
|
|
||||||
e->isMissionTarget = 1;
|
e->isMissionTarget = 1;
|
||||||
|
|
||||||
STRNCPY(e->spriteName, "Crate4", MAX_NAME_LENGTH);
|
STRNCPY(e->spriteName, "Crate4", MAX_NAME_LENGTH);
|
||||||
|
|
|
@ -27,5 +27,6 @@ extern void addExplosion(float x, float y, int radius, Entity *owner);
|
||||||
extern void addScorchDecal(int x, int y);
|
extern void addScorchDecal(int x, int y);
|
||||||
extern int getSpriteIndex(char *name);
|
extern int getSpriteIndex(char *name);
|
||||||
extern void updateObjective(char *targetName);
|
extern void updateObjective(char *targetName);
|
||||||
|
extern void initEntity(Entity *e);
|
||||||
|
|
||||||
extern Entity *self;
|
extern Entity *self;
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2018 Parallel Realities
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "infoPoint.h"
|
||||||
|
|
||||||
|
static void tick(void);
|
||||||
|
static void touch(Entity *other);
|
||||||
|
|
||||||
|
void initInfoPoint(Entity *e)
|
||||||
|
{
|
||||||
|
initEntity(e);
|
||||||
|
|
||||||
|
e->sprite[0] = e->sprite[1] = e->sprite[2] = getSpriteIndex("InfoPoint");
|
||||||
|
|
||||||
|
e->flags |= EF_WEIGHTLESS | EF_IGNORE_BULLETS | EF_NO_CLIP | EF_NO_ENVIRONMENT;
|
||||||
|
|
||||||
|
e->ty = e->y;
|
||||||
|
|
||||||
|
e->firstTouch = 1;
|
||||||
|
|
||||||
|
e->tick = tick;
|
||||||
|
e->touch = touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tick(void)
|
||||||
|
{
|
||||||
|
self->sinVal -= 0.05;
|
||||||
|
self->y += (float) sin(self->sinVal) * 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void touch(Entity *other)
|
||||||
|
{
|
||||||
|
int showMessage;
|
||||||
|
|
||||||
|
if (other == world.bob)
|
||||||
|
{
|
||||||
|
showMessage = 0;
|
||||||
|
|
||||||
|
if (self->firstTouch)
|
||||||
|
{
|
||||||
|
self->firstTouch = 0;
|
||||||
|
showMessage = 1;
|
||||||
|
self->messageTimer = FPS;
|
||||||
|
}
|
||||||
|
else if (world.bob->dx == 0 && world.bob->dy == 0 && world.bob->isOnGround)
|
||||||
|
{
|
||||||
|
self->messageTimer++;
|
||||||
|
|
||||||
|
if (self->messageTimer == FPS)
|
||||||
|
{
|
||||||
|
showMessage = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self->messageTimer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showMessage)
|
||||||
|
{
|
||||||
|
showInfoMessage(self->message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2018 Parallel Realities
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../../../common.h"
|
||||||
|
|
||||||
|
extern void activateEntities(char *names, int activate);
|
||||||
|
extern void dropCarriedItem(void);
|
||||||
|
extern int rrnd(int low, int high);
|
||||||
|
extern void addExplosion(float x, float y, int radius, Entity *owner);
|
||||||
|
extern void addScorchDecal(int x, int y);
|
||||||
|
extern int getSpriteIndex(char *name);
|
||||||
|
extern void updateObjective(char *targetName);
|
||||||
|
extern void initEntity(Entity *e);
|
||||||
|
extern void showInfoMessage(char *message);
|
||||||
|
|
||||||
|
extern Entity *self;
|
||||||
|
extern World world;
|
Loading…
Reference in New Issue