Project

General

Profile

Revision 171

crosshair and mouse (not working yet)

View differences:

proj_func.c
28 28
void update_movement(void) {
29 29
    static int w_pressed = 0, a_pressed = 0, s_pressed = 0, d_pressed = 0;
30 30
    if (sz == 1) {
31
        kbd_print_scancode(!(scancode[0] & BREAK_CODE_BIT), 1, scancode);
32 31
        switch(scancode[0]) {
33 32
        case W_MAKE_CODE  : w_pressed = 1;      break;
34 33
        case W_BREAK_CODE : w_pressed = 0;      break;
......
44 43
    hor_mov = d_pressed - a_pressed;
45 44
}
46 45

  
47
double get_mouse_angle(sprite_t *p, int32_t mouse_x, int32_t mouse_y) {
46
static int32_t mouse_x = 0, mouse_y = 0;
47

  
48
void update_mouse_position(struct packet *p) {
49
    mouse_x = max(0, mouse_x + p->delta_x);
50
    mouse_x = min(mouse_x, graph_get_XRes() - 1);
51

  
52
    mouse_y = max(0, mouse_y + p->delta_y);
53
    mouse_y = min(mouse_y, graph_get_YRes() - 1);
54
}
55

  
56
int32_t get_mouse_X(void) { return mouse_x; }
57

  
58
int32_t get_mouse_Y(void) { return mouse_y; }
59

  
60
double get_mouse_angle(sprite_t *p) {
48 61
    return atan2(sprite_get_y(p) - mouse_y, mouse_x - sprite_get_x(p));
49 62
}
50 63

  

Also available in: Unified diff