Project

General

Profile

Revision 222

more collisions

View differences:

proj/include/proj_func.h
17 17
/**
18 18
 * @brief Updates movement variables.
19 19
 */
20
void update_movement(gunner_t *p);
20
void update_movement(const map_t *map, gunner_t *p);
21 21

  
22 22
typedef struct keys {
23 23
    uint8_t w_pressed       : 1;
proj/src/proj.c
114 114
        ent_set_scale(DEFAULT_SCALE);
115 115

  
116 116
        gunner_t *shooter1 = gunner_ctor(bsp_shooter, bsp_pistol); if(shooter1 == NULL) printf("Failed to get shooter1\n");
117
        gunner_set_pos(shooter1, 0, 0);
117
        gunner_set_pos(shooter1, 75, 75);
118 118

  
119 119
        gunner_t *shooter2 = gunner_ctor(bsp_shooter, bsp_nothing);
120 120
        gunner_set_pos(shooter2, -50, -50);
......
153 153
                            #ifdef TELMO
154 154
                            if (i == 0) {
155 155
                                if (no_interrupts % refresh_count_value == 0) {
156
                                    update_movement(shooter1);
156
                                    update_movement(map1, shooter1);
157 157

  
158 158
                                    if(map_collides_gunner(map1, shooter1)){
159 159
                                        printf("COLLIDING\n");
......
176 176
                                    gunner_draw(shooter1);
177 177
                                    bullet_draw(bullet);
178 178

  
179
                                    t = clock()-t; printf("%d\n", (t*1000)/CLOCKS_PER_SEC);
179
                                    t = clock()-t; //printf("%d\n", (t*1000)/CLOCKS_PER_SEC);
180 180

  
181 181
                                    sprite_draw(sp_crosshair);
182 182
                                    graph_draw();
proj/src/proj_func.c
50 50
    hor_mov = key_presses.d_pressed - key_presses.a_pressed;
51 51
}
52 52

  
53
void update_movement(gunner_t *p) {
53
void update_movement(const map_t *map, gunner_t *p) {
54 54
    static const int speed = 5;
55
    gunner_set_pos(p, gunner_get_x(p) + speed * hor_mov, gunner_get_y(p) + speed * ver_mov);
55
    double x = gunner_get_x(p);
56
    double y = gunner_get_y(p);
57
    gunner_set_pos(p, x + speed * hor_mov, y + speed * ver_mov);
58
    if (map_collides_gunner(map, p)) {
59
        gunner_set_pos(p, x, y);
60
    }
56 61
}
57 62

  
58 63
void update_scale(void) {
......
69 74
            if (scale >= MIN_SCALE) ent_set_scale(scale);
70 75
        }
71 76

  
72
        printf("SCALE: %d\n", (int)(ent_get_scale()*1000));
77
        //printf("SCALE: %d\n", (int)(ent_get_scale()*1000));
73 78
    }
74 79

  
75 80
    last_plus = key_presses.plus_pressed;

Also available in: Unified diff