Move missile code to g_missile
parent
b0734bda05
commit
348c4f2adb
|
@ -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 <math.h>
|
||||||
|
|
||||||
|
// 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
|
|
@ -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
|
|
@ -4,6 +4,7 @@
|
||||||
#include "g_player.h"
|
#include "g_player.h"
|
||||||
|
|
||||||
#include "g_stage.h"
|
#include "g_stage.h"
|
||||||
|
#include "g_missile.h"
|
||||||
#include "m_math.h"
|
#include "m_math.h"
|
||||||
#include "m_str.h"
|
#include "m_str.h"
|
||||||
|
|
||||||
|
@ -13,14 +14,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
// Types ---------------------------------------------------------------------|
|
|
||||||
|
|
||||||
enum G_mslty
|
|
||||||
{
|
|
||||||
missile_playerL,
|
|
||||||
missile_playerR,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Extern Objects ------------------------------------------------------------|
|
// Extern Objects ------------------------------------------------------------|
|
||||||
|
|
||||||
int G_Player_Count;
|
int G_Player_Count;
|
||||||
|
@ -57,46 +50,6 @@ static void G_Player_applyVelocity(G_entty const *ty, G_playr th)
|
||||||
|
|
||||||
// Extern Functions ----------------------------------------------------------|
|
// 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
|
// G_Player_Think
|
||||||
//
|
//
|
||||||
|
@ -126,8 +79,8 @@ void G_Player_Think(G_entty const *ty, unsigned id)
|
||||||
else if(th.nextfire < G_Time)
|
else if(th.nextfire < G_Time)
|
||||||
{
|
{
|
||||||
shot.fsetAnim(G_ObjDef_GetAnim("PlayerShot"));
|
shot.fsetAnim(G_ObjDef_GetAnim("PlayerShot"));
|
||||||
G_Missile_Fire(missile_playerL, th.id, -18, -7, 0, 0);
|
G_Missile_Fire(missile_p_basicL, th.id, -18, -7, 0, 0);
|
||||||
G_Missile_Fire(missile_playerR, th.id, +18, -7, 0, 0);
|
G_Missile_Fire(missile_p_basicR, th.id, +18, -7, 0, 0);
|
||||||
th.nextfire = G_Time + 3;
|
th.nextfire = G_Time + 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue