Project

General

Profile

Revision 240

weird things

View differences:

proj/include/proj_func.h
12 12
 */
13 13
int cleanup(void);
14 14

  
15
void update_key_presses(void);
16

  
17
/**
18
 * @brief Updates movement variables.
19
 */
20
void update_movement(const map_t *map, list_t *shooter_list);
21

  
22 15
typedef struct keys {
23 16
    uint8_t w_pressed       : 1;
24 17
    uint8_t a_pressed       : 1;
......
30 23
    uint8_t lb_pressed      : 1;
31 24
} keys_t;
32 25

  
26
void update_key_presses(void);
27

  
28
/**
29
 * @brief Updates movement variables.
30
 */
31
void update_movement(const map_t *map, gunner_t *p, gunner_t *p2);
32

  
33 33
void update_mouse(struct packet *p);
34 34

  
35 35
keys_t* (get_key_presses)(void);
......
53 53
 */
54 54
double get_mouse_angle(gunner_t *p);
55 55

  
56
/**
57
 * @brief Get horizontal movement direction.
58
 * @return Horizontal movement direction (-1 -> heading LEFT; 0 -> not moving horizontally; 1 -> heading RIGHT)
59
 */
60
int get_hor_movement(void);
61

  
62
/**
63
 * @brief Get vertical movement direction.
64
 * @return Vertical movement direction (-1 -> heading UP; 0 -> not moving vertically; 1 -> heading DOWN)
65
 */
66
int get_ver_movement(void);
67

  
68 56
#endif /* end of include guard: PROJ_FUNC_H_INCLUDED */
proj/src/proj.c
54 54
    int r;
55 55

  
56 56
    #ifdef DIOGO
57
        /*
58 57
        uint8_t conf;
59
        if((r = util_sys_inb(0x3F8+3, &conf))) return 1; //printf("0x%02X\n", conf);
58
        if((r = util_sys_inb(0x3F8+3, &conf))) return 1; printf("0x%02X\n", conf);
60 59
        conf = 0x19; //00011001
61
        //printf("0x%02X\n", conf);
60
        printf("0x%02X\n", conf);
62 61
        if((r = sys_outb(0x3F8+3, conf))) return 1;
63
        if((r = util_sys_inb(0x3F8+3, &conf))) return 1; //printf("0x%02X\n", conf);
64
        */
62
        uint8_t s;
63
        if((r = util_sys_inb(0x3F8+3, &s))) return 1; printf("S: 0x%02X\n", s);
64
        return 0;
65

  
65 66
    #endif
66 67

  
67 68
    font_t *consolas = font_ctor("/home/lcom/labs/proj/media/font/Consolas/xpm2");
......
231 232
                            #ifdef TELMO
232 233
                            if (i == 0) {
233 234
                                if (no_interrupts % refresh_count_value == 0) {
234
                                    //update_movement(map1, shooter_list);
235
                                    update_movement(map1, shooter1, shooter2);
235 236
                                    //bullet_update_movement(bullet);
236 237

  
237 238
                                    if (no_interrupts % 180 == 0) gunner_set_pos(shooter2, 775, 75);
proj/src/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