source: trunk/orbital/gun.h @ 1423

Last change on this file since 1423 was 1423, checked in by sam, 11 years ago

orbital: fix copyright statements.

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