Start of mines.
This commit is contained in:
parent
510bd3da00
commit
3646a9326a
|
@ -19,7 +19,7 @@ OBJS += hud.o
|
|||
OBJS += i18n.o init.o input.o io.o items.o
|
||||
OBJS += jumpgate.o
|
||||
OBJS += load.o locations.o lookup.o
|
||||
OBJS += main.o messageBox.o mission.o missionInfo.o modalDialog.o
|
||||
OBJS += main.o messageBox.o mine.o mission.o missionInfo.o modalDialog.o
|
||||
OBJS += objectives.o options.o
|
||||
OBJS += player.o
|
||||
OBJS += quadtree.o
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 381 B |
|
@ -284,6 +284,36 @@ void addSmallExplosion(void)
|
|||
}
|
||||
}
|
||||
|
||||
void addMineExplosion(void)
|
||||
{
|
||||
int i;
|
||||
Effect *e;
|
||||
|
||||
for (i = 0 ; i < 16 ; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
battle.effectTail->next = e;
|
||||
battle.effectTail = e;
|
||||
|
||||
e->type = EFFECT_TEXTURE;
|
||||
|
||||
e->x = self->x + rand() % 16 - rand() % 16;
|
||||
e->y = self->y + rand() % 16 - rand() % 16;
|
||||
e->texture = explosionTexture;
|
||||
e->size = 32 + (rand() % 32);
|
||||
e->r = 255;
|
||||
|
||||
setRandomFlameHue(e);
|
||||
|
||||
e->a = 32 + (rand() % 192);
|
||||
e->health = e->a;
|
||||
|
||||
e->x -= e->size / 2;
|
||||
e->y -= e->size / 2;
|
||||
}
|
||||
}
|
||||
|
||||
void addLargeExplosion(void)
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
Copyright (C) 2015-2016 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 "mine.h"
|
||||
|
||||
static void think(void);
|
||||
static void lookForFighters(void);
|
||||
|
||||
Entity *spawnMine(void)
|
||||
{
|
||||
Entity *mine = spawnEntity();
|
||||
|
||||
mine->type = ET_MINE;
|
||||
mine->health = mine->maxHealth = 1;
|
||||
mine->texture = getTexture("gfx/entities/mine.png");
|
||||
mine->action = think;
|
||||
|
||||
return mine;
|
||||
}
|
||||
|
||||
static void think(void)
|
||||
{
|
||||
self->angle += 0.1;
|
||||
|
||||
if (self->angle >= 360)
|
||||
{
|
||||
self->angle -= 360;
|
||||
}
|
||||
|
||||
lookForFighters();
|
||||
}
|
||||
|
||||
static void lookForFighters(void)
|
||||
{
|
||||
Entity *e, **candidates;
|
||||
int i;
|
||||
|
||||
candidates = getAllEntsWithin(self->x - (self->w / 2), self->y - (self->h / 2), self->w, self->h, self);
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
{
|
||||
if (e->health > 0 && e->type == ET_FIGHTER && getDistance(self->x, self->y, e->x, e->y) <= 128)
|
||||
{
|
||||
self->health = 0;
|
||||
|
||||
addMineExplosion();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
Copyright (C) 2015-2016 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 Entity *spawnEntity(void);
|
||||
extern SDL_Texture *getTexture(char *filename);
|
||||
extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
|
||||
extern int getDistance(int x1, int y1, int x2, int y2);
|
||||
extern void addMineExplosion(void);
|
||||
|
||||
extern Entity *self;
|
|
@ -151,6 +151,7 @@ enum
|
|||
ET_ITEM,
|
||||
ET_WAYPOINT,
|
||||
ET_JUMPGATE,
|
||||
ET_MINE,
|
||||
ET_CAPITAL_SHIP_GUN,
|
||||
ET_CAPITAL_SHIP_COMPONENT,
|
||||
ET_CAPITAL_SHIP_ENGINE,
|
||||
|
|
|
@ -352,6 +352,10 @@ static void loadEntities(cJSON *node)
|
|||
e = spawnJumpgate();
|
||||
break;
|
||||
|
||||
case ET_MINE:
|
||||
e = spawnMine();
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Error: Unhandled entity type: %s\n", cJSON_GetObjectItem(node, "type")->valuestring);
|
||||
exit(1);
|
||||
|
|
|
@ -57,6 +57,7 @@ extern void loadFighters(cJSON *node);
|
|||
extern void loadItems(cJSON *node);
|
||||
extern void loadLocations(cJSON *node);
|
||||
extern void loadSpawners(cJSON *node);
|
||||
extern Entity *spawnMine(void);
|
||||
|
||||
extern Battle battle;
|
||||
extern Dev dev;
|
||||
|
|
|
@ -45,6 +45,7 @@ void initLookups(void)
|
|||
addLookup("ET_WAYPOINT", ET_WAYPOINT);
|
||||
addLookup("ET_JUMPGATE", ET_JUMPGATE);
|
||||
addLookup("ET_CAPITAL_SHIP", ET_CAPITAL_SHIP);
|
||||
addLookup("ET_MINE", ET_MINE);
|
||||
|
||||
addLookup("EF_NO_KILL", EF_NO_KILL);
|
||||
addLookup("EF_DISABLED", EF_DISABLED);
|
||||
|
|
Loading…
Reference in New Issue