summaryrefslogtreecommitdiff
path: root/source/core/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/core/core.c')
-rw-r--r--source/core/core.c136
1 files changed, 0 insertions, 136 deletions
diff --git a/source/core/core.c b/source/core/core.c
deleted file mode 100644
index f9d062a..0000000
--- a/source/core/core.c
+++ /dev/null
@@ -1,136 +0,0 @@
1#define TB_IMPLEMENTATION
2#include "core.h"
3#include "../base/base_include.h"
4#include "../platform/platform_include.h"
5
6int main()
7{
8 b32 running = 1;
9
10 Display *MainDisplay = XOpenDisplay(0);
11 mem_arena *arena = arena_create(MiB(8));
12
13 Window root = XDefaultRootWindow(MainDisplay);
14 int screen = DefaultScreen(MainDisplay);
15
16 Visual *v = DefaultVisual(MainDisplay, screen);
17
18 XSetWindowAttributes wa = {
19 .background_pixmap = None,
20 .background_pixel = BlackPixel(MainDisplay, DefaultScreen(MainDisplay)),
21 .border_pixmap = CopyFromParent,
22 .border_pixel = 0,
23 .bit_gravity = ForgetGravity,
24 .win_gravity = NorthWestGravity,
25 .backing_store = NotUseful,
26 .backing_planes = 1,
27 .backing_pixel = 0,
28 .save_under = False,
29 .event_mask = 0,
30 .do_not_propagate_mask = 0,
31 .override_redirect = False,
32 .colormap = CopyFromParent,
33 .cursor = None
34 };
35
36 i32 dp_heigth = DisplayHeight(MainDisplay, screen);
37 i32 dp_width = DisplayWidth(MainDisplay, screen);
38
39 WindowProperties p = {
40
41 .x = dp_width / 2,
42 .y = dp_heigth / 2,
43 .height = (u32)800,
44 .width = (u32)1200,
45 .border_width = 0,
46 .window_depth = CopyFromParent,
47 .window_class = CopyFromParent,
48 .value_mask = CWBackPixel,
49
50 };
51
52 Window window =
53 XCreateWindow(
54 MainDisplay,
55 root,
56 p.x,
57 p.y,
58 p.width,
59 p.height,
60 p.border_width,
61 p.window_depth,
62 p.window_class,
63 v,
64 p.value_mask,
65 &wa);
66
67 XSetWindowBorder(MainDisplay, window, 60);
68 XSelectInput(MainDisplay, window, ExposureMask | StructureNotifyMask | KeyReleaseMask | KeyPressMask);
69 XMapWindow(MainDisplay, window);
70 XEvent event;
71
72 f32 DELTA = 2.5;
73
74 u32 rect_width = 50;
75 u32 rect_height = 50;
76
77 i32 rect_x_position = p.width / 2;
78 i32 rect_y_position = p.height / 2;
79
80 i32 rect_enemy_x_position = (p.width / 2) + 300;
81 i32 rect_enemy_y_position = (p.height / 2) + 300;
82
83 u64 color = 0x0FF0FF00;
84
85 GC gc = XCreateGC(MainDisplay, window, 0, NIL);
86 XSetForeground(MainDisplay, gc, color);
87
88 for (;running;)
89 {
90 //- handle enemy movement
91 {
92 if(rect_enemy_x_position < rect_x_position) rect_enemy_x_position += DELTA*0.5;
93 if(rect_enemy_y_position < rect_y_position) rect_enemy_y_position += DELTA*0.5;
94
95 if(rect_enemy_x_position > rect_x_position) rect_enemy_x_position -= DELTA*0.5;
96 if(rect_enemy_y_position > rect_y_position) rect_enemy_y_position -= DELTA*0.5;
97 }
98
99 XNextEvent(MainDisplay, &event);
100
101 switch (event.type)
102 {
103 case(KeyPress):
104 {
105
106 KeySym keysym = XLookupKeysym(&event.xkey, 0);
107 //- handle user movement
108 {
109 if(keysym == XK_h) rect_x_position -= DELTA*1.2;
110 else if(keysym == XK_l) rect_x_position += DELTA*1.2;
111 else if(keysym == XK_k) rect_y_position -= DELTA*1.2;
112 else if(keysym == XK_j) rect_y_position += DELTA*1.2;
113 else if(keysym == XK_s);
114 else if(keysym == XK_Escape || keysym == XK_q) goto exit;
115 }
116
117 //- draw entities
118 {
119 XClearWindow(MainDisplay, window);
120
121 //--
122 XDrawRectangle(MainDisplay, window, gc, rect_x_position, rect_y_position, 50, 50);
123 XFillRectangle(MainDisplay, window, gc, rect_x_position, rect_y_position, 50, 50);
124
125 //--
126 XDrawRectangle(MainDisplay, window, gc, rect_enemy_x_position, rect_y_position, 50, 50);
127 XFillRectangle(MainDisplay, window, gc, rect_enemy_x_position, rect_y_position, 50, 50);
128 } break;
129 }
130 default:
131 }
132 }
133exit:
134 arena_clear(arena);
135 return 0;
136}