Project

General

Profile

Revision 231

shooting things, bit laggy, cause mostly known, to be fixed

View differences:

proj.c
23 23
#include "shooter.h"
24 24
#include "pistol.h"
25 25
#include "nothing.h"
26
#include "bullet.h"
26
//#include "bullet.h"
27 27
#include "map1.h"
28 28

  
29 29
#include "list.h"
......
143 143
        gunner_set_pos(shooter1, 75, 75);
144 144

  
145 145
        gunner_t *shooter2 = gunner_ctor(bsp_shooter, bsp_nothing);
146
        gunner_set_pos(shooter2, -50, -50);
146
        gunner_set_pos(shooter2, 775, 75);
147 147

  
148
        bullet_t *bullet = bullet_ctor(get_bullet(), 400.0, 400.0, 2.0, -1.0);
148
        //bullet_t *bullet = bullet_ctor(get_bullet(), 400.0, 400.0, 2.0, -1.0);
149 149

  
150
        list_t *bullet_list = list_ctor();
151

  
150 152
        ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
151 153
                       gunner_get_y(shooter1)-ent_get_YLength()/2.0);
152 154

  
153 155
        uint32_t refresh_count_value = sys_hz() / REFRESH_RATE;
156

  
157
        uint8_t last_lb = 0;
154 158
    #endif
155 159

  
156 160
    /// loop stuff
......
180 184
                                if (no_interrupts % refresh_count_value == 0) {
181 185
                                    update_movement(map1, shooter1);
182 186
                                    //bullet_update_movement(bullet);
187
                                    update_game_state(map1, shooter2, bullet_list);
183 188

  
184 189
                                    if(map_collides_gunner(map1, shooter1)){
185 190
                                        printf("COLLIDING\n");
186 191
                                    }
187 192

  
188
                                    if (gunner_collides_bullet(shooter1, bullet)) {
193
                                    /*if (gunner_collides_bullet(shooter1, bullet)) {
189 194
                                        printf("Bullet Collide with Shooter\n");
190 195
                                        gunner_set_curr_health(shooter1, gunner_get_curr_health(shooter1) - bullet_get_damage(bullet));
191
                                    }
196
                                    }*/
192 197

  
193 198
                                    update_scale();
194 199

  
......
205 210
                                    map_draw   (map1);
206 211
                                    gunner_draw(shooter2);
207 212
                                    gunner_draw(shooter1);
208
                                    bullet_draw(bullet);
213
                                    bullet_draw_list(bullet_list);
209 214

  
210 215
                                    t = clock()-t; //printf("%d\n", (t*1000)/CLOCKS_PER_SEC);
211 216

  
......
216 221
                            if (i == 12) {
217 222
                                if (counter_mouse_ih >= 3) {
218 223
                                    struct packet pp = mouse_parse_packet(packet_mouse_ih);
219
                                    update_mouse_position(&pp);
224
                                    update_mouse(&pp);
220 225
                                    //printf("X: %d Y: %d\n", get_mouse_X(), get_mouse_Y());
221 226
                                    counter_mouse_ih = 0;
227

  
228
                                    if (last_lb ^ get_key_presses()->lb_pressed && get_key_presses()->lb_pressed) {
229
                                        shoot_bullet(shooter1, bullet_list);
230
                                    }
231

  
232
                                    last_lb = get_key_presses()->lb_pressed;
222 233
                                }
223 234
                            }
224 235
                            #endif
......
237 248
    #ifdef TELMO
238 249
        gunner_dtor(shooter1); shooter1 = NULL;
239 250
        gunner_dtor(shooter2); shooter2 = NULL;
240
        bullet_dtor(bullet); bullet = NULL;
251

  
252
        while(list_size(bullet_list) > 0){
253
            bullet_t *p = (bullet_t*)list_erase(bullet_list, list_begin(bullet_list));
254
            free(p);
255
        }
256
        if(list_dtor(bullet_list)) printf("COULD NOT DESTRUCT BULLET LIST\n");
241 257
    #endif
242 258

  
243 259
    basic_sprite_dtor      (bsp_crosshair); bsp_crosshair = NULL;

Also available in: Unified diff