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

Last change on this file since 1743 was 1743, checked in by Jnat, 8 years ago
File size: 2.6 KB
RevLine 
[1713]1// LOL
2
3#if defined HAVE_CONFIG_H
4#   include "config.h"
5#endif
6
[1715]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
[1713]26#include "core.h"
[1743]27#include "loldebug.h"
[1713]28
29using namespace std;
30using namespace lol;
31
32
[1715]33#include "demo-jnat.h"
[1713]34
35
36
[1715]37DemoJnat::DemoJnat()
38{
39    m_angle = 0;
40               
[1729]41        // Fucking decor
[1715]42    m_mesh.Compile("sc#221 scb#1c1");
[1723]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();
[1713]52
[1729]53
54        //Osom player
[1715]55        m_player = new Player();
[1723]56        m_player->m_position = vec3(0.f,30.f,30.f);
[1715]57        Ticker::Ref(m_player);
[1713]58
[1715]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));
[1739]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
[1715]65    m_camera->SetTarget(vec3(0.f, 0.f, 0.f));
[1723]66    m_camera->SetPosition(vec3(0.f, 60.f, 100.f));
[1715]67    Ticker::Ref(m_camera);
68    m_ready = false;
69}
[1713]70
[1715]71DemoJnat::~DemoJnat(){
72        Ticker::Unref(m_player);
73}
[1713]74
[1715]75void DemoJnat::TickGame(float seconds)
76{
77    WorldEntity::TickGame(seconds);
[1713]78
79
[1715]80        // exit
81        if (Input::GetButtonState(27 /*SDLK_ESCAPE*/))
82                Ticker::Shutdown();
[1713]83
[1715]84        m_angle = 0;
[1713]85
[1739]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));
[1715]89    mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0));
90    mat4 model = mat4::translate(vec3(0, 0, 0));
[1713]91
[1715]92    m_matrix = model * anim;
93}
[1713]94
[1715]95void DemoJnat::TickDraw(float seconds)
96{
97    WorldEntity::TickDraw(seconds);
[1713]98
[1715]99    if (!m_ready)
100    {
101        m_mesh.MeshConvert();
102        m_ready = true;
[1713]103    }
104
[1715]105    Video::SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f));
[1713]106
[1715]107    m_mesh.Render(m_matrix);
108}
[1713]109
110
111int main(int argc, char **argv)
112{
[1715]113    Application app("Jnat Demo", ivec2(960, 600), 60.0f);
[1743]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();
[1713]123    app.Run();
124
125    return EXIT_SUCCESS;
126}
127
Note: See TracBrowser for help on using the repository browser.