Card Reader.
This commit is contained in:
parent
5bcebe8b03
commit
0118582a1c
|
@ -17,6 +17,7 @@ SEARCHPATH += src/world/entities/cannons
|
||||||
SEARCHPATH += src/world/entities/decoration
|
SEARCHPATH += src/world/entities/decoration
|
||||||
SEARCHPATH += src/world/entities/items
|
SEARCHPATH += src/world/entities/items
|
||||||
SEARCHPATH += src/world/entities/misc
|
SEARCHPATH += src/world/entities/misc
|
||||||
|
SEARCHPATH += src/world/entities/structures
|
||||||
|
|
||||||
vpath %.c $(SEARCHPATH)
|
vpath %.c $(SEARCHPATH)
|
||||||
vpath %.h $(SEARCHPATH)
|
vpath %.h $(SEARCHPATH)
|
||||||
|
@ -25,7 +26,7 @@ DEPS += defs.h structs.h
|
||||||
|
|
||||||
OBJS += atlas.o
|
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 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 draw.o
|
OBJS += debris.o destructable.o draw.o
|
||||||
OBJS += effects.o entities.o explosions.o eyeDroidCommander.o
|
OBJS += effects.o entities.o explosions.o eyeDroidCommander.o
|
||||||
OBJS += fleshChunk.o frost.o
|
OBJS += fleshChunk.o frost.o
|
||||||
|
|
|
@ -279,6 +279,7 @@ enum
|
||||||
CH_WEAPON,
|
CH_WEAPON,
|
||||||
CH_DEATH,
|
CH_DEATH,
|
||||||
CH_ITEM,
|
CH_ITEM,
|
||||||
|
CH_TOUCH,
|
||||||
CH_MAX
|
CH_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,15 @@ void addKey(char *name)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int hasItem(char *name)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeKey(char *name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void destroyGame(void)
|
void destroyGame(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,9 +140,12 @@ struct Entity {
|
||||||
int canBePickedUp;
|
int canBePickedUp;
|
||||||
int provided;
|
int provided;
|
||||||
int firstTouch;
|
int firstTouch;
|
||||||
|
int active;
|
||||||
float sinVal;
|
float sinVal;
|
||||||
|
int bobTouching;
|
||||||
int messageTimer;
|
int messageTimer;
|
||||||
char message[MAX_DESCRIPTION_LENGTH];
|
char message[MAX_DESCRIPTION_LENGTH];
|
||||||
|
char requiredCard[MAX_NAME_LENGTH];
|
||||||
long flags;
|
long flags;
|
||||||
SDL_Rect bounds;
|
SDL_Rect bounds;
|
||||||
int sprite[3];
|
int sprite[3];
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
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 "cardReader.h"
|
||||||
|
|
||||||
|
static void tick(void);
|
||||||
|
static void touch(Entity *other);
|
||||||
|
|
||||||
|
void initCardReader(Entity *e)
|
||||||
|
{
|
||||||
|
initEntity(e);
|
||||||
|
|
||||||
|
e->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS | EF_NO_TELEPORT;
|
||||||
|
|
||||||
|
STRNCPY(e->requiredCard, "Black Keycard", MAX_NAME_LENGTH);
|
||||||
|
|
||||||
|
e->isStatic = 1;
|
||||||
|
|
||||||
|
if (!e->active)
|
||||||
|
{
|
||||||
|
e->sprite[FACING_LEFT] = e->sprite[FACING_RIGHT] = e->sprite[FACING_DIE] = getSpriteIndex("CardReaderIdle");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e->sprite[FACING_LEFT] = e->sprite[FACING_RIGHT] = e->sprite[FACING_DIE] = getSpriteIndex("CardReader");
|
||||||
|
}
|
||||||
|
|
||||||
|
e->tick = tick;
|
||||||
|
e->touch = touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tick(void)
|
||||||
|
{
|
||||||
|
if (!self->active)
|
||||||
|
{
|
||||||
|
self->bobTouching = MAX(self->bobTouching - 1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void touch(Entity *other)
|
||||||
|
{
|
||||||
|
if (!self->active && other->type == ET_BOB)
|
||||||
|
{
|
||||||
|
if (hasItem(self->requiredCard) || dev.cheatKeys)
|
||||||
|
{
|
||||||
|
activateEntities(self->targetNames, 1);
|
||||||
|
|
||||||
|
setGameplayMessage(MSG_GAMEPLAY, "%s removed", self->requiredCard);
|
||||||
|
|
||||||
|
removeKey(self->requiredCard);
|
||||||
|
|
||||||
|
self->active = 1;
|
||||||
|
self->sprite[FACING_LEFT] = self->sprite[FACING_RIGHT] = self->sprite[FACING_DIE] = getSpriteIndex("CardReader");
|
||||||
|
self->spriteTime = 0;
|
||||||
|
self->spriteFrame = 0;
|
||||||
|
|
||||||
|
playSound(SND_CONFIRMED, CH_TOUCH);
|
||||||
|
}
|
||||||
|
else if (self->bobTouching == 0)
|
||||||
|
{
|
||||||
|
setGameplayMessage(MSG_GAMEPLAY, "%s required", self->requiredCard);
|
||||||
|
playSound(SND_DENIED, CH_TOUCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
self->bobTouching = 2;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
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 removeKey(char *name);
|
||||||
|
extern int hasItem(char *name);
|
||||||
|
extern void setGameplayMessage(int type, char *format, ...);
|
||||||
|
extern void activateEntities(char *names, int activate);
|
||||||
|
extern void playSound(int snd, int ch);
|
||||||
|
|
||||||
|
extern Dev dev;
|
||||||
|
extern Entity *self;
|
Loading…
Reference in New Issue