Beispiel #1
0
void			Core::Nibbler::operator()()
{
  float		box_x;
  float		box_y;
  bool		run = true;

  box_x = (800.0 / this->_g.getSizeX());
  box_y = (600.0 / this->_g.getSizeY());
  this->_window->CreateWindow(&this->_g, box_x, box_y);
  this->_window->Display(this->_food.getScore(), this->level);
  while (run)
    {
      try
	{
	  this->_window->Display(this->_food.getScore(), this->level);
	}
      catch (...)
	{
	  throw (excp("Fail to display"));
	}
      if (!this->handleEvent())
	run = false;
      if (!this->moveSnake())
      	run = false;
      this->setLevel();
      usleep(this->speed);
    }
}
Beispiel #2
0
Dynamic::DlLoader::DlLoader(std::string const& filename, int flag) throw (std::exception&) : _filename(filename)
{
  this->_handle = dlopen(this->_filename.c_str(), flag);
  if (!this->_handle)
    {
      std::cout << dlerror() << std::endl;
      throw (excp("Unable to open dynamic library: " + this->_filename));
    }
}
Beispiel #3
0
  Egg &Grid::getEgg(unsigned int id)
  {
    std::list<Egg*>::iterator it_b = _eggs.begin();

    for (; it_b != _eggs.end() ; ++it_b)
      {
	if ((*it_b)->getId() == id)
	  return *(*it_b);
      }
    throw (excp("bad player"));
  }
Beispiel #4
0
  Player *Grid::getPlayer(unsigned int id)
  {
    std::list<Player*>::iterator it_b = _p_list.begin();

    for (; it_b != _p_list.end() ; ++it_b)
      {
	if ((*it_b)->getId() == id)
	  return (*it_b);
      }
    throw (excp("bad player"));
  }