Added destructable.
This commit is contained in:
parent
45244303f8
commit
e4f9c33c74
|
@ -16,6 +16,7 @@ SEARCHPATH += src/world/entities/boss
|
||||||
SEARCHPATH += src/world/entities/cannons
|
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
|
||||||
|
|
||||||
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 cell.o cherry.o combat.o consumable.o
|
||||||
OBJS += debris.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
|
||||||
OBJS += game.o
|
OBJS += game.o
|
||||||
|
|
|
@ -246,6 +246,7 @@ Bullet *createBaseBullet(Entity *owner)
|
||||||
bullet->damage = 1;
|
bullet->damage = 1;
|
||||||
bullet->owner = owner;
|
bullet->owner = owner;
|
||||||
bullet->health = FPS * 3;
|
bullet->health = FPS * 3;
|
||||||
|
bullet->flags |= EF_WEIGHTLESS | EF_IGNORE_BULLETS | EF_NO_ENVIRONMENT | EF_KILL_OFFSCREEN | EF_NO_TELEPORT;
|
||||||
|
|
||||||
return bullet;
|
return bullet;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ struct Entity {
|
||||||
unsigned long uniqueId;
|
unsigned long uniqueId;
|
||||||
char name[MAX_NAME_LENGTH];
|
char name[MAX_NAME_LENGTH];
|
||||||
char spriteName[MAX_NAME_LENGTH];
|
char spriteName[MAX_NAME_LENGTH];
|
||||||
|
char targetNames[MAX_DESCRIPTION_LENGTH];
|
||||||
int type;
|
int type;
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
|
@ -344,6 +345,7 @@ struct Bullet {
|
||||||
float dx;
|
float dx;
|
||||||
float dy;
|
float dy;
|
||||||
int sprite[2];
|
int sprite[2];
|
||||||
|
long flags;
|
||||||
Entity *owner;
|
Entity *owner;
|
||||||
Bullet *next;
|
Bullet *next;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
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 "destructable.h"
|
||||||
|
|
||||||
|
static void applyDamage(int amount);
|
||||||
|
static void action(void);
|
||||||
|
|
||||||
|
void initDestructable(Entity *e)
|
||||||
|
{
|
||||||
|
e->isMissionTarget = 1;
|
||||||
|
|
||||||
|
STRNCPY(e->spriteName, "Crate4", MAX_NAME_LENGTH);
|
||||||
|
|
||||||
|
e->flags |= EF_EXPLODES;
|
||||||
|
|
||||||
|
e->health = e->healthMax = 10;
|
||||||
|
|
||||||
|
e->sprite[FACING_LEFT] = e->sprite[FACING_RIGHT] = e->sprite[FACING_DIE] = getSpriteIndex(e->spriteName);
|
||||||
|
|
||||||
|
e->applyDamage = applyDamage;
|
||||||
|
e->action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void applyDamage(int amount)
|
||||||
|
{
|
||||||
|
if (self->health > 0)
|
||||||
|
{
|
||||||
|
self->health -= amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void action(void)
|
||||||
|
{
|
||||||
|
int mx, my;
|
||||||
|
|
||||||
|
if (self->health <= 0)
|
||||||
|
{
|
||||||
|
self->health--;
|
||||||
|
|
||||||
|
if (self->health % 3 == 0)
|
||||||
|
{
|
||||||
|
mx = (int) ((self->x + (self->w / 2)) / MAP_TILE_SIZE);
|
||||||
|
my = (int) ((self->y + self->h) / MAP_TILE_SIZE);
|
||||||
|
addScorchDecal(mx, my);
|
||||||
|
|
||||||
|
addExplosion(self->x, self->y, 50, self);
|
||||||
|
self->dx = rrnd(-10, 10);
|
||||||
|
self->dy = rrnd(-10, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self->health <= -50)
|
||||||
|
{
|
||||||
|
dropCarriedItem();
|
||||||
|
|
||||||
|
updateObjective(self->name);
|
||||||
|
|
||||||
|
if (strlen(self->targetNames) > 0)
|
||||||
|
{
|
||||||
|
activateEntities(self->targetNames, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
self->alive = ALIVE_DEAD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
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 Entity *self;
|
Loading…
Reference in New Issue