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 | |
---|
41 | using namespace std; |
---|
42 | using namespace lol; |
---|
43 | |
---|
44 | #include "neercs.h" |
---|
45 | #include "video/render.h" |
---|
46 | |
---|
47 | Neercs::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 | |
---|
56 | void Neercs::TickGame(float seconds) |
---|
57 | { |
---|
58 | WorldEntity::TickGame(seconds); |
---|
59 | |
---|
60 | m_time += seconds; |
---|
61 | |
---|
62 | /* draw something */ |
---|
63 | caca_set_color_argb(m_caca, 0xfff, 0x222); |
---|
64 | caca_clear_canvas(m_caca); |
---|
65 | |
---|
66 | 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), '|'); |
---|
67 | 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), ' '); |
---|
68 | |
---|
69 | caca_set_color_argb(m_caca, 0xcef, 0x222); |
---|
70 | int x1 = 12 + 10 * lol::cos(m_time * 5.f); |
---|
71 | int y1 = 6 + 5 * lol::sin(m_time * 5.f); |
---|
72 | int x2 = 30 + 5 * lol::cos(m_time * 8.f); |
---|
73 | int y2 = 8 + 5 * lol::sin(m_time * 8.f); |
---|
74 | int y3 = 8 + 5 * lol::cos(m_time * 5.f); |
---|
75 | caca_draw_thin_line(m_caca, x1, y1, x2, y2); |
---|
76 | caca_draw_thin_line(m_caca, 40, y3, x2, y2); |
---|
77 | caca_draw_thin_line(m_caca, x1, y1, 40, y3); |
---|
78 | |
---|
79 | int x3 = 13 + 7 * lol::cos(m_time * 3.f); |
---|
80 | caca_set_color_ansi(m_caca, CACA_CYAN, CACA_BLUE); |
---|
81 | caca_put_str(m_caca, x3, 3, " LOL WUT "); |
---|
82 | |
---|
83 | int x4 = 6 + 5 * lol::cos(m_time * 2.f); |
---|
84 | caca_set_color_ansi(m_caca, CACA_YELLOW, CACA_RED); |
---|
85 | caca_put_str(m_caca, x4, 25, "Le Caca C'Est Surpuissant \\:D/"); |
---|
86 | |
---|
87 | caca_put_str(m_caca, 0, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
---|
88 | caca_put_str(m_caca, 0, 1, " !\"#$%&'()*+,-./0123456789"); |
---|
89 | } |
---|
90 | |
---|
91 | void Neercs::TickDraw(float seconds) |
---|
92 | { |
---|
93 | WorldEntity::TickDraw(seconds); |
---|
94 | } |
---|
95 | |
---|
96 | Neercs::~Neercs() |
---|
97 | { |
---|
98 | Ticker::Unref(m_render); |
---|
99 | } |
---|
100 | |
---|
101 | int main(int argc, char **argv) |
---|
102 | { |
---|
103 | Application app("Neercs", ivec2(800, 600), 60.0f); |
---|
104 | |
---|
105 | #if defined _MSC_VER && !defined _XBOX |
---|
106 | _chdir(".."); |
---|
107 | #elif defined _WIN32 && !defined _XBOX |
---|
108 | _chdir("../.."); |
---|
109 | #endif |
---|
110 | |
---|
111 | new Neercs(); |
---|
112 | new DebugFps(5, 5); |
---|
113 | app.ShowPointer(false); |
---|
114 | |
---|
115 | app.Run(); |
---|
116 | |
---|
117 | return EXIT_SUCCESS; |
---|
118 | } |
---|
119 | |
---|