source: trunk/neercs/neercs.cpp @ 1513

Last change on this file since 1513 was 1513, checked in by sam, 9 years ago

core: replace usage of sin() or std::sin() with lol::sin() where appropriate.

File size: 2.8 KB
Line 
1//
2// Neercs
3//
4// Copyright: (c) 2012 Sam Hocevar <sam@hocevar.net>
5//
6
7#if defined HAVE_CONFIG_H
8#   include "config.h"
9#endif
10
11#if defined _WIN32
12#   include <direct.h>
13#endif
14
15#if defined _XBOX
16#   define _USE_MATH_DEFINES /* for M_PI */
17#   include <xtl.h>
18#   undef near /* Fuck Microsoft */
19#   undef far /* Fuck Microsoft again */
20#elif defined _WIN32
21#   define _USE_MATH_DEFINES /* for M_PI */
22#   define WIN32_LEAN_AND_MEAN
23#   include <windows.h>
24#   undef near /* Fuck Microsoft */
25#   undef far /* Fuck Microsoft again */
26#else
27#   include <cmath>
28#endif
29
30#if USE_SDL && defined __APPLE__
31#   include <SDL_main.h>
32#endif
33
34#include <time.h>
35
36#include <caca.h>
37
38#include "core.h"
39#include "loldebug.h"
40
41using namespace std;
42using namespace lol;
43
44#include "neercs.h"
45#include "video/render.h"
46
47Neercs::Neercs()
48  : m_ready(false),
49    m_caca(caca_create_canvas(47, 32)),
50    m_render(new Render(m_caca)),
51    m_time(0.f)
52{
53    Ticker::Ref(m_render);
54}
55
56void Neercs::TickGame(float seconds)
57{
58    WorldEntity::TickGame(seconds);
59
60    m_time += seconds;
61
62    caca_set_color_ansi(m_caca, CACA_DEFAULT, CACA_DEFAULT);
63    caca_clear_canvas(m_caca);
64
65    caca_fill_ellipse(m_caca, 20+10 * lol::cos(m_time * 1.f), 10+10 * lol::sin(m_time * 1.f), 16+8 * lol::sin(m_time * 6.f), 12+6 * lol::cos(m_time * 5.f), '|');
66    caca_fill_ellipse(m_caca, 20+10 * lol::cos(m_time * 1.f), 10+10 * lol::sin(m_time * 1.f), 12+8 * lol::sin(m_time * 6.f), 8+6 * lol::cos(m_time * 5.f), ' ');
67
68    caca_set_color_ansi(m_caca, 2, CACA_DEFAULT);
69    int x1 = 12 + 10 * lol::cos(m_time * 5.f);
70    int y1 = 6 + 5 * lol::sin(m_time * 5.f);
71    int x2 = 30 + 5 * lol::cos(m_time * 8.f);
72    int y2 = 8 + 5 * lol::sin(m_time * 8.f);
73    int y3 = 8 + 5 * lol::cos(m_time * 5.f);
74    caca_draw_thin_line(m_caca, x1, y1, x2, y2);
75    caca_draw_thin_line(m_caca, 40, y3, x2, y2);
76    caca_draw_thin_line(m_caca, x1, y1, 40, y3);
77
78    int x3 = 13 + 7 * lol::cos(m_time * 3.f);
79    caca_set_color_ansi(m_caca, CACA_CYAN, CACA_BLUE);
80    caca_put_str(m_caca, x3, 3, " LOL WUT ");
81
82    int x4 = 6 + 5 * lol::cos(m_time * 2.f);
83    caca_set_color_ansi(m_caca, CACA_YELLOW, CACA_RED);
84    caca_put_str(m_caca, x4, 25, "Le Caca C'Est Surpuissant \\:D/");
85
86    caca_put_str(m_caca, 0, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
87    caca_put_str(m_caca, 0, 1, " !\"#$%&'()*+,-./0123456789");
88
89    if (Input::GetButtonState(27 /*SDLK_ESCAPE*/))
90        Ticker::Shutdown();
91
92}
93
94void Neercs::TickDraw(float seconds)
95{
96    WorldEntity::TickDraw(seconds);
97}
98
99Neercs::~Neercs()
100{
101    Ticker::Unref(m_render);
102}
103
104int main(int argc, char **argv)
105{
106    Application app("Neercs", ivec2(800, 600), 60.0f);
107
108#if defined _MSC_VER && !defined _XBOX
109    _chdir("..");
110#elif defined _WIN32 && !defined _XBOX
111    _chdir("../..");
112#endif
113
114    new Neercs();
115    new DebugFps(5, 5);
116    app.ShowPointer(false);
117
118    app.Run();
119
120    return EXIT_SUCCESS;
121}
122
Note: See TracBrowser for help on using the repository browser.