compilation - C segmentation fault with methods -
i trying work setup_diamond()
, draw_game()
functions , keep getting segmentation fault. have literally no idea why i'm having error, far aware, being stored correctly , initialized.
//function preparing diamonds void setup_diamond() { //for loop, size of number of max diamonds (int = 0; < max_bd; i++){ //creates array stores values diamond x values rand_x_value[i] = rand() % (screen_width()-bd_width); //creates 10 big diamonds based on rand angle bdiamond[i] = sprite_create( rand_x_value[i], 3, bd_width, bd_height, bdiamond_image ); //creates random angle saved in array randangle[i] = rand() % 360; //set's diamonds speeds 0.1 sprite_turn_to (bdiamond[i], 0.1, 0); //points diamond in random direction saved in array sprite_turn (bdiamond[i], randangle[i] ); //draws diamond sprite_draw (bdiamond[i] ); //creates 20 medium sized diamonds (int q = 0; q <= 20; q++){ ldiamond[q] = sprite_create(-5, -5, ld_height , ld_height, ldiamond_image); } //creates 40 small diamonds (int k = 0; k <= 40; k++){ mdiamond[k] = sprite_create(-3, -3, md_width , md_height, mdiamond_image); } } } void draw_game() { clear_screen(); draw_border(); sprite_draw ( ship ); (int = 0; < max_bd; i++ ) { sprite_draw(bdiamond[i] ); } for( int = 0; <= max_bullet; i++){ sprite_step(bullet[i]); sprite_draw(bullet[i]); } //creates 20 medium diamonds @ offscreen position ready use when diamonds split for( int k = 0; k <= max_md; k++){ sprite_step(mdiamond[k]); sprite_draw(mdiamond[k]); } //creates 40 small diamonds off screen for( int q = 0; q <= max_ld; q++){ sprite_step(ldiamond[q]); sprite_draw(ldiamond[q]); } }
there link source folder here
it includes code (in 'c') , library folder. compiling using cygwin.
Comments
Post a Comment