source: trunk/orbital/tank.h @ 1333

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

orbital: put the tanks in a separate class.

File size: 1.2 KB
Line 
1//
2// Orbital
3//
4// Copyright: (c) 2012 Various People
5//
6
7/* FIXME: this file is pure crap; it's only a test. */
8
9#if !defined __TANK_H__
10#define __TANK_H__
11
12class Tank : public WorldEntity
13{
14public:
15    Tank()
16      : m_angle(0.f),
17        m_ready(false)
18    {
19        m_body.SendCommand("sc0.1,0.1,0,1,ab6,6,15,ty-2,sc1,1,1,1,afcb4,5,16,0.4,tx4,mx,fl,sc0.2,0.7,0,1,afcb8,7,10,0.4,tz-4,fl");
20        m_head.SendCommand("sc0.2,0.7,0,1,afcb3,6,10,0.4,tx-8,afcb3,6,10,0.4,tx4,ty10,fl,sc1,1,1,1,afcb3,6,10,0.4,rx-30,ty10,fl");
21    }
22
23    ~Tank()
24    {
25    }
26
27    char const *GetName() { return "<tank>"; }
28
29protected:
30    virtual void TickGame(float seconds)
31    {
32        WorldEntity::TickGame(seconds);
33
34        m_angle += seconds * 50.f;
35    }
36
37    virtual void TickDraw(float seconds)
38    {
39        WorldEntity::TickDraw(seconds);
40
41        if (!m_ready)
42        {
43            m_body.SendCommand("irb");
44            m_head.SendCommand("irb");
45            m_ready = true;
46        }
47
48        mat4 model = mat4::translate(m_position);
49
50        m_body.Render(model);
51
52        model = model * mat4::rotate(m_angle, vec3(0, 1, 0));
53        m_head.Render(model);
54    }
55
56private:
57    Mesh m_body, m_head;
58    float m_angle;
59    bool m_ready;
60};
61
62#endif /* __TANK_H__ */
63
Note: See TracBrowser for help on using the repository browser.