Revision 167
some changes
proj_func.c | ||
---|---|---|
1 |
#include <lcom/lcf.h> |
|
2 |
|
|
1 | 3 |
#include "proj_func.h" |
4 |
|
|
2 | 5 |
#include "interrupts_func.h" |
3 | 6 |
#include "graph.h" |
7 |
#include "keyboard.h" |
|
4 | 8 |
#include "errors.h" |
9 |
#include "proj_macros.h" |
|
10 |
#include "utils.h" |
|
5 | 11 |
|
6 |
#include <lcom/lcf.h>
|
|
12 |
#include "kbc_macros.h"
|
|
7 | 13 |
|
14 |
#include <math.h> |
|
15 |
|
|
8 | 16 |
int cleanup(void) { |
9 | 17 |
int r = SUCCESS; |
10 | 18 |
if ((r = unsubscribe_all())) |
... | ... | |
14 | 22 |
|
15 | 23 |
return r; |
16 | 24 |
} |
25 |
|
|
26 |
static int hor_mov = REST, ver_mov = REST; |
|
27 |
|
|
28 |
void update_movement(void) { |
|
29 |
static int w_pressed = 0, a_pressed = 0, s_pressed = 0, d_pressed = 0; |
|
30 |
if (sz == 1) { |
|
31 |
kbd_print_scancode(!(scancode[0] & BREAK_CODE_BIT), 1, scancode); |
|
32 |
switch(scancode[0]) { |
|
33 |
case W_MAKE_CODE : w_pressed = 1; break; |
|
34 |
case W_BREAK_CODE : w_pressed = 0; break; |
|
35 |
case A_MAKE_CODE : a_pressed = 1; break; |
|
36 |
case A_BREAK_CODE : a_pressed = 0; break; |
|
37 |
case S_MAKE_CODE : s_pressed = 1; break; |
|
38 |
case S_BREAK_CODE : s_pressed = 0; break; |
|
39 |
case D_MAKE_CODE : d_pressed = 1; break; |
|
40 |
case D_BREAK_CODE : d_pressed = 0; break; |
|
41 |
} |
|
42 |
} |
|
43 |
ver_mov = s_pressed - w_pressed; |
|
44 |
hor_mov = d_pressed - a_pressed; |
|
45 |
} |
|
46 |
|
|
47 |
double get_mouse_angle(sprite_t *p, int32_t mouse_x, int32_t mouse_y) { |
|
48 |
return atan2(sprite_get_y(p) - mouse_y, mouse_x - sprite_get_x(p)); |
|
49 |
} |
|
50 |
|
|
51 |
int get_hor_movement(void) { return hor_mov; } |
|
52 |
|
|
53 |
int get_ver_movement(void) { return ver_mov; } |
Also available in: Unified diff