Shot.cc File Reference

#include "Robot.h"
#include "Shot.h"
#include "ArenaController.h"
#include "ArenaRealTime.h"
#include "ArenaWindow.h"
#include "Extras.h"
#include "Various.h"
#include "Options.h"

Include dependency graph for Shot.cc:

Include dependency graph

Go to the source code of this file.

Functions

void shot_collision (Shot *shot1p, Shot *shot2p)
void shot_collision (Shot *shot1p, const Vector2D &shot2_vel, const double shot2_en)


Function Documentation

void shot_collision Shot shot1p,
const Vector2D shot2_vel,
const double  shot2_en
 

Definition at line 136 of file Shot.cc.

References Circle::center, Shot::die(), dot(), Shot::energy, Options::get_d(), Shape::id, length(), OPTION_SHOT_MIN_ENERGY, OPTION_SHOT_SPEED, realtime_arena, the_arena, the_opts, unit(), and MovingObject::velocity.

Referenced by Robot::get_messages(), and shot_collision().

00137 {
00138   Vector2D vel = ( shot1p->energy * shot1p->velocity + 
00139                    shot2_en * shot2_vel ) / ( shot1p->energy + shot2_en );
00140 
00141   double en = dot( shot1p->energy * unit(shot1p->velocity) + shot2_en * unit(shot2_vel),  
00142                    unit(vel));
00143 
00144   if( en < the_opts.get_d(OPTION_SHOT_MIN_ENERGY) || 
00145       length(vel) < the_opts.get_d(OPTION_SHOT_SPEED) * 0.5 )
00146     {
00147       shot1p->die();
00148     }
00149   else
00150     {
00151       shot1p->velocity = vel;
00152       shot1p->energy = en;
00153       realtime_arena.print_to_logfile('D', (int)'S', shot1p->id);
00154       shot1p->id = the_arena.increase_shot_count();
00155       realtime_arena.print_to_logfile('S', shot1p->id, shot1p->center[0], shot1p->center[1], 
00156                                       shot1p->velocity[0], shot1p->velocity[1]);
00157       
00158 
00159     }
00160 }

Here is the call graph for this function:

void shot_collision Shot shot1p,
Shot shot2p
 

Definition at line 128 of file Shot.cc.

References Shot::die(), Shot::energy, shot_collision(), the_arena, and MovingObject::velocity.

00129 {
00130   shot_collision(shot1p, shot2p->velocity, shot2p->energy);
00131   shot2p->die();
00132   the_arena.get_object_lists()[SHOT].remove( shot2p );
00133 }

Here is the call graph for this function:


Generated on Fri Oct 15 15:48:16 2004 for Real Time Battle by  doxygen 1.3.9.1