source: trunk/games/demo-jnat/demo-jnat.cpp @ 1716

Last change on this file since 1716 was 1716, checked in by Jnat, 8 years ago
File size: 2.0 KB
Line 
1// LOL
2
3#if defined HAVE_CONFIG_H
4#   include "config.h"
5#endif
6
7#if defined _WIN32
8#   include <direct.h>
9#endif
10
11#if defined _XBOX
12#   define _USE_MATH_DEFINES /* for M_PI */
13#   include <xtl.h>
14#   undef near /* Fuck Microsoft */
15#   undef far /* Fuck Microsoft again */
16#elif defined _WIN32
17#   define _USE_MATH_DEFINES /* for M_PI */
18#   define WIN32_LEAN_AND_MEAN
19#   include <windows.h>
20#   undef near /* Fuck Microsoft */
21#   undef far /* Fuck Microsoft again */
22#else
23#   include <cmath>
24#endif
25
26#include "core.h"
27
28using namespace std;
29using namespace lol;
30
31
32#include "demo-jnat.h"
33
34
35
36DemoJnat::DemoJnat()
37{
38    m_angle = 0;
39               
40        // set color
41    m_mesh.Compile("sc#221 scb#1c1");
42        m_mesh.AppendFlatChamfBox(vec3(1000, 10, 500), 1.f);
43
44        m_player = new Player();
45        Ticker::Ref(m_player);
46
47    /* Center everything -- is it needed? */
48    //m_mesh.Compile("tx4 tz4");
49
50    m_camera = new Camera(vec3(0.f, 600.f, 0.f),
51                            vec3(0.f, 0.f, 0.f),
52                            vec3(0, 1, 0));
53    m_camera->SetPerspective(70.f, 960.f, 600.f, .1f, 1000.f);
54    m_camera->SetTarget(vec3(0.f, 0.f, 0.f));
55    m_camera->SetPosition(vec3(0.f, 80.f, -100.f));
56    Ticker::Ref(m_camera);
57
58    m_ready = false;
59}
60
61DemoJnat::~DemoJnat(){
62        Ticker::Unref(m_player);
63}
64
65void DemoJnat::TickGame(float seconds)
66{
67    WorldEntity::TickGame(seconds);
68
69
70        // exit
71        if (Input::GetButtonState(27 /*SDLK_ESCAPE*/))
72                Ticker::Shutdown();
73
74        m_angle = 0;
75
76        m_camera->SetTarget(m_player->m_position);
77
78    mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0));
79    mat4 model = mat4::translate(vec3(0, 0, 0));
80
81    m_matrix = model * anim;
82}
83
84void DemoJnat::TickDraw(float seconds)
85{
86    WorldEntity::TickDraw(seconds);
87
88    if (!m_ready)
89    {
90        m_mesh.MeshConvert();
91        m_ready = true;
92    }
93
94    Video::SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f));
95
96    m_mesh.Render(m_matrix);
97}
98
99
100int main(int argc, char **argv)
101{
102    Application app("Jnat Demo", ivec2(960, 600), 60.0f);
103    new DemoJnat();
104    app.Run();
105
106    return EXIT_SUCCESS;
107}
108
Note: See TracBrowser for help on using the repository browser.