diff --git a/common.mk b/common.mk index e10ceab..3663f97 100644 --- a/common.mk +++ b/common.mk @@ -22,7 +22,7 @@ DEPS += defs.h structs.h OBJS += atlas.o OBJS += battery.o blaze.o bob.o boss.o blobBoss.o -OBJS += camera.o combat.o consumable.o +OBJS += camera.o cell.o cherry.o combat.o consumable.o OBJS += draw.o OBJS += effects.o entities.o explosions.o eyeDroidCommander.o OBJS += frost.o diff --git a/src/combat/explosions.h b/src/combat/explosions.h index 10217be..54e0419 100644 --- a/src/combat/explosions.h +++ b/src/combat/explosions.h @@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern int rrnd(int low, int high); extern void stunPlayer(void); -extern void applyEntityDamage(Entity *e, int amount); extern void addExplosionEffect(int x, int y, int dx, int dy); extern void playSound(int snd, int ch); extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore); diff --git a/src/hub/hub.h b/src/hub/hub.h index 156c06a..fbd7970 100644 --- a/src/hub/hub.h +++ b/src/hub/hub.h @@ -24,4 +24,3 @@ extern int getDistance(int x1, int y1, int x2, int y2); extern Dev dev; extern Game game; -extern World world; diff --git a/src/world/entities/blobs/mia.h b/src/world/entities/blobs/mia.h index 468cdf1..78822d7 100644 --- a/src/world/entities/blobs/mia.h +++ b/src/world/entities/blobs/mia.h @@ -30,5 +30,4 @@ extern void updateObjective(char *targetName); extern void addRescuedMIA(char *name); extern Entity *self; -extern Game game; extern World world; diff --git a/src/world/entities/blobs/teeka.h b/src/world/entities/blobs/teeka.h index 941b500..6977187 100644 --- a/src/world/entities/blobs/teeka.h +++ b/src/world/entities/blobs/teeka.h @@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../../../common.h" -extern void lookForEnemy(void); extern void unitTick(void); extern int getSpriteIndex(char *name); extern int rrnd(int low, int high); diff --git a/src/world/entities/boss/tankCommander.h b/src/world/entities/boss/tankCommander.h index f62a66a..81fde53 100644 --- a/src/world/entities/boss/tankCommander.h +++ b/src/world/entities/boss/tankCommander.h @@ -25,13 +25,11 @@ extern int getSpriteIndex(char *name); extern void playMusic(char *filename, int loop); extern void addTeleportStars(Entity *e); extern float limit(float i, float a, float b); -extern void addSmokeParticles(float x, float y); extern int rrnd(int low, int high); extern int getDistance(int x1, int y1, int x2, int y2); extern int enemyCanSeePlayer(Entity *e); extern void addDefeatedTarget(char *name); extern void updateObjective(char *targetName); -extern double randF(void); extern void playSound(int snd, int ch); extern Entity *createBaseBullet(Entity *owner); extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy); diff --git a/src/world/entities/boss/tankTrack.h b/src/world/entities/boss/tankTrack.h index 9e310ad..1876465 100644 --- a/src/world/entities/boss/tankTrack.h +++ b/src/world/entities/boss/tankTrack.h @@ -22,21 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern void initBoss(Entity *e); extern int getSpriteIndex(char *name); -extern void playMusic(char *filename, int loop); -extern void addTeleportStars(Entity *e); -extern float limit(float i, float a, float b); -extern void addSmokeParticles(float x, float y); extern int rrnd(int low, int high); -extern int getDistance(int x1, int y1, int x2, int y2); -extern int enemyCanSeePlayer(Entity *e); -extern void addDefeatedTarget(char *name); -extern void updateObjective(char *targetName); -extern double randF(void); extern void playSound(int snd, int ch); -extern Entity *createBaseBullet(Entity *owner); -extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy); -extern void addExplosion(float x, float y, int radius, Entity *owner); extern Entity *self; -extern Game game; extern World world; diff --git a/src/world/entities/items/cell.c b/src/world/entities/items/cell.c new file mode 100644 index 0000000..0ea6c50 --- /dev/null +++ b/src/world/entities/items/cell.c @@ -0,0 +1,57 @@ +/* +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 "cell.h" + +static void touch(Entity *other); + +void initCell(Entity *e) +{ + initItem(e); + + e->isMissionTarget = 1; + + STRNCPY(e->spriteName, "Battery", MAX_NAME_LENGTH); + + e->sprite[0] = e->sprite[1] = e->sprite[2] = getSpriteIndex("Battery"); + + e->spriteFrame = 0; + e->spriteTime = -1; + + e->touch = touch; +} + +static void touch(Entity *other) +{ + if (other != NULL && other->type == ET_BOB && self->alive == ALIVE_ALIVE) + { + game.cells++; + + world.bob->power = world.bob->powerMax = game.cells; + + setGameplayMessage(MSG_OBJECTIVE, "Found a battery cell - Max power increased!"); + + playSound(SND_HEART_CELL, CH_ITEM); + + self->alive = ALIVE_DEAD; + + updateObjective("HEART_CELL"); + } +} diff --git a/src/world/entities/items/cell.h b/src/world/entities/items/cell.h new file mode 100644 index 0000000..be55ef5 --- /dev/null +++ b/src/world/entities/items/cell.h @@ -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 initItem(Entity *e); +extern int getSpriteIndex(char *name); +extern void setGameplayMessage(int type, char *format, ...); +extern void playSound(int snd, int ch); +extern void updateObjective(char *targetName); + +extern Entity *self; +extern Game game; +extern World world; diff --git a/src/world/entities/items/cherry.c b/src/world/entities/items/cherry.c new file mode 100644 index 0000000..c028617 --- /dev/null +++ b/src/world/entities/items/cherry.c @@ -0,0 +1,44 @@ +/* +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 "cherry.h" + +static void touch(Entity *other); + +void initCherry(Entity *e) +{ + initConsumable(e); + + e->touch = touch; +} + +static void touch(Entity *other) +{ + if (touchedPlayer(other)) + { + world.bob->health = limit(world.bob->health + self->value, 0, world.bob->healthMax); + + setGameplayMessage(MSG_STANDARD, "Picked up a %s", self->name); + + pickupItem(); + + playSound(SND_CHERRY, CH_PLAYER); + } +} diff --git a/src/world/entities/items/cherry.h b/src/world/entities/items/cherry.h new file mode 100644 index 0000000..f91d6e7 --- /dev/null +++ b/src/world/entities/items/cherry.h @@ -0,0 +1,34 @@ +/* +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 initConsumable(Entity *e); +extern int getSpriteIndex(char *name); +extern void setGameplayMessage(int type, char *format, ...); +extern void playSound(int snd, int ch); +extern void updateObjective(char *targetName); +extern int touchedPlayer(Entity *other); +extern void pickupItem(void); +extern float limit(float i, float a, float b); + +extern Entity *self; +extern Game game; +extern World world; diff --git a/src/world/entities/items/item.h b/src/world/entities/items/item.h index 214a1aa..fae5c53 100644 --- a/src/world/entities/items/item.h +++ b/src/world/entities/items/item.h @@ -21,10 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../../../common.h" extern void playSound(int snd, int ch); -extern void pickupItem(void); extern void setGameplayMessage(int type, char *format, ...); -extern void initConsumable(Entity *e); -extern int touchedPlayer(Entity *e); extern void addTeleportStars(Entity *e); extern void initEntity(Entity *e); extern int getSpriteIndex(char *name); diff --git a/src/world/entities/unit.h b/src/world/entities/unit.h index 06163d8..b07b958 100644 --- a/src/world/entities/unit.h +++ b/src/world/entities/unit.h @@ -25,8 +25,6 @@ extern void lookForPlayer(void); extern int rrnd(int low, int high); extern float limit(float i, float a, float b); extern int getDistance(int x1, int y1, int x2, int y2); -extern void addTeleportStars(Entity *e); -extern void playSound(int snd, int ch); extern int canFire(Entity *target); extern void fireAimedShot(Entity *e); extern void fireMachineGun(Entity *e);