Item pad.
This commit is contained in:
parent
8e923164ca
commit
ff60ddf6de
|
@ -32,7 +32,7 @@ OBJS += effects.o entities.o exit.o explosions.o eyeDroidCommander.o
|
|||
OBJS += fleshChunk.o frost.o
|
||||
OBJS += game.o
|
||||
OBJS += heart.o horizontalDoor.o hub.o hud.o
|
||||
OBJS += init.o infoPoint.o input.o io.o item.o items.o
|
||||
OBJS += init.o infoPoint.o input.o io.o item.o items.o itemPad.o
|
||||
OBJS += key.o keycard.o
|
||||
OBJS += lookup.o
|
||||
OBJS += main.o map.o maths.o mia.o
|
||||
|
|
|
@ -76,7 +76,12 @@ int hasItem(char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void removeKey(char *name)
|
||||
Entity *getItem(char *name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void removeItem(char *name)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -147,6 +147,7 @@ struct Entity {
|
|||
char message[MAX_DESCRIPTION_LENGTH];
|
||||
char requiredCard[MAX_NAME_LENGTH];
|
||||
char requiredKey[MAX_NAME_LENGTH];
|
||||
char requiredItem[MAX_NAME_LENGTH];
|
||||
long flags;
|
||||
SDL_Rect bounds;
|
||||
int sprite[3];
|
||||
|
|
|
@ -64,7 +64,7 @@ static void touch(Entity *other)
|
|||
|
||||
setGameplayMessage(MSG_GAMEPLAY, "%s removed", self->requiredCard);
|
||||
|
||||
removeKey(self->requiredCard);
|
||||
removeItem(self->requiredCard);
|
||||
|
||||
self->active = 1;
|
||||
self->sprite[FACING_LEFT] = self->sprite[FACING_RIGHT] = self->sprite[FACING_DIE] = getSpriteIndex("CardReader");
|
||||
|
|
|
@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
extern void initEntity(Entity *e);
|
||||
extern int getSpriteIndex(char *name);
|
||||
extern void removeKey(char *name);
|
||||
extern void removeItem(char *name);
|
||||
extern int hasItem(char *name);
|
||||
extern void setGameplayMessage(int type, char *format, ...);
|
||||
extern void activateEntities(char *names, int activate);
|
||||
|
|
|
@ -187,7 +187,7 @@ static void openWithKey(void)
|
|||
return;
|
||||
}
|
||||
|
||||
removeKey(self->requiredKey);
|
||||
removeItem(self->requiredKey);
|
||||
|
||||
setGameplayMessage(MSG_GAMEPLAY, "%s removed", self->requiredKey);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ extern void playSound(int snd, int ch);
|
|||
extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);
|
||||
extern void setGameplayMessage(int type, char *format, ...);
|
||||
extern int hasItem(char *name);
|
||||
extern void removeKey(char *name);
|
||||
extern void removeItem(char *name);
|
||||
|
||||
extern Entity *self;
|
||||
extern Dev dev;
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
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 "itemPad.h"
|
||||
|
||||
static void tick(void);
|
||||
static void touch(Entity *other);
|
||||
|
||||
void initItemPad(Entity *e)
|
||||
{
|
||||
initEntity(e);
|
||||
|
||||
e->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS;
|
||||
|
||||
e->plane = PLANE_FOREGROUND;
|
||||
|
||||
e->isStatic = 1;
|
||||
|
||||
if (!e->active)
|
||||
{
|
||||
e->sprite[FACING_LEFT] = e->sprite[FACING_RIGHT] = e->sprite[FACING_DIE] = getSpriteIndex("ItemPadActive");
|
||||
}
|
||||
else
|
||||
{
|
||||
e->sprite[FACING_LEFT] = e->sprite[FACING_RIGHT] = e->sprite[FACING_DIE] = getSpriteIndex("ItemPadInactive");
|
||||
}
|
||||
|
||||
e->tick = tick;
|
||||
e->touch = touch;
|
||||
}
|
||||
|
||||
static void tick(void)
|
||||
{
|
||||
self->bobTouching = MAX(self->bobTouching - 1, 0);
|
||||
}
|
||||
|
||||
static void touch(Entity *other)
|
||||
{
|
||||
Entity *i;
|
||||
|
||||
if (other->type == ET_BOB && !self->active)
|
||||
{
|
||||
i = getItem(self->requiredItem);
|
||||
|
||||
if (i != NULL)
|
||||
{
|
||||
removeItem(i->name);
|
||||
|
||||
i->flags &= ~EF_GONE;
|
||||
|
||||
i->x = self->x + (self->w / 2) - (i->w / 2);
|
||||
i->y = self->y - i->h;
|
||||
|
||||
i->canBeCarried = i->canBePickedUp = i->isMissionTarget = 0;
|
||||
|
||||
self->active = 1;
|
||||
|
||||
setGameplayMessage(MSG_GAMEPLAY, "%s removed", self->requiredItem);
|
||||
|
||||
self->sprite[FACING_LEFT] = self->sprite[FACING_RIGHT] = self->sprite[FACING_DIE] = getSpriteIndex("ItemPadActive");
|
||||
|
||||
self->spriteFrame = 0;
|
||||
|
||||
updateObjective(self->name);
|
||||
}
|
||||
else if (!self->bobTouching)
|
||||
{
|
||||
setGameplayMessage(MSG_GAMEPLAY, "%s required", self->requiredItem);
|
||||
}
|
||||
|
||||
self->bobTouching = 2;
|
||||
}
|
||||
}
|
|
@ -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 updateObjective(char *targetName);
|
||||
extern void setGameplayMessage(int type, char *format, ...);
|
||||
extern void removeItem(char *name);
|
||||
extern Entity *getItem(char *name);
|
||||
|
||||
extern Entity *self;
|
Loading…
Reference in New Issue