diff --git a/src/g_missile.c b/src/g_missile.c new file mode 100644 index 0000000..8d38c41 --- /dev/null +++ b/src/g_missile.c @@ -0,0 +1,52 @@ +// Copyright © 2017 Project Golan, all rights reserved. +// See COPYING for more information. +#define _GNU_SOURCE // Required for sincos(3). See feature_test_macros(7) +#include "g_missile.h" + +#include "g_object.h" +#include "m_math.h" + +#include + +// Extern Functions ----------------------------------------------------------| + +// +// G_Missile_Fire +// +void G_Missile_Fire(enum G_mslty type, unsigned owner, fixed x, fixed y, fixed z, ulfra yaw) +{ + G_entit ot = {owner}; + G_missl th = {DGE_MissileEntity_Create(0)}; + th.subtype = subtype_missile; + + th.x = ot.x + x; + th.y = ot.y + y; + th.z = ot.z + z; + th.yaw = yaw; + th.health = 1; + th.damage = 1; + th.owner = owner; + th.sz = 4; + + float s, c; + sincosf(M_angle(yaw), &s, &c); + + switch(type) + { + case missile_p_basicL: + th.sprite = DGE_Texture_Get(s"ent/shotl"); goto player; + case missile_p_basicR: + th.sprite = DGE_Texture_Get(s"ent/shotr"); goto player; + player: + th.ca = 0.7ulr; + th.rsx = 6; + th.rsy = 16; + th.sx = 6; + th.sy = 18; + th.vx = c * 14; + th.vy = s * 14; + break; + } +} + +// EOF diff --git a/src/g_missile.h b/src/g_missile.h new file mode 100644 index 0000000..a255a3c --- /dev/null +++ b/src/g_missile.h @@ -0,0 +1,20 @@ +// Copyright © 2017 Project Golan, all rights reserved. +// See COPYING for more information. +#ifndef g_missile_h +#define g_missile_h + +#include "m_types.h" + +// Types ---------------------------------------------------------------------| + +enum G_mslty +{ + missile_p_basicL, + missile_p_basicR, +}; + +// Extern Functions ----------------------------------------------------------| + +void G_Missile_Fire(enum G_mslty type, unsigned owner, fixed x, fixed y, fixed z, ulfra yaw); + +#endif diff --git a/src/g_player.c b/src/g_player.c index 6e376f0..a8a3a20 100644 --- a/src/g_player.c +++ b/src/g_player.c @@ -4,6 +4,7 @@ #include "g_player.h" #include "g_stage.h" +#include "g_missile.h" #include "m_math.h" #include "m_str.h" @@ -13,14 +14,6 @@ #include #include -// Types ---------------------------------------------------------------------| - -enum G_mslty -{ - missile_playerL, - missile_playerR, -}; - // Extern Objects ------------------------------------------------------------| int G_Player_Count; @@ -57,46 +50,6 @@ static void G_Player_applyVelocity(G_entty const *ty, G_playr th) // Extern Functions ----------------------------------------------------------| -// -// G_Missile_Fire -// -void G_Missile_Fire(enum G_mslty type, unsigned owner, fixed x, fixed y, fixed z, ulfra yaw) -{ - G_entit ot = {owner}; - G_missl th = {DGE_MissileEntity_Create(0)}; - th.subtype = subtype_missile; - - th.x = ot.x + x; - th.y = ot.y + y; - th.z = ot.z + z; - th.yaw = yaw; - th.health = 1; - th.damage = 1; - th.owner = owner; - th.sz = 4; - - float s, c; - sincosf(M_angle(yaw), &s, &c); - - switch(type) - { - case missile_playerL: th.sprite = DGE_Texture_Get(s"ent/shotl"); goto player; - case missile_playerR: th.sprite = DGE_Texture_Get(s"ent/shotr"); goto player; - player: - th.cr = 0.3ulr; - th.cg = 0.9ulr; - th.cb = 0.1ulr; - th.ca = 0.7ulr; - th.rsx = 6; - th.rsy = 16; - th.sx = 6; - th.sy = 18; - th.vx = c * 14; - th.vy = s * 14; - break; - } -} - // // G_Player_Think // @@ -126,8 +79,8 @@ void G_Player_Think(G_entty const *ty, unsigned id) else if(th.nextfire < G_Time) { shot.fsetAnim(G_ObjDef_GetAnim("PlayerShot")); - G_Missile_Fire(missile_playerL, th.id, -18, -7, 0, 0); - G_Missile_Fire(missile_playerR, th.id, +18, -7, 0, 0); + G_Missile_Fire(missile_p_basicL, th.id, -18, -7, 0, 0); + G_Missile_Fire(missile_p_basicR, th.id, +18, -7, 0, 0); th.nextfire = G_Time + 3; }