From 0197bcd5faf757d09f63beed185dd0728b731370 Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 9 Feb 2018 22:41:37 +0000 Subject: [PATCH] Added MachineGunDroid. --- common.mk | 2 +- src/entities/entityFactory.c | 1 + src/entities/entityFactory.h | 1 + src/entities/eyeDroids/machineGunDroid.c | 10 ++++++++- src/entities/eyeDroids/machineGunDroid.h | 27 ++++++++++++++++++++++++ src/test/atlasTest.c | 4 ++-- src/world/world.c | 6 +----- 7 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 src/entities/eyeDroids/machineGunDroid.h diff --git a/common.mk b/common.mk index a0f321f..241ce13 100644 --- a/common.mk +++ b/common.mk @@ -42,7 +42,7 @@ _OBJS += i18n.o init.o infoPoint.o input.o io.o item.o items.o itemPad.o _OBJS += cJSON.o _OBJS += key.o keycard.o _OBJS += laser.o laserTrap.o lift.o lookup.o -_OBJS += machineGunBlob.o main.o map.o maths.o mia.o missile.o +_OBJS += machineGunBlob.o machineGunDroid.o main.o map.o maths.o mia.o missile.o _OBJS += objectives.o _OBJS += particles.o player.o pistolBlob.o pistolDroid.o powerPoint.o powerPool.o pressurePlate.o pushBlock.o _OBJS += quadtree.o diff --git a/src/entities/entityFactory.c b/src/entities/entityFactory.c index 3485f6f..0de8678 100644 --- a/src/entities/entityFactory.c +++ b/src/entities/entityFactory.c @@ -38,6 +38,7 @@ void initEntityFactory(void) addEntityDef("GenericEvilBlob", initGenericEvilBlob); addEntityDef("GenericEyeDroid", initGenericEyeDroid); addEntityDef("MachineGunBlob", initMachineGunBlob); + addEntityDef("MachineGunEyeDroid", initMachineGunDroid); addEntityDef("GrenadeBlob", initGrenadeBlob); addEntityDef("GrenadeEyeDroid", initGrenadeDroid); addEntityDef("ShotgunBlob", initShotgunBlob); diff --git a/src/entities/entityFactory.h b/src/entities/entityFactory.h index fc33957..7f368f8 100644 --- a/src/entities/entityFactory.h +++ b/src/entities/entityFactory.h @@ -56,5 +56,6 @@ extern Entity *initRedKeycard(void); extern Entity *initYellowKeycard(void); extern Entity *initLaserTrap(void); extern Entity *initHorizontalLaserTrap(void); +extern Entity *initMachineGunDroid(void); extern World world; diff --git a/src/entities/eyeDroids/machineGunDroid.c b/src/entities/eyeDroids/machineGunDroid.c index 2d34e28..bc98244 100644 --- a/src/entities/eyeDroids/machineGunDroid.c +++ b/src/entities/eyeDroids/machineGunDroid.c @@ -22,9 +22,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static int canFire(Entity *target); -void initMachineGunDroid(Unit *u) +Entity *initMachineGunDroid(void) { + Unit *u; + + u = createUnit(); + initEyeDroid(u); + + u->unitType = "MachineGunEyeDroid"; u->sprite[FACING_LEFT] = getSprite("MachineGunDroidLeft"); u->sprite[FACING_RIGHT] = getSprite("MachineGunDroidRight"); @@ -35,6 +41,8 @@ void initMachineGunDroid(Unit *u) u->maxShotsToFire = 5; u->canFire = canFire; + + return (Entity*)u; } static int canFire(Entity *target) diff --git a/src/entities/eyeDroids/machineGunDroid.h b/src/entities/eyeDroids/machineGunDroid.h new file mode 100644 index 0000000..b83685e --- /dev/null +++ b/src/entities/eyeDroids/machineGunDroid.h @@ -0,0 +1,27 @@ +/* +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 Unit *createUnit(void); +extern void initEyeDroid(Unit *u); +extern Sprite *getSprite(char *name); + +extern Entity *self; diff --git a/src/test/atlasTest.c b/src/test/atlasTest.c index a06e372..21cf54f 100644 --- a/src/test/atlasTest.c +++ b/src/test/atlasTest.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void initAtlasTest(void) { - dev.cheatNoEnemies = 1; + dev.cheatNoEnemies = 0; dev.cheatKeys = 1; dev.cheatPower = 1; @@ -30,7 +30,7 @@ void initAtlasTest(void) initHub(); - loadWorld("data/maps/beachFront2.json"); + loadWorld("data/maps/beachFront3.json"); initWorld(); diff --git a/src/world/world.c b/src/world/world.c index 8befdaf..60ea2f7 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -87,10 +87,6 @@ void initWorld(void) app.delegate.logic = logic; app.delegate.draw = draw; - - startMission(); - world.bob->x = 140 * MAP_TILE_SIZE; - world.bob->y = 106 * MAP_TILE_SIZE; } static void logic(void) @@ -379,7 +375,7 @@ static void doCommon(void) animateSprites(); world.frameCounter++; - world.frameCounter %= 4096; + world.frameCounter %= (FPS * 10); doHud();