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

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