Exemplo n.º 1
0
bool SpaceShipBeam::Update(float dt, QuadTree& tree)
{
	glm::vec3 dir(-sin(m_dir * 3.14f / 180.0f),cos(m_dir * 3.14f / 180.0f),0.0f);
	m_pos += dir * m_speed * dt;
	m_age += dt;

	tree.Erase(*this);
	m_collisionPoly.GetCircle().center = glm::vec2(m_pos.x,m_pos.y);
	tree.Insert(*this);

	std::vector<ISpatialObject*> nearObj;
	tree.QueryNearObjects(this,nearObj);

	for(unsigned int i = 0; i < nearObj.size(); ++i)
	{
		void* pInterface = nearObj[i]->QueryInterface(IDestroyable::INTERFACE_DESTROY);
		void* pBeam = nearObj[i]->QueryInterface(SpaceShipBeam::INTERFACE_BEAM);

		if(pInterface != nullptr && pBeam == nullptr)
		{
			IDestroyable* pDestroyable = static_cast<IDestroyable*>(pInterface);
			pDestroyable->Destroy();
			m_bDestroyed = true;
		}
	}

	m_animation.Update(dt);

	return m_bDestroyed || m_age > 1.5f;
}
Exemplo n.º 2
0
void
GameBoard::MarkAlive(const CellSet& cells,
                     QuadTree& tree) {
  tree.Clear();
  for (CellSet::iterator it = cells.begin();
       it != cells.end(); ++it) {
    tree.Insert(*it);
  } 
}