Cell, Cherry. Code clean up.

This commit is contained in:
Steve 2018-01-26 19:24:03 +00:00
parent 75f6220aeb
commit 8e2ed9bace
13 changed files with 167 additions and 25 deletions

View File

@ -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

View File

@ -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);

View File

@ -24,4 +24,3 @@ extern int getDistance(int x1, int y1, int x2, int y2);
extern Dev dev;
extern Game game;
extern World world;

View File

@ -30,5 +30,4 @@ extern void updateObjective(char *targetName);
extern void addRescuedMIA(char *name);
extern Entity *self;
extern Game game;
extern World world;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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");
}
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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);