This commit is contained in:
Steve 2018-01-22 07:23:23 +00:00
parent f3bf387d98
commit 821fa54110
6 changed files with 151 additions and 3 deletions

View File

@ -8,10 +8,9 @@ vpath %.h $(SEARCHPATH)
DEPS += defs.h structs.h
OBJS += camera.o
OBJS += camera.o combat.o
OBJS += draw.o
OBJS += combat.o
OBJS += entities.o
OBJS += effects.o entities.o
OBJS += game.o
OBJS += hud.o
OBJS += init.o input.o io.o
@ -19,6 +18,7 @@ OBJS += lookup.o
OBJS += main.o map.o maths.o
OBJS += objectives.o
OBJS += quadtree.o
OBJS += sprites.o
OBJS += text.o textures.o title.o triggers.o
OBJS += util.o
OBJS += widgets.o

View File

@ -81,6 +81,7 @@ struct Entity {
float y;
int w;
int h;
int health;
int alive;
float dx;
float dy;
@ -91,6 +92,7 @@ struct Entity {
int isSolid;
long flags;
SDL_Rect bounds;
int sprite[3];
void (*walk)(void);
void (*attack)(void);
Entity *next;

26
src/system/sprites.c Normal file
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 "sprites.h"
int getSpriteIndex(char *name)
{
return 0;
}

21
src/system/sprites.h Normal file
View File

@ -0,0 +1,21 @@
/*
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"

73
src/world/effects.c Normal file
View File

@ -0,0 +1,73 @@
/*
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 "effects.h"
static int fleshChunk[3];
static int debris[3];
void initEffects(void)
{
fleshChunk[0] = getSpriteIndex("FleshChunk1");
fleshChunk[1] = getSpriteIndex("FleshChunk2");
fleshChunk[2] = getSpriteIndex("FleshChunk3");
debris[0] = getSpriteIndex("Debris1");
debris[1] = getSpriteIndex("Debris2");
debris[2] = getSpriteIndex("Debris3");
}
void addSmallFleshChunk(double x, double y)
{
Entity *chunk;
chunk = malloc(sizeof(Entity));
memset(chunk, 0, sizeof(Entity));
world.entityTail->next = chunk;
world.entityTail = chunk;
chunk->x = x;
chunk->y = y;
chunk->dx = 0;
chunk->dy = 0;
chunk->health = FPS / 4;
chunk->sprite[0] = chunk->sprite[1] = chunk->sprite[2] = fleshChunk[0];
}
void throwFleshChunks(double x, double y, int amount)
{
int i;
Entity *chunk;
for (i = 0; i < amount; i++)
{
chunk = malloc(sizeof(Entity));
memset(chunk, 0, sizeof(Entity));
world.entityTail->next = chunk;
world.entityTail = chunk;
chunk->x = x;
chunk->y = y;
chunk->dx = rrnd(-2, 2);
chunk->dy = -rrnd(10, 15);
chunk->health = FPS * rrnd(3, 12);
chunk->sprite[0] = chunk->sprite[1] = chunk->sprite[2] = fleshChunk[i % 3];
}
}

26
src/world/effects.h Normal file
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 rrnd(int low, int high);
extern int getSpriteIndex(char *name);
extern World world;