void RobotMove::debugCode(){
		cout<< "debug";
		cout<<(*position).GetXPos()<<", "<<(*position).GetYPos()<<", "<< (*position).GetYaw()<< endl;
		cout << "AngularDistance: " << rtod(angularDistence);
		cout << " Starting Angle: "<< startingAngle << " Robot Angle: " << rtod((*position).GetYaw()) << endl;
		cout << " Distance: " << distanceToGo << endl;
	}
示例#2
0
void		BulletCommand::setSpeedDirection()
{
	this->_direction = atan2((double)this->_vy, (double)this->_vx);
	this->_speed = sqrt((double)(this->_vx * this->_vx) + (double)(this->_vy * this->_vy));
	if (this->_sprite)
		this->_sprite->setRotation(-rtod(this->_direction) + 90);
}
示例#3
0
文件: Bullet.cpp 项目: Koukan/Grab
void		Bullet::setSprite(Sprite *sprite)
{
	if (this->_sprite)
		delete this->_sprite;
	this->_sprite = sprite;
	if (this->_sprite)
		this->_sprite->setRotation(rtod(atan2(_vy, _vx)));
}
示例#4
0
文件: Bullet.cpp 项目: Koukan/Grab
void		Bullet::setSprite(ResourceManager &resource, std::string const &name)
{
	if (this->_sprite)
		delete this->_sprite;
	this->_sprite = resource.getSprite(name);
	if (this->_sprite)
		this->_sprite->setRotation(rtod(atan2(_vy, _vx)));
}
示例#5
0
void		BulletCommand::doChangeSpeed(double speed)
{
	if (!this->_isCommanded)
		return ;
	this->_speed = speed;
	this->_vx = this->_speed * cos(this->_direction);
	this->_vy = this->_speed * sin(this->_direction);
	if (this->_sprite)
		this->_sprite->setRotation(-rtod(this->_direction) + 90);
}
示例#6
0
//Calculate bearing from lat1/lon1 to lat2/lon2
//Note lat1/lon1/lat2/lon2 must be in radians
//Returns bearing in degrees
int CalcBearing(double lat1, double lon1, double lat2, double lon2)
{
  lat1 = dtor(lat1);
  lon1 = dtor(lon1);
  lat2 = dtor(lat2);
  lon2 = dtor(lon2);
  
  //determine angle
  double bearing = atan2(sin(lon2-lon1)*cos(lat2), (cos(lat1)*sin(lat2))-(sin(lat1)*cos(lat2)*cos(lon2-lon1)));
  //convert to degrees
  bearing = rtod(bearing);
  //use mod to turn -90 = 270
  //bearing = fmod((bearing + 360.0), 360);
  //return (int) bearing + 0.5;
  return ((int) bearing + 360) % 360;
}
示例#7
0
文件: Bullet.cpp 项目: Koukan/Grab
Bullet::Bullet(ResourceManager &resource, std::string const & sprite, HitBox &box,
	       double vx, double vy, double xHitboxOffset, double yHitboxOffset)
	: PhysicObject(box, vx, vy, xHitboxOffset, yHitboxOffset), _sprite(0), _parent(0), _bulletId(0),
	  _life(1), _damage(1)
{
  try
  {
	this->_sprite = resource.getSprite(sprite);
	if (this->_sprite)
		this->_sprite->setRotation(rtod(atan2(vy, vx)));
  }
  catch (...)
  {
	std::cerr << "Sprite \"" << sprite  << "\" not found" << std::endl;
  }
}
示例#8
0
double		BulletCommand::getAimDirection(double defaultValue)
{
	/*this->setRelativeObject(0);
	if (!this->_relativeObject || this->_relativeObject->isDelete())
	{*/
		GameObject	*obj = 0;
		uint32_t	distance = static_cast<uint32_t>(-1);
		Group		*group;
		int			x, y;
		uint32_t	calc;
		for (std::set<std::string>::const_iterator it = this->_focus.begin();
			it != this->_focus.end(); it++)
		{
			group = this->_state.getGroup(*it);
			if (group)
			{
				for (Group::gameObjectSet::const_iterator lit = group->getObjects().begin();
				 lit != group->getObjects().end(); lit++)
				{
					if ((*lit)->isDelete())
						continue;
					x = this->getX() - (*lit)->getX();
					y = this->getY() - (*lit)->getY();
					calc = static_cast<int>(x * x + y * y);
					if (calc < distance)
					{
						distance = calc;
						obj = *lit;
					}
				}
			}
		}
		/*if (obj)
			this->setRelativeObject(obj);
		else
			this->setRelativeObject(0);
	}*/
	if (obj/*this->_relativeObject*/)
	{
		PhysicObject	*ph = static_cast<PhysicObject*>(obj/*this->_relativeObject*/);
		HitBox			&hb = ph->getHitBox();
		double			px = (ph->getX() + ph->getXHitBoxOffset() + (hb.getWidth() / 2)) - this->getX();
		double			py = (ph->getY() + ph->getYHitBoxOffset() + (hb.getHeight() / 2)) - this->getY();
		return rtod(::atan2(py, px));
	}
	return defaultValue;
}
示例#9
0
double		BulletCommand::getBulletDirection()
{
	return rtod(_direction);
}
示例#10
0
double BulletCommand::getAimDirection() 
{
    return rtod(M_PI-atan2(mTarget->x - mMover->x, mTarget->y - mMover->y));
}
示例#11
0
 double getAimDirectionWithXRev_(BulletMLRunner* r) {
     Vector b = Bullet::now->pos;
     Vector t = Bullet::target;
     float xrev = dynamic_cast<P47Bullet*>(Bullet::now)->xReverse;
     return rtod(atan2(t.x - b.x, t.y - b.y) * xrev);
 }