source: trunk/games/ToukyDemo/ToukyDemo.cpp @ 1547

Last change on this file since 1547 was 1547, checked in by touky, 8 years ago

Added basic character logic.

File size: 2.3 KB
Line 
1//
2// ToukyDemo
3//
4// Copyright: (c) 2009-2012 Cédric Lecacheur <jordx@free.fr>
5//            (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
6//            (c) 2012 Sam Hocevar <sam@hocevar.net>
7//
8
9#if defined HAVE_CONFIG_H
10#   include "config.h"
11#endif
12
13#if defined _WIN32
14#   include <direct.h>
15#endif
16
17#if defined _XBOX
18#   define _USE_MATH_DEFINES /* for M_PI */
19#   include <xtl.h>
20#   undef near /* Fuck Microsoft */
21#   undef far /* Fuck Microsoft again */
22#elif defined _WIN32
23#   define _USE_MATH_DEFINES /* for M_PI */
24#   define WIN32_LEAN_AND_MEAN
25#   include <windows.h>
26#   undef near /* Fuck Microsoft */
27#   undef far /* Fuck Microsoft again */
28#else
29#   include <cmath>
30#endif
31
32#if USE_SDL && defined __APPLE__
33#   include <SDL_main.h>
34#endif
35
36#include "core.h"
37#include "loldebug.h"
38
39using namespace lol;
40
41#include "ToukyDemo.h"
42
43ToukyDemo::ToukyDemo(bool editor)
44{
45    /* Create a camera that matches the settings of XNA ToukyDemo */
46    m_camera = new Camera(vec3(0.f, 600.f, 0.f),
47                          vec3(0.f, 0.f, 0.f),
48                          vec3(0, 0, -1));
49    m_camera->SetRotation(quat::fromeuler_yxz(0.f, -30.f, 0.f));
50    //m_camera->SetPerspective(120.f, 1280.f, 960.f, -1000.f, 1000.f);
51        m_camera->SetOrtho(1280.f / 6, 960.f / 6, -1000.f, 1000.f);
52    Ticker::Ref(m_camera);
53
54        m_URO = new UserReactiveObject();
55        Ticker::Ref(m_URO);
56
57        m_Character = new Character();
58        m_Character->m_position = vec3(.0f, 10.0f, .0f);
59        Ticker::Ref(m_Character);
60
61    m_ready = false;
62}
63
64void ToukyDemo::TickGame(float seconds)
65{
66    WorldEntity::TickGame(seconds);
67
68    if (Input::GetButtonState(27 /*SDLK_ESCAPE*/))
69        Ticker::Shutdown();
70}
71
72void ToukyDemo::TickDraw(float seconds)
73{
74    WorldEntity::TickDraw(seconds);
75
76    if (!m_ready)
77    {
78        /* FIXME: this object never cleans up */
79        m_ready = true;
80    }
81
82    Video::SetClearColor(vec4(0.0f, 0.0f, 0.12f, 1.0f));
83}
84
85ToukyDemo::~ToukyDemo()
86{
87        Ticker::Unref(m_camera);
88    Ticker::Unref(m_URO);
89        Ticker::Unref(m_Character);
90}
91
92int main(int argc, char **argv)
93{
94    Application app("ToukyDemo", ivec2(800, 600), 60.0f);
95
96#if defined _MSC_VER && !defined _XBOX
97    _chdir("..");
98#elif defined _WIN32 && !defined _XBOX
99    _chdir("../..");
100#endif
101
102    new ToukyDemo(argc > 1);
103    app.ShowPointer(false);
104
105    app.Run();
106
107    return EXIT_SUCCESS;
108}
109
Note: See TracBrowser for help on using the repository browser.