Skip to content

Commit

Permalink
Updated "charged fire" secondary player weapon
Browse files Browse the repository at this point in the history
The secondary weapon now fires all bolts from right in front of the ship,
just like the primary nose gun. Instead, the bolts are spread over an
arrow shaped "front," and the're spread by means of different velocities
instead. This prevents firing through base pipes.

The charged bolts now travel slower than the primary weapon as well, which
feels more interesting and "motivated" from a gameplay point of view.

Closes #319.
  • Loading branch information
olofson committed Jan 17, 2017
1 parent 318fccf commit 1c97641
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/myship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ void KOBO_myship::render()
}


void KOBO_myship::shot_single(float dir, int loffset, int hoffset)
void KOBO_myship::shot_single(float dir, int loffset, int hoffset, int speed)
{
int i;
for(i = 0; i < MAX_BOLTS && bolts[i].state; i++)
Expand All @@ -671,8 +671,9 @@ void KOBO_myship::shot_single(float dir, int loffset, int hoffset)
int cdi = cos(M_PI * (dir - 1) / 4) * 256.0f;
bolts[i].x = x - vx + loffset * sdi + hoffset * cdi;
bolts[i].y = y - vy - loffset * cdi + hoffset * sdi;
bolts[i].dx = vx + game.bolt_speed * sdi;
bolts[i].dy = vy - game.bolt_speed * cdi;
int sp = game.bolt_speed * speed;
bolts[i].dx = vx + sp * sdi >> 16;
bolts[i].dy = vy - sp * cdi >> 16;
if(!bolts[i].object)
bolts[i].object = gengine->get_obj(LAYER_PLAYER);
if(bolts[i].object)
Expand Down Expand Up @@ -708,15 +709,17 @@ void KOBO_myship::charged_fire(int dir)
}

int power = _charge > game.charge_max ? game.charge_max : _charge;
int maxbolts = game.charge_max / game.charge_drain;
sound.g_player_charged_fire((float)power / game.charge_max);
while(power >= game.charge_drain)
for(int b = 0; power >= game.charge_drain; ++b)
{
power -= game.charge_drain;
_charge -= game.charge_drain;
float spread = gamerand.get(16) * (8.0f / 65536.0f) - 4.0f;
spread *= game.charge_spread * (1.0f / 360.0f),
shot_single(dir + spread, 15 + power / game.charge_drain,
gamerand.get(3) - 4);
spread *= game.charge_spread * (1.0f / 360.0f);
int cx = gamerand.get(3) - 4;
shot_single(dir + spread, GUN_NOSE_Y - labs(cx), cx,
(b + maxbolts * 2) * 16384 / maxbolts);
}
charge_cool = game.charge_cooldown;
}
Expand Down
3 changes: 2 additions & 1 deletion src/myship.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class KOBO_myship
// For the gfxengine connection
static cs_obj_t *object;

static void shot_single(float dir, int loffset, int hoffset);
static void shot_single(float dir, int loffset, int hoffset,
int speed = 65536);
static void charged_fire(int dir);
static void apply_position();
static void explode();
Expand Down

0 comments on commit 1c97641

Please sign in to comment.