summaryrefslogtreecommitdiff
path: root/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'source/core')
-rw-r--r--source/core/core.c64
1 files changed, 38 insertions, 26 deletions
diff --git a/source/core/core.c b/source/core/core.c
index fffcb47..f9d062a 100644
--- a/source/core/core.c
+++ b/source/core/core.c
@@ -69,53 +69,65 @@ int main()
69 XMapWindow(MainDisplay, window); 69 XMapWindow(MainDisplay, window);
70 XEvent event; 70 XEvent event;
71 71
72 f32 DELTA = 2.5;
73
72 u32 rect_width = 50; 74 u32 rect_width = 50;
73 u32 rect_height = 50; 75 u32 rect_height = 50;
76
74 i32 rect_x_position = p.width / 2; 77 i32 rect_x_position = p.width / 2;
75 i32 rect_y_position = p.height / 2; 78 i32 rect_y_position = p.height / 2;
76 79
77 u64 color = 0x0000ff00; 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;
78 84
79 GC gc = XCreateGC(MainDisplay, window, 0, NIL); 85 GC gc = XCreateGC(MainDisplay, window, 0, NIL);
80 XSetForeground(MainDisplay, gc, color); 86 XSetForeground(MainDisplay, gc, color);
81 87
82 for (;running;) 88 for (;running;)
83 { 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
84 XNextEvent(MainDisplay, &event); 99 XNextEvent(MainDisplay, &event);
85 KeySym keysym = XLookupKeysym(&event.xkey, 0);
86 100
87 switch (event.type) 101 switch (event.type)
88 { 102 {
89 case (KeyPress): 103 case(KeyPress):
90 { 104 {
91 if(keysym == XK_h) rect_x_position -= 20; 105
92 else if(keysym == XK_l) rect_x_position += 20; 106 KeySym keysym = XLookupKeysym(&event.xkey, 0);
93 else if(keysym == XK_k) 107 //- handle user movement
94 {
95 rect_y_position -= 20;
96 }
97 else if(keysym == XK_j)
98 { 108 {
99 rect_y_position += 20; 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;
100 } 115 }
101 else if(keysym == XK_s)
102 {
103 116
104 } 117 //- draw entities
105 else if(keysym == XK_Escape || keysym == XK_q) goto exit; 118 {
119 XClearWindow(MainDisplay, window);
106 120
107 XClearWindow(MainDisplay, window); 121 //--
108 XDrawRectangle(MainDisplay, window, gc, rect_x_position, rect_y_position, 50, 50); 122 XDrawRectangle(MainDisplay, window, gc, rect_x_position, rect_y_position, 50, 50);
109 XFillRectangle(MainDisplay, window, gc, rect_x_position, rect_y_position, 50, 50); 123 XFillRectangle(MainDisplay, window, gc, rect_x_position, rect_y_position, 50, 50);
110 124
111 break; 125 //--
112 } 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 }
113 default: 130 default:
114 {
115
116
117 }
118
119 } 131 }
120 } 132 }
121exit: 133exit: