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

Last change on this file since 1645 was 1645, checked in by sam, 8 years ago

core: switch the Win32/x64 binaries to the Windows subsystem so that they
do not open a console at startup.

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