Added exit.

This commit is contained in:
Steve 2018-01-27 10:32:17 +00:00
parent 4a77cf6e4d
commit 23ed116a9e
5 changed files with 154 additions and 2 deletions

View File

@ -28,7 +28,7 @@ OBJS += atlas.o
OBJS += battery.o blaze.o bob.o boss.o blobBoss.o OBJS += battery.o blaze.o bob.o boss.o blobBoss.o
OBJS += camera.o cannon.o cardReader.o cell.o cherry.o combat.o consumable.o OBJS += camera.o cannon.o cardReader.o cell.o cherry.o combat.o consumable.o
OBJS += debris.o destructable.o door.o draw.o OBJS += debris.o destructable.o door.o draw.o
OBJS += effects.o entities.o explosions.o eyeDroidCommander.o OBJS += effects.o entities.o exit.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

View File

@ -200,7 +200,8 @@ enum
enum enum
{ {
WS_IN_PROGRESS WS_IN_PROGRESS,
WS_COMPLETE
}; };
enum enum

View File

@ -374,6 +374,8 @@ typedef struct {
int isBossMission; int isBossMission;
int isBossActive; int isBossActive;
int isOutpostMission; int isOutpostMission;
int isReturnVisit;
int missionCompleteTimer;
PointF checkpoints[MAX_CHECKPOINTS]; PointF checkpoints[MAX_CHECKPOINTS];
Quadtree quadtree; Quadtree quadtree;
Entity entityHead, *entityTail; Entity entityHead, *entityTail;

View File

@ -0,0 +1,120 @@
/*
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 "exit.h"
static void tick(void);
static void action(void);
static void touch(Entity *other);
static SDL_Rect getBounds(void);
void initExit(Entity *e)
{
e->sprite[FACING_LEFT] = e->sprite[FACING_RIGHT] = e->sprite[FACING_DIE] = getSpriteIndex("Exit");
e->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS;
e->isStatic = 1;
e->active = 0;
if (!e->active)
{
e->spriteFrame = 0;
}
else
{
e->spriteFrame = 1;
}
e->spriteTime = -1;
e->tick = tick;
e->action = action;
e->touch = touch;
e->getBounds = getBounds;
}
static void tick(void)
{
if (!self->active)
{
self->bobTouching = MAX(self->bobTouching - 1, 0);
}
}
static void action(void)
{
Objective *o;
if (!self->active)
{
self->active = 1;
for (o = world.objectiveHead.next ; o != NULL ; o = o->next)
{
if (o->required && strcmp(o->targetName, "EXIT") != 0 && o->currentValue < o->targetValue)
{
self->active = 0;
}
}
if (self->active)
{
self->spriteFrame = 1;
}
}
self->thinkTime = FPS;
}
static void touch(Entity *other)
{
if (other->type == ET_BOB && !world.isReturnVisit)
{
if (self->bobTouching == 0)
{
if (self->active)
{
updateObjective("EXIT");
world.missionCompleteTimer = (int) (FPS * 1.5);
world.bob->flags |= (EF_IMMUNE | EF_GONE);
world.state = WS_COMPLETE;
stopMusic();
}
else
{
setGameplayMessage(MSG_GAMEPLAY, "Can't exit yet - required objectives not met");
}
}
self->bobTouching = 2;
}
}
static SDL_Rect getBounds(void)
{
self->bounds.x = self->x + 64;
self->bounds.y = self->y;
self->bounds.w = 2;
self->bounds.h = self->h;
return self->bounds;
}

View File

@ -0,0 +1,29 @@
/*
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 int getSpriteIndex(char *name);
extern void updateObjective(char *targetName);
extern void setGameplayMessage(int type, char *format, ...);
extern void stopMusic(void);
extern Entity *self;
extern World world;