Example #1
0
void		Game::loop(void)
{
	Map			*map;
	Snake		*snake;

	map = this->getMap();
	snake = new	Snake(map->getWidth() / 2, map->getHeight() / 2);
	map->setSnake(snake);

	while (!this->_shouldExit)
	{
		Time::update();

		/* events */
		this->_handleInputs(this->_dlib->getInput());

		/* update */
		if (!this->_isPaused)
			this->update();

		/* refresh display */
		this->_dlib->draw(map);

		Time::sleep(200 - snake->getSpeed() * 10);
	}
	this->_dlib->close();

	printf("Final score: %d\n", this->_score);
}