source: trunk/orbital/tank.h @ 1397

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

orbital: tweak enemy colours and restore smaller screen.

File size: 1.7 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_turret_angle(0.f),
17        m_ready(false)
18    {
19        m_body.SendCommand("sc0.1,0.1,0,1,ab6,6,15,ty-2,sc.7,.8,.7,1,afcb4,5,16,0.4,tx4,ty5,mx,fl,sc0.2,0.7,0,1,afcb8,7,10,0.4,tz-4,ty5,fl");
20        m_turret.SendCommand("sc0.2,0.7,0,1,afcb3,6,10,0.4,tx-8,afcb3,6,10,0.4,tx4,ty13,fl,sc.7,.8,.7,1,afcb3,6,10,0.4,rx-30,ty13,fl");
21
22        m_rotation = quat::rotate(RandF(0.f, 360.f), vec3(0, 1, 0));
23    }
24
25    ~Tank()
26    {
27    }
28
29    char const *GetName() { return "<tank>"; }
30
31    /* Set a target for the tank */
32    void SetTarget(vec3 const &position)
33    {
34        m_target = position;
35    }
36
37protected:
38    virtual void TickGame(float seconds)
39    {
40        WorldEntity::TickGame(seconds);
41
42        float test = RandF(40.f, 70.f);
43        m_rotation *= quat::rotate(seconds * test, vec3(0, 1, 0));
44        m_velocity = m_rotation.transform(vec3(0, 0, 1));
45        m_position += seconds * 80.f * m_velocity;
46
47        m_turret_angle += seconds * 50.f;
48    }
49
50    virtual void TickDraw(float seconds)
51    {
52        WorldEntity::TickDraw(seconds);
53
54        if (!m_ready)
55        {
56            m_body.SendCommand("irb");
57            m_turret.SendCommand("irb");
58            m_ready = true;
59        }
60
61        mat4 model = mat4::translate(m_position) * mat4(m_rotation);
62        m_body.Render(model);
63
64        model = model * mat4::rotate(m_turret_angle, vec3(0, 1, 0));
65        m_turret.Render(model);
66    }
67
68private:
69    Mesh m_body, m_turret;
70    vec3 m_target;
71    float m_turret_angle;
72    bool m_ready;
73};
74
75#endif /* __TANK_H__ */
76
Note: See TracBrowser for help on using the repository browser.