Beispiel #1
0
//------------------------------------------
void   Enemy::update(float time)
{
	


	updateAnimation(time);

	if(m_State==ES_NORMAL)
	{
		updateNormal(time);
		//updateOrientation();

	}else if(m_State==ES_DODGE)
	{
		updateDodge(time);
	}else if(m_State==ES_DEATH)
	{
		updateDeath(time);
	}else if(m_State==ES_SWALLOWBALL)
	{
		updateSwallowBall(time);
	}else if(m_State==ES_SMOKE)
	{
		updateSmoke(time);
	}

	return  ;
}
Beispiel #2
0
void		CoreGame::runCode(void *params)
{
	int		x = 0;
	double time = 0.f;
	t_movement	mouv;
	sf::Event event;
	std::string	port;

	port = this->intToString();
	this->_idSocketRoom = this->_socketInGame->connectToSocket(_sconnect.ip, port);
	this->_window->createWindow();
	this->_backgroundFirstPart->setPosition((float)x, 0.0);
	this->_backgroundSecondePart->setPosition((float(x + SIZEIMAGE)), 0);
	
#ifdef _WIN32
	FILETIME	ttmp{ 0, 0 };
	MTime		*mtime = new MTime(ttmp);
	ULARGE_INTEGER tbegin;
#else
	MTime		*mtime = new MTime;
	struct timeval start;
#endif
	while (this->_window->getWindow()->isOpen())
	{
#ifdef _WIN32
		mtime->updateClock(&tbegin);
		if ((time = mtime->getTime(tbegin)) < 0.02) {
			int res = (int)std::floor((0.02 - time) * 1000);
			Sleep(res);
		}
#else
		if ((time = mtime->getTime()) < 0.02) {
			int res = (int)std::floor((0.02 - time) * 1000);
			usleep(res);
		}
#endif
		this->_window->getWindow()->clear();

		this->_backgroundFirstPart->setPosition((float)x, 0.0);
		this->_backgroundSecondePart->setPosition((float(x + SIZEIMAGE)), 0.0);
		
		x--;
		if (x < -SIZEIMAGE)
			x = 0;

		this->_backgroundTop->setPosition(0.0, 0.0);
		this->_backgroundBottom->setPosition(0.0, 695.0);

		this->_window->getWindow()->draw(*this->_backgroundFirstPart);
		this->_window->getWindow()->draw(*this->_backgroundSecondePart);
		
		this->_window->getWindow()->draw(*this->_backgroundTop);
		this->_window->getWindow()->draw(*this->_backgroundBottom);
		if (endgame() == true)
			return ;
		updateDeath();

		drawPlayer(this->_classShared->_mapPlayer);
		drawMonster(this->_classShared->_mapMonster);
		drawAmmo(this->_classShared->_mapAmmo);
		drawBoss(this->_classShared->_mapBoss);
		drawAnExplosion();


		while (this->_window->getWindow()->pollEvent(event)){
			if (event.type == sf::Event::Closed)
				this->_window->getWindow()->close();
		}
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
			this->moveRight(mouv);
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
			this->moveLeft(mouv);
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
			this->moveUp(mouv);
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
			this->moveDown(mouv);
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space))
			this->shoot(mouv);
		this->_window->getWindow()->display();
	}
}