Centre bullets more inside shooter.

This commit is contained in:
Steve 2018-04-24 19:04:08 +01:00
parent 73e0e4b17a
commit d4f310119f
13 changed files with 26 additions and 38 deletions

View File

@ -71,7 +71,7 @@ void firePistol(void)
if (world.bob->facing != FACING_DIE)
{
bullet = createBaseBullet((Unit*)world.bob);
bullet = createBaseBullet((Unit*)world.bob, bulletSprite[0]->frames[0]->rect.w);
bullet->weaponType = WPN_PISTOL;
bullet->facing = world.bob->facing;
bullet->sprite[0] = bulletSprite[0];
@ -96,7 +96,7 @@ void fireAimedShot(Unit *owner)
getSlope(x, y, owner->x, owner->y, &dx, &dy);
bullet = createBaseBullet(owner);
bullet = createBaseBullet(owner, aimedSprite->w);
bullet->weaponType = WPN_AIMED_PISTOL;
bullet->dx = dx * 6;
bullet->dy = dy * 6;
@ -115,7 +115,7 @@ void fireMachineGun(Unit *owner)
if (owner->facing != FACING_DIE)
{
bullet = createBaseBullet(owner);
bullet = createBaseBullet(owner, bulletSprite[0]->w);
bullet->weaponType = WPN_MACHINE_GUN;
bullet->sprite[0] = bulletSprite[0];
bullet->sprite[1] = bulletSprite[1];
@ -131,7 +131,7 @@ void firePlasma(Unit *owner)
if (owner->facing != FACING_DIE)
{
bullet = createBaseBullet(owner);
bullet = createBaseBullet(owner, plasmaSprite[0]->w);
bullet->weaponType = WPN_PLASMA;
bullet->sprite[0] = plasmaSprite[0];
bullet->sprite[1] = plasmaSprite[1];
@ -155,7 +155,7 @@ void fireSpread(Unit *owner, int numberOfShots)
for (i = 0 ; i < numberOfShots ; i++)
{
bullet = createBaseBullet(owner);
bullet = createBaseBullet(owner, spreadShotSprite->w);
bullet->weaponType = WPN_SPREAD;
bullet->sprite[0] = bullet->sprite[1] = owner->type == ET_BOB ? spreadShotSprite : alienSpreadShotSprite;
bullet->dx = owner->facing == FACING_RIGHT ? 15 : -15;
@ -176,9 +176,7 @@ void fireLaser(Unit *owner)
if (owner->facing != FACING_DIE)
{
laser = createBaseBullet(owner);
laser->x = owner->x + owner->w / 2;
laser->y = owner->y + owner->h / 2;
laser = createBaseBullet(owner, laserSprite[0]->w);
laser->facing = owner->facing;
laser->dx = owner->facing == FACING_RIGHT ? 20 : -20;
laser->health = FPS * 3;
@ -198,8 +196,7 @@ void fireGrenade(Unit *owner)
if (owner->facing != FACING_DIE)
{
grenade = createBaseBullet(owner);
grenade->x = owner->x + owner->w / 2;
grenade = createBaseBullet(owner, grenadeSprite->w);
grenade->y = owner->y;
grenade->facing = owner->facing;
grenade->health = FPS * 3;
@ -227,7 +224,7 @@ void fireShotgun(Unit *owner)
{
getSlope(world.bob->x + rrnd(0, 40), world.bob->y + rrnd(0, 40), owner->x, owner->y, &dx, &dy);
bullet = createBaseBullet(owner);
bullet = createBaseBullet(owner, 0);
bullet->weaponType = WPN_SHOTGUN;
bullet->x = owner->x + (owner->w / 2) + rrnd(-8, 8);
bullet->y = owner->y + (owner->h / 2) + rrnd(-8, 8);
@ -249,8 +246,7 @@ void fireMissile(Unit *owner)
if (owner->facing != FACING_DIE)
{
missile = createBaseBullet(owner);
missile->x = owner->x + owner->w / 2;
missile = createBaseBullet(owner, missileSprite[0]->w);
missile->y = owner->y + 10;
missile->facing = owner->facing;
missile->dx = owner->facing == FACING_RIGHT ? 10 : -10;

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../common.h"
extern Bullet *createBaseBullet(Unit *owner);
extern Bullet *createBaseBullet(Unit *owner, int bulletWidth);
extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);
extern Sprite *getSprite(char *name);
extern void initGrenade(Bullet *b);

View File

@ -161,9 +161,7 @@ static void attack(void)
getSlope(target->x, target->y, self->x, self->y, &dx, &dy);
bullet = createBaseBullet((Unit*)self);
bullet->x = self->x;
bullet->y = (self->y + self->h / 2) - 3;
bullet = createBaseBullet((Unit*)self, aimedSprite->w);
bullet->facing = self->facing;
bullet->damage = 1;
bullet->owner = self;

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void addTeleportStars(Entity *e);
extern Bullet *createBaseBullet(Unit *owner);
extern Bullet *createBaseBullet(Unit *owner, int bulletWidth);
extern Unit *createUnit(void);
extern int getDistance(int x1, int y1, int x2, int y2);
extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);

View File

@ -313,9 +313,7 @@ static void attack(void)
getSlope(bx, by, self->x, self->y, &dx, &dy);
bullet = createBaseBullet((Unit*)self);
bullet->x = self->x;
bullet->y = (self->y + self->h / 2) - 3;
bullet = createBaseBullet((Unit*)self, aimedSprite->w);
bullet->facing = self->facing;
bullet->damage = 1;
bullet->owner = self;

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern void addTeleportStars(Entity *e);
extern void awardTrophy(char *id);
extern Bullet *createBaseBullet(Unit *owner);
extern Bullet *createBaseBullet(Unit *owner, int bulletWidth);
extern int enemyCanSeePlayer(Entity *e);
extern void entityIdle(void);
extern int getDistance(int x1, int y1, int x2, int y2);

View File

@ -278,9 +278,7 @@ static void attackPistol(void)
getSlope(bx, by, self->x, self->y, &dx, &dy);
bullet = createBaseBullet((Unit*)self);
bullet->x = (self->x + self->w / 2);
bullet->y = (self->y + self->h / 2) - 3;
bullet = createBaseBullet((Unit*)self, aimedSprite->w);
bullet->facing = self->facing;
bullet->damage = 1;
bullet->owner = self;
@ -302,9 +300,7 @@ static void attackPlasma(void)
b = (Boss*)self;
bullet = createBaseBullet((Unit*)self);
bullet->x = (self->x + self->w / 2);
bullet->y = (self->y + self->h / 2) - 3;
bullet = createBaseBullet((Unit*)self, plasmaSprite[0]->w);
bullet->facing = self->facing;
bullet->damage = 2;
bullet->owner = self;
@ -327,9 +323,7 @@ static void attackMissile(void)
b = (Boss*)self;
missile = createBaseBullet((Unit*)self);
missile->x = b->x + b->w / 2;
missile->y = b->y + b->h / 2;
missile = createBaseBullet((Unit*)self, missileSprite[0]->w);
missile->facing = b->facing;
missile->dx = b->facing == FACING_RIGHT ? 15 : -15;
missile->owner = self;

View File

@ -24,7 +24,7 @@ extern void addExplosion(float x, float y, int radius, Entity *owner);
extern void addSmokeParticles(float x, float y, int rising);
extern void addTeleportStars(Entity *e);
extern void awardTrophy(char *id);
extern Bullet *createBaseBullet(Unit *owner);
extern Bullet *createBaseBullet(Unit *owner, int bulletWidth);
extern int enemyCanSeePlayer(Entity *e);
extern void entityIdle(void);
extern int getDistance(int x1, int y1, int x2, int y2);

View File

@ -250,7 +250,7 @@ static void attackPistol(void)
getSlope(bx, by, b->x, b->y, &dx, &dy);
bullet = createBaseBullet((Unit*)self);
bullet = createBaseBullet((Unit*)self, aimedSprite->w);
bullet->x = (b->x + b->w / 2);
bullet->y = b->y + 30;
bullet->facing = b->facing;
@ -274,7 +274,7 @@ static void attackMissile(void)
b = (Boss*)self;
missile = createBaseBullet((Unit*)self);
missile = createBaseBullet((Unit*)self, missileSprite[0]->w);
missile->x = b->x + b->w / 2;
missile->y = b->y + 30;
missile->facing = b->facing;

View File

@ -24,7 +24,7 @@ extern void addExplosion(float x, float y, int radius, Entity *owner);
extern void addScorchDecal(int x, int y);
extern void addTeleportStars(Entity *e);
extern void awardTrophy(char *id);
extern Bullet *createBaseBullet(Unit *owner);
extern Bullet *createBaseBullet(Unit *owner, int bulletWidth);
extern int enemyCanSeePlayer(Entity *e);
extern void entityIdle(void);
extern int getDistance(int x1, int y1, int x2, int y2);

View File

@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void tick(void);
static void touch(Entity *other);
Bullet *createBaseBullet(Unit *owner)
Bullet *createBaseBullet(Unit *owner, int bulletWidth)
{
Bullet *bullet;
@ -32,7 +32,7 @@ Bullet *createBaseBullet(Unit *owner)
initEntity((Entity*)bullet);
bullet->x = (owner->x + owner->w / 2);
bullet->x = owner->x + (owner->w / 2) - (bulletWidth / 2);
bullet->y = (owner->y + owner->h / 2) - 3;
bullet->dx = owner->facing == FACING_RIGHT ? 15 : -15;
bullet->facing = owner->facing;

View File

@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern void addSmallFleshChunk(float x, float y);
extern void addSparkParticles(float x, float y);
extern Bullet *createBaseBullet(Unit *owner);
extern void initEntity(Entity *e);
extern void playBattleSound(int snd, int ch, int x, int y);
extern void swapSelf(Entity *e);

View File

@ -163,6 +163,9 @@ void loadSprite(cJSON *root)
i++;
}
s->w = s->frames[0]->rect.w;
s->h = s->frames[0]->rect.h;
}
void destroySprites(void)