Project

General

Profile

Revision 240

weird things

View differences:

proj_func.c
25 25
    return r;
26 26
}
27 27

  
28
static int hor_mov = REST, ver_mov = REST;
29 28
static keys_t key_presses;
30 29

  
31 30
void update_key_presses(void) {
......
47 46
        case MINUS_BREAK_CODE   : key_presses.minus_pressed = 0;        break;
48 47
        }
49 48
    }
50
    ver_mov = key_presses.s_pressed - key_presses.w_pressed;
51
    hor_mov = key_presses.d_pressed - key_presses.a_pressed;
52 49
}
53
/*
54
void update_movement(const map_t *map, list_t *shooter_list){
55
    list_node_t *it1 = list_begin(shooter_list);
56
    while(it1 != list_end(shooter_list)){
57
        double x = gunner_get_x(p);
58
        double y = gunner_get_y(p);
59
        gunner_set_pos(p, x + SHOOTER_SPEED * hor_mov, y);
60
        if (map_collides_gunner(map, p) || gunner_collides_gunner(p, p2)) {
61
            gunner_set_pos(p, x, y);
62
        }
50

  
51

  
52
void update_movement(const map_t *map, gunner_t *p, gunner_t *p2) {
53
    int ver_mov = key_presses.s_pressed - key_presses.w_pressed;
54
    int hor_mov = key_presses.d_pressed - key_presses.a_pressed;
55
    double x = gunner_get_x(p);
56
    double y = gunner_get_y(p);
57
    gunner_set_pos(p, x + SHOOTER_SPEED * hor_mov, y);
58
    if (map_collides_gunner(map, p) || gunner_collides_gunner(p, p2)) {
59
        gunner_set_pos(p, x, y);
60
    }
63 61
        x = gunner_get_x(p);
64
        gunner_set_pos(p, x, y + SHOOTER_SPEED * ver_mov);
65
        if (map_collides_gunner(map, p) || gunner_collides_gunner(p, p2)) {
66
            gunner_set_pos(p, x, y);
67
        }
62
    gunner_set_pos(p, x, y + SHOOTER_SPEED * ver_mov);
63
    if (map_collides_gunner(map, p) || gunner_collides_gunner(p, p2)) {
64
        gunner_set_pos(p, x, y);
68 65
    }
69 66
}
70
*/
67

  
71 68
void (shoot_bullet)(const gunner_t *shooter, list_t *bullet_list, const basic_sprite_t *bsp_bullet) {
72 69
    double angle = gunner_get_angle(shooter);
73 70
    double vx = -BULLET_SPEED * fm_sin(angle);
......
162 159
double get_mouse_angle(gunner_t *p) {
163 160
    return atan2(gunner_get_y_screen(p) - mouse_y, mouse_x - gunner_get_x_screen(p));
164 161
}
165

  
166
int get_hor_movement(void) { return hor_mov; }
167

  
168
int get_ver_movement(void) { return ver_mov; }

Also available in: Unified diff