diff --git a/common.mk b/common.mk index 6b393f4..aad931e 100644 --- a/common.mk +++ b/common.mk @@ -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 diff --git a/src/structs.h b/src/structs.h index 502b3a5..b099842 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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; diff --git a/src/system/sprites.c b/src/system/sprites.c new file mode 100644 index 0000000..a763955 --- /dev/null +++ b/src/system/sprites.c @@ -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; +} diff --git a/src/system/sprites.h b/src/system/sprites.h new file mode 100644 index 0000000..8ad0dc9 --- /dev/null +++ b/src/system/sprites.h @@ -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" diff --git a/src/world/effects.c b/src/world/effects.c new file mode 100644 index 0000000..ea733cd --- /dev/null +++ b/src/world/effects.c @@ -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]; + } +} diff --git a/src/world/effects.h b/src/world/effects.h new file mode 100644 index 0000000..1f9cd8c --- /dev/null +++ b/src/world/effects.h @@ -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;