source: trunk/orbital/player.h @ 1347

Last change on this file since 1347 was 1347, checked in by sam, 9 years ago

orbital: more randomness in tanks.

  • Property svn:keywords set to Id
File size: 2.4 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 __PLAYER_H__
10#define __PLAYER_H__
11
12class Player : public WorldEntity
13{
14public:
15    Player()
16      : m_stick(0),
17        m_ready(false)
18    {
19        /* FIXME: this is the orange ship; add code for the other one later */
20        m_ship_mesh.SendCommand("sc1,.5,0,1");
21        m_ship_mesh.SendCommand("afcb5,1,3,0.6,fl,sc1,1,1,1,afcb1,5,3,0.6,tz-1,irb");
22        m_ship_mesh.SendCommand("sc1,.5,0,1");
23        m_ship_mesh.SendCommand("afcb3,6,7,.4,t0,0,7,sc1,1,1,1,afcb3,4,4,.4,t4,0,-4,mx,fl");
24        m_ship_mesh.SendCommand("sc1,.5,0,1");
25        m_ship_mesh.SendCommand("afcb3,6,5,.4,sc1,1,1,1,afcb2,3,9,.4,fl");
26        m_ship_mesh.SendCommand("scb1,1,1,1,ac4,15,.2,.6,1,1,tz-2,ac4,15,.2,.6,1,1,rx90,t0,-2,-7,fl");
27
28        m_exhaust_mesh.SendCommand("sc0,1,1,scb0,0,0,1,ac5,15,0,1.5,0,1,ac7,35,1.1,4,0,1,rx90,t-3,0,27,mx,fl");
29
30        m_drone_mesh.SendCommand("sc0.2,0.7,0,1,afcb3,6,10,0.4,tx-8,afcb3,6,10,0.4,tx4,ty13,fl,sc1,1,1,1,afcb3,6,10,0.4,rx-30,ty13,fl");
31
32        m_position = vec3(0.f, 5.f, 0.f);
33    }
34
35    ~Player()
36    {
37        if (m_stick)
38            Ticker::Unref(m_stick);
39    }
40
41    char const *GetName() { return "<ship>"; }
42
43protected:
44    virtual void TickGame(float seconds)
45    {
46        WorldEntity::TickGame(seconds);
47
48        float rightleft = 0.f, updown = 0.f;
49
50        if (!m_stick)
51            m_stick = Input::TrackStick();
52        if (m_stick && m_stick->GetAxisCount() >= 4)
53        {
54            rightleft += 1.f * m_stick->GetAxis(2);
55            updown += -1.f * m_stick->GetAxis(3);
56        }
57
58        m_position += vec3(rightleft, 0.f, -updown) * 200.f * seconds;
59    }
60
61    virtual void TickDraw(float seconds)
62    {
63        WorldEntity::TickDraw(seconds);
64
65        if (!m_ready)
66        {
67            m_ship_mesh.SendCommand("irb");
68            m_exhaust_mesh.SendCommand("irb");
69            m_drone_mesh.SendCommand("irb");
70            m_ready = true;
71        }
72
73        mat4 model = mat4::translate(m_position) * mat4(m_rotation);
74        m_ship_mesh.Render(model);
75        m_exhaust_mesh.Render(model);
76
77        for (int i = 0; i < m_drones.Count(); i++)
78        {
79            m_drone_mesh.Render(model * mat4::translate(m_drones[i]));
80        }
81    }
82
83private:
84    Mesh m_ship_mesh, m_drone_mesh, m_exhaust_mesh;
85    Stick *m_stick;
86
87    Array<vec3> m_drones;
88    bool m_ready;
89};
90
91#endif /* __PLAYER_H__ */
92
Note: See TracBrowser for help on using the repository browser.