Power point and power pool.

This commit is contained in:
Steve 2018-01-27 11:15:23 +00:00
parent 1337fb2602
commit 0bc6599a95
6 changed files with 237 additions and 1 deletions

View File

@ -37,7 +37,7 @@ OBJS += key.o keycard.o
OBJS += lift.o lookup.o
OBJS += main.o map.o maths.o mia.o
OBJS += objectives.o
OBJS += particles.o player.o
OBJS += particles.o player.o powerPoint.o powerPool.o
OBJS += quadtree.o
OBJS += sound.o sprites.o
OBJS += tankCommander.o tankTrack.o teeka.o text.o textures.o title.o triggers.o

View File

@ -148,6 +148,7 @@ struct Entity {
char requiredCard[MAX_NAME_LENGTH];
char requiredKey[MAX_NAME_LENGTH];
char requiredItem[MAX_NAME_LENGTH];
int requiredPower;
long flags;
SDL_Rect bounds;
int sprite[3];

View File

@ -0,0 +1,97 @@
/*
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 "powerPoint.h"
static void tick(void);
static void action(void);
static void touch(Entity *other);
void initPowerPoint(Entity *e)
{
initEntity(e);
e->sprite[FACING_LEFT] = e->sprite[FACING_RIGHT] = e->sprite[FACING_DIE] = getSpriteIndex("PowerPoint");
e->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS;
e->requiredPower = 100;
e->isStatic = 1;
e->tick = tick;
e->action = action;
e->touch = touch;
}
static void tick(void)
{
if (!self->active)
{
self->bobTouching = MAX(self->bobTouching - 1, 0);
if (self->bobTouching == 0)
{
self->spriteFrame = 0;
self->spriteTime = -1;
self->thinkTime = FPS / 2;
}
}
}
static void action(void)
{
self->spriteFrame = MIN(self->spriteFrame + 1, 3);
if (!self->active && self->spriteFrame == 3)
{
activateEntities(self->targetNames, 1);
setGameplayMessage(MSG_GAMEPLAY, self->message);
if (!dev.cheatPower)
{
world.bob->power -= self->requiredPower;
}
self->requiredPower = 0;
self->active = 1;
}
else
{
self->thinkTime = FPS / 2;
}
}
static void touch(Entity *other)
{
if (!self->active && other->type == ET_BOB && other->dx == 0)
{
if (world.bob->power < self->requiredPower && self->bobTouching == 0 && !dev.cheatPower)
{
setGameplayMessage(MSG_GAMEPLAY, "Not enough power (%d units required)", self->requiredPower);
}
else
{
self->bobTouching = 2;
}
}
}

View File

@ -0,0 +1,30 @@
/*
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 initEntity(Entity *e);
extern int getSpriteIndex(char *name);
extern void activateEntities(char *names, int activate);
extern void setGameplayMessage(int type, char *format, ...);
extern Dev dev;
extern Entity *self;
extern World world;

View File

@ -0,0 +1,82 @@
/*
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 "powerPool.h"
static void tick(void);
static void action(void);
static void touch(Entity *other);
void initPowerPool(Entity *e)
{
e->sprite[FACING_LEFT] = e->sprite[FACING_RIGHT] = e->sprite[FACING_DIE] = getSpriteIndex("PowerPool");
e->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_IGNORE_BULLETS;
e->plane = PLANE_FOREGROUND;
e->isStatic = 1;
e->tick = tick;
e->action = action;
e->touch = touch;
}
static void tick(void)
{
if (self->active)
{
self->spriteTime--;
if (self->spriteTime <= 0)
{
self->spriteFrame = (int) (1 + (rand() % 6));
self->spriteTime = 12;
}
}
}
static void action(void)
{
self->active = 1;
if (self->spriteFrame == 0)
{
self->spriteFrame = (int) (1 + (rand() % 6));
self->spriteTime = 12;
}
self->thinkTime = FPS * 99999;
}
static void touch(Entity *other)
{
if (self->active && other->type == ET_BOB && world.bob->power < world.bob->powerMax)
{
world.bob->power = MIN(world.bob->power + 0.05, world.bob->powerMax);
if (world.bob->power == world.bob->powerMax)
{
self->thinkTime = FPS * 10;
self->spriteTime = -1;
self->spriteFrame = 0;
self->active = 0;
}
}
}

View File

@ -0,0 +1,26 @@
/*
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 Entity *self;
extern World world;