void render_shot(struct shot *shot, int s_id) { struct player *shoot_pl = dyn_arr_get(&Players, s_id); center_camera(shoot_pl->pos); clear(); render_map(); render_tanks(); debug_d(1, "RenderShotX", shoot_pl->pos.x); debug_d(1, "RenderShotY", shoot_pl->pos.y); debug_d(1, "RenderShot Angle", shot->angle); debug_d(1, "RenderShot Power", shot->power); int input_ch; struct f_pair init_v = initial_v(shot); struct f_pair acc = acceleration(); /* position (x,y) must be either double or float */ struct f_pair init_pos = map_pos_to_float(shoot_pl->pos); timeout(SHOOT_TIMEOUT); float t=1; /* this part is duplicated, because it's initial */ struct f_pair b_pos = shot_pos(init_pos, init_v, acc, t); struct map_position map_pos = round_to_map_pos(b_pos); draw_bullet(dx, dy, map_pos.x, map_pos.y); refresh(); /* end */ input_ch = getch(); if (input_ch != ERR) quit_key(input_ch); while (loc_player->state) { /* remove drew bullet */ draw_blank_bullet(dx, dy, map_pos.x, map_pos.y); debug_d(1, "BulletX", map_pos.x); debug_d(1, "BulletY", map_pos.y); t+=(float)SHOOT_TIMEOUT/100; b_pos = shot_pos(init_pos, init_v, acc, t); map_pos = round_to_map_pos(b_pos); /* draw a new one */ switch (draw_bullet(dx, dy, map_pos.x, map_pos.y)) { case SCR_OK: break; case SCR_UP: case SCR_DOWN: case SCR_LEFT: case SCR_RIGHT: center_camera(map_pos); clear(); render_map(); render_tanks(); draw_bullet(dx, dy, map_pos.x, map_pos.y); break; default: debug_s(5, "ScreenMove(shot)", "Wrong ScrMove value"); } refresh(); if (map_pos.x > map_data->length || map_pos.x < 0) break; if (t > g_impact_t) { b_pos = shot_pos(init_pos, init_v, acc, g_impact_t); map_pos = round_to_map_pos(b_pos); center_camera(map_pos); clear(); render_map(); render_tanks(); draw_bullet_explosion(dx, dy, map_pos.x, map_pos.y); refresh(); break; } /* let player see the change */ input_ch = getch(); if (input_ch != ERR) quit_key(input_ch); } input_ch = getch(); // let players input_ch = getch(); // see the explosion struct player *c_player = dyn_arr_get(&Players, camera_focus); center_camera(c_player->pos); /* SCR_ALL is already in screen update queue by center_camera*/ timeout(DEFAULT_TIMEOUT); //back to original }
//------------------------------------------------------------------------------ // void gosFX::ParticleCloud::CreateNewParticle( unsigned index, Stuff::Point3D *translation ) { Check_Object(this); // //---------------------------------------------------- // Figure out the age and age rate of the new particle //---------------------------------------------------- // Specification *spec = GetSpecification(); Check_Object(spec); Particle *particle = GetParticle(index); Check_Object(particle); particle->m_age = 0.0f; Stuff::Scalar min_seed = spec->m_minimumChildSeed.ComputeValue(m_age, m_seed); Stuff::Scalar seed_range = spec->m_maximumChildSeed.ComputeValue(m_age, m_seed) - min_seed; Stuff::Scalar seed = Stuff::Random::GetFraction()*seed_range + min_seed; Clamp(seed, 0.0f, 1.0f); particle->m_seed = seed; Stuff::Scalar lifetime = spec->m_pLifeSpan.ComputeValue(m_age, seed); Min_Clamp(lifetime, 0.0333333f); particle->m_ageRate = 1.0f / lifetime; // //-------------------------------- // Figure out the initial position //-------------------------------- // Stuff::YawPitchRange initial_p( Stuff::Random::GetFraction() * Stuff::Two_Pi, Stuff::Random::GetFraction() * Stuff::Pi - Stuff::Pi_Over_2, Stuff::Random::GetFraction() ); Stuff::Vector3D position(initial_p); translation->x = position.x * spec->m_emitterSizeX.ComputeValue(m_age, seed); translation->y = position.y * spec->m_emitterSizeY.ComputeValue(m_age, seed); translation->z = position.z * spec->m_emitterSizeZ.ComputeValue(m_age, seed); // //-------------------------------- // Figure out the initial velocity //-------------------------------- // Stuff::Scalar pitch_min = spec->m_minimumDeviation.ComputeValue(m_age, seed); Stuff::Scalar pitch_range = spec->m_maximumDeviation.ComputeValue(m_age, seed) - pitch_min; if (pitch_range < 0.0f) pitch_range = 0.0f; pitch_min += pitch_range * Stuff::Random::GetFraction() - Stuff::Pi_Over_2; Stuff::YawPitchRange initial_v( Stuff::Random::GetFraction() * Stuff::Two_Pi, pitch_min, spec->m_startingSpeed.ComputeValue(m_age, seed) ); particle->m_localLinearVelocity = initial_v; }