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

Last change on this file since 1723 was 1723, checked in by Jnat, 8 years ago

omg

File size: 2.3 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.OpenBrace();
43        m_mesh.AppendFlatChamfBox(vec3(500, 50, 100), 1.f);
44        m_mesh.CloseBrace();
45        m_mesh.OpenBrace();
46        m_mesh.AppendFlatChamfBox(vec3(500, 50, 100), 1.f);
47        m_mesh.Translate(vec3(-300, -100,0));
48        m_mesh.AppendFlatChamfBox(vec3(100, 200, 100), 1.f);
49        m_mesh.Translate(vec3(900, 100,0));
50        m_mesh.CloseBrace();
51
52        m_player = new Player();
53        m_player->m_position = vec3(0.f,30.f,30.f);
54        Ticker::Ref(m_player);
55
56    m_camera = new Camera(vec3(0.f, 600.f, 0.f),
57                            vec3(0.f, 0.f, 0.f),
58                            vec3(0, 1, 0));
59    m_camera->SetPerspective(20.f, 960.f, 600.f, .1f, 1000.f);
60    m_camera->SetTarget(vec3(0.f, 0.f, 0.f));
61    m_camera->SetPosition(vec3(0.f, 60.f, 100.f));
62    Ticker::Ref(m_camera);
63
64    m_ready = false;
65}
66
67DemoJnat::~DemoJnat(){
68        Ticker::Unref(m_player);
69}
70
71void DemoJnat::TickGame(float seconds)
72{
73    WorldEntity::TickGame(seconds);
74
75
76        // exit
77        if (Input::GetButtonState(27 /*SDLK_ESCAPE*/))
78                Ticker::Shutdown();
79
80        m_angle = 0;
81
82        m_camera->SetTarget(m_player->m_position + vec3(0.f,100.f,0.f));
83        m_camera->SetPosition(m_player->m_position + vec3(0.0f, 0.0f, 1000.0f));
84    mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0));
85    mat4 model = mat4::translate(vec3(0, 0, 0));
86
87    m_matrix = model * anim;
88}
89
90void DemoJnat::TickDraw(float seconds)
91{
92    WorldEntity::TickDraw(seconds);
93
94    if (!m_ready)
95    {
96        m_mesh.MeshConvert();
97        m_ready = true;
98    }
99
100    Video::SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f));
101
102    m_mesh.Render(m_matrix);
103}
104
105
106int main(int argc, char **argv)
107{
108    Application app("Jnat Demo", ivec2(960, 600), 60.0f);
109    new DemoJnat();
110    app.Run();
111
112    return EXIT_SUCCESS;
113}
114
Note: See TracBrowser for help on using the repository browser.