source: trunk/orbital/gun.h @ 1396

Last change on this file since 1396 was 1396, checked in by sam, 8 years ago

orbital: start working on the gun system.

File size: 2.9 KB
Line 
1//
2// Orbital
3//
4// Copyright: (c) 2012 Various People
5//
6
7/* TODO for this file:
8 *  - rename "AppendQuadVert" to "AddVertex" or something; it has nothing
9 *    to do with quads.
10 */
11
12extern char const *lolfx_shiny;
13
14#include "CommandParser.h"
15
16#if !defined __GUN_H__
17#define __GUN_H__
18
19class Gun : public CommandParser
20{
21public:
22    Gun()
23      : m_position(0.f),
24        m_scrz(0.f),
25        m_round_duration(0.2f),
26        m_round_timer(0.f),
27        m_elapsed_time(0.f),
28        m_radius(5.f),
29        m_angle(0.f),
30        m_angle_offset(0.f),
31        m_pre_aim(0.f),
32        m_nbshoots(0),
33        m_shoot_type(0),
34        m_shoot_speed(10.f),
35        m_continuous_aim(false),
36        m_running(false)
37    {}
38
39    virtual void SwitchCommand(char const *&command)
40    {
41        vec4 v4;
42        vec3 v3;
43        float f1, f2, f3, f4, f5, f6, f7, f8;
44
45        const char *&p = command;
46        {
47#define CASE(str) if (CheckCommand(str, p))
48                 CASE("ai") { m_angle = AimActor(); }
49            else CASE("pai") { p = GetArg(p, f1); PreAimActor(f1); }
50            else CASE("ca") { p = GetArg(p, f1); m_pre_aim = f1; }
51            else CASE("sa") { p = GetArg(p, f1); m_angle = f1; }
52            else CASE("tim") { p = GetArg(p, f1); m_round_duration = f1; }
53            else CASE("so") { p = GetArg(p, f1); m_angle_offset = f1; }
54            else CASE("rd") { p = GetArg(p, f1); m_radius = f1; }
55            else CASE("spd") { p = GetArg(p, f1); m_shoot_speed = f1; }
56            else CASE("moda") { p = GetArg(p, v3); /* FIXME: 1st modifier */ }
57            else CASE("modb") { p = GetArg(p, v3); /* FIXME: 2nd modifier */ }
58            else CASE("ffb") { p = GetArg(p, f1); for (int i = 0; i < (int)f1; i++) Shoot(1); m_shoot_type = 1; m_round_timer = m_round_duration; }
59            else CASE("ffp") { p = GetArg(p, f1); for (int i = 0; i < (int)f1; i++) Shoot(0); m_shoot_type = 0; m_round_timer = m_round_duration; }
60            else CASE("fb") { p = GetArg(p, f1); Shoot(1); m_nbshoots = (int)f1 - 1; m_shoot_type = 1; m_round_timer = m_round_duration; }
61            else CASE("fp") { p = GetArg(p, f1); Shoot(0); m_nbshoots = (int)f1 - 1; m_shoot_type = 0; m_round_timer = m_round_duration; }
62            else CASE("sk") { p = GetArg(p, f1); m_round_timer = m_round_duration * f1; /* FIXME: modifiers */ }
63            else CASE("loop") { /* FIXME: loops */ }
64#undef CASE
65        }
66    }
67
68    void Shoot(int count)
69    {
70        float angle = m_angle + m_angle_offset /* FIXME: modifiers */;
71    }
72
73    float AimActor()
74    {
75        return 0.f;
76    }
77
78    void PreAimActor(float time)
79    {
80    }
81
82private:
83    vec3 m_position;
84    float m_scrz;
85    float m_round_duration, m_round_timer, m_elapsed_time;
86    float m_radius, m_angle, m_angle_offset;
87    float m_pre_aim;
88    int m_nbshoots, m_shoot_type;
89    float m_shoot_speed;
90    bool m_continuous_aim, m_running;
91    /* FIXME: angle modifier? */
92};
93
94#endif /* __GUN_H__ */
95
Note: See TracBrowser for help on using the repository browser.