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

Last change on this file since 1743 was 1743, checked in by Jnat, 7 years ago
File size: 2.6 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#include "loldebug.h"
28
29using namespace std;
30using namespace lol;
31
32
33#include "demo-jnat.h"
34
35
36
37DemoJnat::DemoJnat()
38{
39    m_angle = 0;
40               
41        // Fucking decor
42    m_mesh.Compile("sc#221 scb#1c1");
43        m_mesh.OpenBrace();
44        m_mesh.AppendFlatChamfBox(vec3(500, 50, 100), 1.f);
45        m_mesh.CloseBrace();
46        m_mesh.OpenBrace();
47        m_mesh.AppendFlatChamfBox(vec3(500, 50, 100), 1.f);
48        m_mesh.Translate(vec3(-300, -100,0));
49        m_mesh.AppendFlatChamfBox(vec3(100, 200, 100), 1.f);
50        m_mesh.Translate(vec3(900, 100,0));
51        m_mesh.CloseBrace();
52
53
54        //Osom player
55        m_player = new Player();
56        m_player->m_position = vec3(0.f,30.f,30.f);
57        Ticker::Ref(m_player);
58
59    m_camera = new Camera(vec3(0.f, 600.f, 0.f),
60                            vec3(0.f, 0.f, 0.f),
61                            vec3(0, 1, 0));
62    //m_camera->SetPerspective(20.f, 960.f, 600.f, .1f, 1000.f);
63        m_camera->SetPerspective(30.f, 960.f, 600.f, .1f, 1000.f);
64
65    m_camera->SetTarget(vec3(0.f, 0.f, 0.f));
66    m_camera->SetPosition(vec3(0.f, 60.f, 100.f));
67    Ticker::Ref(m_camera);
68    m_ready = false;
69}
70
71DemoJnat::~DemoJnat(){
72        Ticker::Unref(m_player);
73}
74
75void DemoJnat::TickGame(float seconds)
76{
77    WorldEntity::TickGame(seconds);
78
79
80        // exit
81        if (Input::GetButtonState(27 /*SDLK_ESCAPE*/))
82                Ticker::Shutdown();
83
84        m_angle = 0;
85
86        m_camera->SetTarget(m_player->m_position + vec3(0.f,50.f,0.f));
87        //m_camera->SetPosition(m_player->m_position + vec3(0.0f, 0.0f, 1000.0f));
88        m_camera->SetPosition(m_player->m_position + vec3(0.0f, 200.0f, 300.0f));
89    mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0));
90    mat4 model = mat4::translate(vec3(0, 0, 0));
91
92    m_matrix = model * anim;
93}
94
95void DemoJnat::TickDraw(float seconds)
96{
97    WorldEntity::TickDraw(seconds);
98
99    if (!m_ready)
100    {
101        m_mesh.MeshConvert();
102        m_ready = true;
103    }
104
105    Video::SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f));
106
107    m_mesh.Render(m_matrix);
108}
109
110
111int main(int argc, char **argv)
112{
113    Application app("Jnat Demo", ivec2(960, 600), 60.0f);
114
115#if defined _MSC_VER && !defined _XBOX
116    _chdir("..");
117#elif defined _WIN32 && !defined _XBOX
118    _chdir("../..");
119#endif
120
121        new DebugFps(5, 5);
122        new DemoJnat();
123    app.Run();
124
125    return EXIT_SUCCESS;
126}
127
Note: See TracBrowser for help on using the repository browser.