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

Last change on this file since 1647 was 1647, checked in by sam, 7 years ago

build: hide the SDL_main.h inclusion in core.h, and only activate it
on Windows if using Visual Studio; if using MinGW, try to stick to the
original main() entry point.

File size: 2.4 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#include "core.h"
33#include "loldebug.h"
34#include <cstdio>
35
36using namespace lol;
37
38#include "ToukyDemo.h"
39
40ToukyDemo::ToukyDemo(bool editor)
41{
42    /* Create a camera that matches the settings of XNA ToukyDemo */
43    m_camera = new Camera(vec3(0.f, 600.f, 0.f),
44                          vec3(0.f, 0.f, 0.f),
45                          vec3(0, 0, -1));
46    //m_camera->SetRotation(quat::fromeuler_yxz(0.f, -30.f, 0.f));
47    m_camera->SetPerspective(120.f, 1280.f, 960.f, .1f, 1000.f);
48        m_camera->SetOrtho(1280.f / 6, 960.f / 6, -1000.f, 1000.f);
49    Ticker::Ref(m_camera);
50
51        m_URO = new UserReactiveObject();
52        m_URO->m_position = vec3(.0f, -80.0f, .0f);
53        Ticker::Ref(m_URO);
54
55        m_Character = new Character();
56        m_Character->m_position = vec3(.0f, 10.0f, 40.0f);
57        Ticker::Ref(m_Character);
58        m_URO->InfluenceEntityRegistration(true, m_Character);
59
60    m_ready = false;
61}
62
63void ToukyDemo::TickGame(float seconds)
64{
65    WorldEntity::TickGame(seconds);
66
67    if (Input::GetButtonState(27 /*SDLK_ESCAPE*/))
68        Ticker::Shutdown();
69}
70
71void ToukyDemo::TickDraw(float seconds)
72{
73    WorldEntity::TickDraw(seconds);
74
75    if (!m_ready)
76    {
77        /* FIXME: this object never cleans up */
78        m_ready = true;
79    }
80
81    Video::SetClearColor(vec4(0.0f, 0.0f, 0.12f, 1.0f));
82}
83
84ToukyDemo::~ToukyDemo()
85{
86        m_URO->InfluenceEntityRegistration(false, m_Character);
87
88        Ticker::Unref(m_camera);
89    Ticker::Unref(m_URO);
90        Ticker::Unref(m_Character);
91}
92
93int main(int argc, char **argv)
94{
95    Application app("ToukyDemo", ivec2(800, 600), 60.0f);
96
97#if defined _MSC_VER && !defined _XBOX
98    _chdir("..");
99#elif defined _WIN32 && !defined _XBOX
100    _chdir("../..");
101#endif
102
103    new ToukyDemo(argc > 1);
104    app.ShowPointer(false);
105
106    app.Run();
107
108    return EXIT_SUCCESS;
109}
110
Note: See TracBrowser for help on using the repository browser.