source: trunk/games/demo-jnat/player.h @ 1715

Last change on this file since 1715 was 1715, checked in by Jnat, 9 years ago
File size: 979 bytes
Line 
1//
2// demo-jnat
3//
4
5
6#if !defined __PLAYER_H__
7#define __PLAYER_H__
8
9class Player : public WorldEntity
10{
11public:
12    Player()
13      : m_stick(0),
14        m_ready(false)
15    {
16                m_bodymesh.Compile("sc#f21 scb#1c1");
17        m_bodymesh.AppendFlatChamfBox(vec3(10, 30, 10), 1.f);
18                m_position = vec3(0.f,10.0f,0.f);
19    }
20
21    ~Player()
22    {
23        if (m_stick)
24            Input::UntrackStick(m_stick);
25    }
26
27    char const *GetName() { return "<player>"; }
28
29protected:
30    virtual void TickGame(float seconds)
31    {
32        WorldEntity::TickGame(seconds);
33
34
35    }
36
37    virtual void TickDraw(float seconds)
38    {
39        WorldEntity::TickDraw(seconds);
40
41        if (!m_ready)
42        {
43            m_bodymesh.MeshConvert();
44            m_ready = true;
45        }
46
47        mat4 model = mat4::translate(m_position) * mat4(m_rotation);
48
49        m_bodymesh.Render(model);
50    }
51
52private:
53    EasyMesh m_bodymesh;
54    Stick *m_stick;
55
56    bool m_ready;
57};
58
59#endif /* __PLAYER_H__ */
60
Note: See TracBrowser for help on using the repository browser.