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 | |
---|
12 | class Player : public WorldEntity |
---|
13 | { |
---|
14 | public: |
---|
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, 3.5f + 50.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 | |
---|
43 | protected: |
---|
44 | virtual void TickGame(float seconds) |
---|
45 | { |
---|
46 | WorldEntity::TickGame(seconds); |
---|
47 | |
---|
48 | float updown = Input::GetButtonState(273 /*SDLK_UP*/) |
---|
49 | - Input::GetButtonState(274 /*SDLK_DOWN*/); |
---|
50 | float rightleft = Input::GetButtonState(275 /*SDLK_RIGHT*/) |
---|
51 | - Input::GetButtonState(276 /*SDLK_LEFT*/); |
---|
52 | |
---|
53 | if (!m_stick) |
---|
54 | m_stick = Input::TrackStick(); |
---|
55 | if (m_stick && m_stick->GetAxisCount() >= 4) |
---|
56 | { |
---|
57 | rightleft += 1.f * m_stick->GetAxis(2); |
---|
58 | updown += -1.f * m_stick->GetAxis(3); |
---|
59 | } |
---|
60 | |
---|
61 | m_position += vec3(rightleft, 0.f, -updown) * 200.f * seconds; |
---|
62 | } |
---|
63 | |
---|
64 | virtual void TickDraw(float seconds) |
---|
65 | { |
---|
66 | WorldEntity::TickDraw(seconds); |
---|
67 | |
---|
68 | if (!m_ready) |
---|
69 | { |
---|
70 | m_ship_mesh.SendCommand("irb"); |
---|
71 | m_exhaust_mesh.SendCommand("irb"); |
---|
72 | m_drone_mesh.SendCommand("irb"); |
---|
73 | m_ready = true; |
---|
74 | } |
---|
75 | |
---|
76 | mat4 model = mat4::translate(m_position) * mat4(m_rotation); |
---|
77 | m_ship_mesh.Render(model); |
---|
78 | m_exhaust_mesh.Render(model); |
---|
79 | |
---|
80 | for (int i = 0; i < m_drones.Count(); i++) |
---|
81 | { |
---|
82 | m_drone_mesh.Render(model * mat4::translate(m_drones[i])); |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | private: |
---|
87 | Mesh m_ship_mesh, m_drone_mesh, m_exhaust_mesh; |
---|
88 | Stick *m_stick; |
---|
89 | |
---|
90 | Array<vec3> m_drones; |
---|
91 | bool m_ready; |
---|
92 | }; |
---|
93 | |
---|
94 | #endif /* __PLAYER_H__ */ |
---|
95 | |
---|