void my_keyboard( unsigned char key, int x, int y ) { switch( key ) { case 'q': case 'Q': exit(0) ; break ; case '+': case '=': { cur_quantity++; printf("quantity is %d\n", cur_quantity); } break; case '-': case '_': { cur_quantity--; printf("quantity is %d\n", cur_quantity); } break; case '1': { make_explosion(&explosions[0], 1000, 1, 64, .02, 1, test_sound, (&nozzles[0])->x, (&nozzles[0])->y + 1); break; } case '2': { make_explosion(&explosions[1], 200, 1, 200, .01, 1, test_sound, (&nozzles[1])->x, (&nozzles[1])->y + 1); break; } case '3': { make_explosion(&explosions[2], 350, 1, 250, .05, 1, test_sound, (&nozzles[2])->x, (&nozzles[2])->y + 1); break; } case '4': { make_explosion(&explosions[3], 1000, 1, cur_quantity, .05, 1, test_sound, (&nozzles[3])->x, (&nozzles[3])->y + 1); break; } case '5': { make_explosion(&explosions[4], 1500, 1, 1000, .1, 1, test_sound, (&nozzles[4])->x, (&nozzles[4])->y + 1); break; } case '6': { make_explosion(&explosions[5], 600, 1, 30, .09, 1, test_sound, (&nozzles[5])->x, (&nozzles[5])->y + 1); break; } case '7': { make_explosion(&explosions[6], 2500, 1, 400, .3, 1, test_sound, (&nozzles[6])->x, (&nozzles[6])->y + 1); break; } default: break; } glutPostRedisplay(); }
void W_FireBigAss ( ) { vec3_t dir, vtemp; if ( self->s.v.ammo_shells < 10 ) { make_explosion ( ); // G_sprint (self, 2, "Ammo chamber jammed!\n"); // I just don't like excess messages sound ( self, 1, "weapons/asscan4.wav", 1, 1 ); stuffcmd ( self, "bf\n" ); self->option4 = 0; return; } self->nojumptime = ( g_globalvars.time + 0.75 ); // stops the 10.30.98 20mm speed "bug" // "weapons/sgun1.wav" was the old sound, this is 11.11.04's sound sound( self, 1, "weapons/20mm.wav", 1, 1 ); KickPlayer( -5, self ); muzzleflash( ); stuffcmd (self, "bf\n"); // self.ammo_shells = (self.ammo_shells - 10); // self.currentammo = (self.ammo_shells - 10); //self->s.v.currentammo = self->s.v.ammo_shells - 10; self->s.v.ammo_shells = self->s.v.ammo_shells - 10; self->s.v.currentammo = self->s.v.ammo_shells; makevectors( self->s.v.v_angle ); dir[0] = g_globalvars.v_forward[0];dir[1] = g_globalvars.v_forward[1];dir[2] = g_globalvars.v_forward[2]; mtf_deathmsg( 46 ); BigAssBullet( dir, 50 ); EjectShell ( ); //self->s.v.velocity = (self.velocity - (v_forward * 200)); VectorScale( g_globalvars.v_forward, 200, vtemp ); VectorSubtract( self->s.v.velocity, vtemp, vtemp ); self->s.v.velocity[0] = vtemp[0]; self->s.v.velocity[1] = vtemp[1]; if ( vtemp[2] > 179.9 && self->s.v.button2 ) vtemp[2] = vtemp[2] * 2.1; // "fixes" 20mm jump when facing down self->s.v.velocity[2] = vtemp[2]; if ( self->s.v.ammo_shells == 0 ) self->s.v.ammo_shells = 1; }
/* Purpose: animate the enemy missiles and the lines following them Input : a missile struct, an explosion struct, and the clock Returns: nothing, but updates the missiles current position, and updates the explosion if necessary Assume : nothing */ void processEnemyMissiles(struct missile *mis, struct explosion *exp, long clock,int speed){ if ((*mis).shortest == -1) { calculateLine(mis); } if ((*mis).currentX < (*mis).endX || (*mis).currentX > (*mis).endX) { getPositions(mis,speed); } if ((*mis).currentX == (*mis).endX || (*mis).currentY == (*mis).endY && (*mis).endX != 0) { (*mis).destroyed = TRUE; make_explosion(exp,(*mis).endX,(*mis).endY); explosion_sound(); reset_positions(&(*mis)); } }
void my_keyboard( unsigned char key, int x, int y ) { GLfloat used_radius; GLfloat used_density; int used_quantity; GLfloat used_cube_size; int used_after_counter; int num = rand() % (NUM_SOUNDS - 2); int cur_shape = rand() % (NUM_SHAPES+1); //right now 2 0-regular 1-burst if(cur_shape){ used_radius = reg_radius; used_density = reg_density; used_quantity = reg_quantity; used_after_counter = reg_after_counter; } else{ used_radius = bur_radius; used_density = bur_density; used_quantity = bur_quantity; used_after_counter = bur_after_counter; BASS_ChannelSetAttribute(sounds[num], BASS_ATTRIB_VOL, 90); } GLfloat new_radius = (float)((rand()%41 -20)/100.)*used_radius +used_radius; GLfloat new_density = (float)((rand()%41 -20)/100.)*used_density +used_density; int new_quantity = (int)((float)(rand()%41 -20)/100.)*used_quantity +used_quantity; GLfloat new_after_counter= (float)((rand()%41 -20)/100.)*used_after_counter +used_after_counter; //GLfloat cur_cube_size = .007; switch( key ) { case 'q': case 'Q': { exit(0) ; break ; } case '+': case '=': { if (cur_variable == RADIUS) { cur_radius += 2; } if (cur_variable == DENSITY) { cur_density += 1; } if (cur_variable == QUANTITY) { cur_quantity += 5; } if (cur_variable == CUBE_SIZE) { cur_cube_size += .001; } if (cur_variable == AFTER_COUNTER) { cur_after_counter += 10; } print_cur(); } break; case 'j': { light_screen = 1; } break; case '-': case '_': { if (cur_variable == RADIUS) { cur_radius -= 2; } if (cur_variable == DENSITY) { cur_density -= 1; } if (cur_variable == QUANTITY) { cur_quantity -= 5; } if (cur_variable == CUBE_SIZE) { cur_cube_size -= .001; } if (cur_variable == AFTER_COUNTER) { cur_after_counter -= 10; } print_cur(); } break; case 'z': { music_playing = (music_playing + 1) % 2; if (music_playing) { BASS_ChannelPlay(sounds[8], FALSE); } else { BASS_ChannelPause(sounds[8]); } } break; case 'a': case 'A': { cur_variable = RADIUS; print_cur(); } break; case 's': case 'S': { cur_variable = DENSITY; print_cur(); } break; case 'd': case 'D': { cur_variable = QUANTITY; print_cur(); } break; case 'f': case 'F': { cur_variable = CUBE_SIZE; print_cur(); } break; case 'g': case 'G': { cur_variable = AFTER_COUNTER; print_cur(); } break; case '1': { make_explosion(&explosions[num_fireworks = (num_fireworks + 1 )% MAX_FIREWORKS], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[0])->x, (&nozzles[0])->y + 1.2); //make_explosion(&explosions[0], 60, 1, 5000, .02, 48, 1, test_sound, (&nozzles[0])->x, (&nozzles[0])->y + 1); BASS_ChannelPlay(sounds[cur_shape], TRUE); break; } case '2': { make_explosion(&explosions[num_fireworks = (num_fireworks + 1 )% MAX_FIREWORKS], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[1])->x, (&nozzles[1])->y + 1.2); //make_explosion(&explosions[1], 500, 1, 100, .01, 1100, 1, test_sound, (&nozzles[1])->x, (&nozzles[1])->y + 1); BASS_ChannelPlay(sounds[cur_shape], TRUE); break; } case '3': { make_explosion(&explosions[num_fireworks = (num_fireworks + 1 )% MAX_FIREWORKS], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[2])->x, (&nozzles[2])->y + 1.2); //make_explosion(&explosions[2], 6MAX_FIREWORKS, 1, 100, .05, 800, 1, test_sound, (&nozzles[2])->x, (&nozzles[2])->y + 1); BASS_ChannelPlay(sounds[cur_shape], TRUE); break; } case '4': { if(cur_shape){ if(cur_shape ==1){ new_radius *=1.5; new_quantity *=1.2; } } make_explosion(&explosions[num_fireworks = (num_fireworks + 1 )% MAX_FIREWORKS], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[3])->x, (&nozzles[3])->y + 1.2); //make_explosion(&explosions[3], 1000, 1, 100, .05, 900, 1, test_sound, (&nozzles[3])->x, (&nozzles[3])->y + 1); BASS_ChannelPlay(sounds[cur_shape], TRUE); break; } case '5': { make_explosion(&explosions[num_fireworks = (num_fireworks + 1 )% MAX_FIREWORKS], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[4])->x, (&nozzles[4])->y + 1.2); //make_explosion(&explosions[4], 1MAX_FIREWORKS0, 1, 100, .1, 1000, 1, test_sound, (&nozzles[4])->x, (&nozzles[4])->y + 1); BASS_ChannelPlay(sounds[cur_shape], TRUE); break; } case '6': { make_explosion(&explosions[num_fireworks = (num_fireworks + 1 )% MAX_FIREWORKS], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[5])->x, (&nozzles[5])->y + 1.2); //make_explosion(&explosions[5], 600, 1, 100, .09, 1100, 1, test_sound, (&nozzles[5])->x, (&nozzles[5])->y + 1); BASS_ChannelPlay(sounds[cur_shape], TRUE); break; } case '7': { make_explosion(&explosions[num_fireworks = (num_fireworks + 1 )% MAX_FIREWORKS], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[6])->x, (&nozzles[6])->y + 1.2); //make_explosion(&explosions[6], 2MAX_FIREWORKS0, 1, 100, .3, 1200, 1, test_sound, (&nozzles[6])->x, (&nozzles[6])->y + 1); BASS_ChannelPlay(sounds[cur_shape], TRUE); break; } case '0': { make_explosion(&explosions[num_fireworks = (num_fireworks + 1 )% MAX_FIREWORKS], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[3])->x, (&nozzles[3])->y + 1); } break; default: break; } glutPostRedisplay(); }
void my_time_out(int id) { int i, j,k; PARTICLE *cur; EXPLOSION *cur_explosion; FUSE *curr_fuse; GLfloat nozzle_change=0; float fall_time; fall_time =(float)((rand() % (10)))/100000.; for (j = 0; j < MAX_FIREWORKS; j++) { curr_fuse = &fuses[j]; if (curr_fuse -> hangtime > 0) { for (i = 0; i < curr_fuse->trail_size; i++) { cur = &(curr_fuse -> trail[i]); if(curr_fuse->start_y==-1){ nozzle_change = (float)((rand() % (41)-20))/5000.; cur->init_color[0]=cur->init_color[0]-2250*fall_time; cur->init_color[1]=cur->init_color[1]-2250*fall_time; cur->init_color[2]=cur->init_color[2]-2250*fall_time; } else{ nozzle_change=0; } real_translation(&(cur->shape), cur->translation[0]+nozzle_change, cur->translation[1], cur->translation[2]); } if (curr_fuse -> counter < curr_fuse -> hangtime) { curr_fuse -> counter += 1; } else { int num = rand() % (NUM_SOUNDS - 2); GLfloat used_radius; GLfloat used_density; int used_quantity; GLfloat used_cube_size; int used_after_counter; int cur_shape = rand() % (NUM_SHAPES); //right now 2 0-regular 1-burst 2-heart**(needs 2 twice in a row if(cur_shape ==2){ cur_shape = rand() % (NUM_SHAPES); } if(cur_shape==1){ used_radius = reg_radius; used_density = reg_density; used_quantity = reg_quantity; used_after_counter = reg_after_counter; } else{ used_radius = bur_radius; used_density = bur_density; used_quantity = bur_quantity; used_after_counter = bur_after_counter; BASS_ChannelSetAttribute(sounds[num], BASS_ATTRIB_VOL, 90); } ////FOR INTRO TEXT if(intro_flag_1){ cur_shape =-1; } else if(intro_flag_2){ cur_shape =-2; } else if(intro_flag_3){ cur_shape =-3; } else if(intro_flag_4){ cur_shape =-4; } GLfloat test_this_shit_out = (&(cur -> shape)) -> shape_verts[1][1][1]; GLfloat new_radius = (float)((rand()%41 -20)/100.)*used_radius +used_radius; int new_quantity = (int)((float)(rand()%41 -20)/100.)*used_quantity +used_quantity; GLfloat new_after_counter= (float)((rand()%41 -20)/100.)*used_after_counter +used_after_counter; //GLfloat cur_cube_size = .007; if (curr_fuse->start_y==-1){ if((cur->init_color[0])<0.1 && (cur->init_color[1]) <0.1 && (cur->init_color[2])<0.1){ for(i=0;i<curr_fuse->trail_size;i++){ free(&(curr_fuse -> trail[i])); curr_fuse -> hangtime= 0; curr_fuse -> counter = 0; curr_fuse -> trail_size = 0; curr_fuse -> start_x = 0; curr_fuse -> start_y = 0; } } } else{ if (cur_shape == 3) { make_fuse(&fuses[cur_fuse = (cur_fuse + 1 ) % MAX_FIREWORKS], 5, colors[RED], .005, .005, 0, .004, curr_fuse -> start_x, test_this_shit_out); make_fuse(&fuses[cur_fuse = (cur_fuse + 1 ) % MAX_FIREWORKS], 5, colors[RED], -.005, .005, 0, .004, curr_fuse -> start_x, test_this_shit_out); make_fuse(&fuses[cur_fuse = (cur_fuse + 1 ) % MAX_FIREWORKS], 5, colors[RED], -.005, -.005, 0, .004, curr_fuse -> start_x, test_this_shit_out); make_fuse(&fuses[cur_fuse = (cur_fuse + 1 ) % MAX_FIREWORKS], 5, colors[RED], .005, -.005, 0, .004, curr_fuse -> start_x, test_this_shit_out); } else { make_explosion(&explosions[cur_firework = (cur_firework + 1 )% MAX_FIREWORKS], new_radius, 1, new_quantity, .007, new_after_counter, cur_shape, test_sound, curr_fuse -> start_x, test_this_shit_out, 1, 0); if(cur_shape<0){ cur_shape=(rand()%2)+1; } BASS_ChannelPlay(sounds[cur_shape], TRUE); } curr_fuse -> hangtime = -1; } } } cur_explosion = &explosions[j]; for (i = 0; i < (&explosions[j])->quantity; i++) { cur = &(cur_explosion->particles[i]); if (cur_explosion->counter < cur_explosion->radius) { if (cur -> is_sparkler != 0) { cur -> translation[0] = (float)((rand() % (10)) - 5)/180.; cur -> translation[1] = (float)((rand() % (10)) - 5)/180.; cur -> translation[2] = (float)((rand() % (10)) - 5)/180.; } real_translation(&(cur->shape), cur->translation[0], cur->translation[1], cur->translation[2]); } else { if (cur_explosion->counter > cur_explosion->radius && cur_explosion->counter < cur_explosion->radius + cur_explosion->after_counter && cur_explosion -> radius > 0) { fall_time =(float)((rand() % (10)))/100000.; real_translation(&(cur->shape), 0, -fall_time*5, 0); cur->init_color[0]=cur->init_color[0]-250*fall_time; cur->init_color[1]=cur->init_color[1]-250*fall_time; cur->init_color[2]=cur->init_color[2]-250*fall_time; if(!cur_explosion->fizz){ // BASS_ChannelPlay(sounds[7], TRUE); cur_explosion->fizz=1; } // TODO THIS IS WHERE WE WANT TO START FADING AS WELL } if (cur_explosion->counter > cur_explosion->after_counter && cur_explosion -> radius > 0) { cur_explosion->fizz=0; free(&(cur_explosion->particles[0])); cur_explosion -> radius = 0; cur_explosion -> density = 0; cur_explosion -> quantity = 0; cur_explosion -> cube_size = 0; cur_explosion -> shape = 0; cur_explosion -> counter = 0; cur_explosion -> start_x = 0; cur_explosion -> start_y = 0; cur_explosion -> after_counter = 0; } } } if (cur_explosion->radius > 0) { cur_explosion->counter += 1; } } glutPostRedisplay(); // re-draw the scene glutTimerFunc(timer_speed, my_time_out, 0); // keeps the timer moving, at timer_speed ms }
void my_keyboard( unsigned char key, int x, int y ) { int num = rand() % (NUM_SOUNDS - 2); GLfloat new_radius = (float)((rand()%41 -20)/100.)*cur_radius +cur_radius; GLfloat new_density = (float)((rand()%41 -20)/100.)*cur_density +cur_density; int new_quantity = (int)((float)(rand()%41 -20)/100.)*cur_quantity +cur_quantity; GLfloat new_after_counter= (float)((rand()%41 -20)/100.)*cur_after_counter +cur_after_counter; //GLfloat cur_cube_size = .007; int cur_shape = 1; printf("num is %d", num); switch( key ) { case 'q': case 'Q': { exit(0) ; break ; } case '+': case '=': { if (cur_variable == RADIUS) { cur_radius += 2; } if (cur_variable == DENSITY) { cur_density += 1; } if (cur_variable == QUANTITY) { cur_quantity += 5; } if (cur_variable == CUBE_SIZE) { cur_cube_size += .001; } if (cur_variable == AFTER_COUNTER) { cur_after_counter += 10; } print_cur(); } break; case '-': case '_': { if (cur_variable == RADIUS) { cur_radius -= 2; } if (cur_variable == DENSITY) { cur_density -= 1; } if (cur_variable == QUANTITY) { cur_quantity -= 5; } if (cur_variable == CUBE_SIZE) { cur_cube_size -= .001; } if (cur_variable == AFTER_COUNTER) { cur_after_counter -= 10; } print_cur(); } break; case 'z': { music_playing = (music_playing + 1) % 2; if (music_playing) { BASS_ChannelPlay(sounds[8], FALSE); } else { BASS_ChannelPause(sounds[8]); } } break; case 'a': case 'A': { cur_variable = RADIUS; print_cur(); } break; case 's': case 'S': { cur_variable = DENSITY; print_cur(); } break; case 'd': case 'D': { cur_variable = QUANTITY; print_cur(); } break; case 'f': case 'F': { cur_variable = CUBE_SIZE; print_cur(); } break; case 'g': case 'G': { cur_variable = AFTER_COUNTER; print_cur(); } break; case '1': { make_explosion(&explosions[0], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[0])->x, (&nozzles[0])->y + 1.2); //make_explosion(&explosions[0], 60, 1, 5000, .02, 48, 1, test_sound, (&nozzles[0])->x, (&nozzles[0])->y + 1); BASS_ChannelPlay(sounds[num], TRUE); break; } case '2': { make_explosion(&explosions[1], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[1])->x, (&nozzles[1])->y + 1.2); //make_explosion(&explosions[1], 500, 1, 100, .01, 1100, 1, test_sound, (&nozzles[1])->x, (&nozzles[1])->y + 1); BASS_ChannelPlay(sounds[num], TRUE); break; } case '3': { make_explosion(&explosions[2], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[2])->x, (&nozzles[2])->y + 1.2); //make_explosion(&explosions[2], 650, 1, 100, .05, 800, 1, test_sound, (&nozzles[2])->x, (&nozzles[2])->y + 1); BASS_ChannelPlay(sounds[num], TRUE); break; } case '4': { make_explosion(&explosions[3], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[3])->x, (&nozzles[3])->y + 1.2); //make_explosion(&explosions[3], 1000, 1, 100, .05, 900, 1, test_sound, (&nozzles[3])->x, (&nozzles[3])->y + 1); BASS_ChannelPlay(sounds[num], TRUE); break; } case '5': { make_explosion(&explosions[4], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[4])->x, (&nozzles[4])->y + 1.2); //make_explosion(&explosions[4], 1500, 1, 100, .1, 1000, 1, test_sound, (&nozzles[4])->x, (&nozzles[4])->y + 1); BASS_ChannelPlay(sounds[num], TRUE); break; } case '6': { make_explosion(&explosions[5], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[5])->x, (&nozzles[5])->y + 1.2); //make_explosion(&explosions[5], 600, 1, 100, .09, 1100, 1, test_sound, (&nozzles[5])->x, (&nozzles[5])->y + 1); BASS_ChannelPlay(sounds[num], TRUE); break; } case '7': { make_explosion(&explosions[6], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[6])->x, (&nozzles[6])->y + 1.2); //make_explosion(&explosions[6], 2500, 1, 100, .3, 1200, 1, test_sound, (&nozzles[6])->x, (&nozzles[6])->y + 1); BASS_ChannelPlay(sounds[num], TRUE); break; } case '0': { make_explosion(&explosions[3], new_radius, new_density, new_quantity, cur_cube_size, new_after_counter, cur_shape, test_sound, (&nozzles[3])->x, (&nozzles[3])->y + 1); } break; default: break; } glutPostRedisplay(); }