Exemplo n.º 1
0
thinkofgrapples()
{
	register int n, l, friendly;

	for (n=0; n < scene[game].vessels; n++){
		if (!scene[game].ship[n].file -> captain[0] && pos[n].dir){
			for (l=0; l < scene[game].vessels; l++){
				if ((friendly = scene[game].ship[l].file -> captured) < 0)
					friendly = scene[game].ship[n].nationality == scene[game].ship[l].nationality;
				else
					friendly = scene[game].ship[n].nationality == scene[game].ship[friendly].nationality;
				if (!friendly){
					if (range(n,l) == 1 && !scene[game].ship[n].file -> struck && scene[game].ship[n].file -> captured < 0){
						if (grapple(n,l))
							if (toughmelee(n,l,0,0))
								ungrap(n, l);
							else
								grap(n, l);
						else if (couldwin(n,l)){
							grap(n, l);
							loadwith[n] = GRAPE;
						}
					}
				}
				else
					ungrap(n,l);
			}
		}
	}
}
Exemplo n.º 2
0
const Process::Return GameLoadingProcess::update(const float deltaTime)
{
	StateManager& stateManager(StateManager::instance());
	GameState* gameState(stateManager.getState<GameState>("GameState"));
	assert(gameState);
	
	EntitySystem& entitySystem(EntitySystem::instance());
	PlayerShip* playerShip(entitySystem.add<PlayerShip>("Player"));
	playerShip->setGraphicObject(new SDLGraphicObject);
	playerShip->writeGraphicObject<SDLGraphicObject>().load("data/playership.bmp");
	playerShip->setInputObject(new SDLInputObject(playerShip));
	playerShip->writeInputObject<SDLInputObject>().setup();
	playerShip->writePosition() = Vector2D(300.0F, 200.0F);
	playerShip->setMass(3.0F);
	//playerShip->writeVelocity() = Vector2D(100.0F, 300.0F);
	entitySystem.addToList(playerShip, "Renderable");
	entitySystem.addToList(playerShip, "Collidable");
	entitySystem.addToList(playerShip, "Movable");
	entitySystem.addToList(playerShip, "Ship");
	
	Bullet* enemyShip(entitySystem.add<Bullet>("Renderable"));
	enemyShip->setGraphicObject(new SDLGraphicObject);
	enemyShip->writeGraphicObject<SDLGraphicObject>().load("data/enemy.bmp");
	enemyShip->writePosition() = Vector2D(150.0F, 300.0F);
	enemyShip->setMass(3.0F);
	entitySystem.addToList(enemyShip, "Movable");
	//entitySystem.addToList(enemyShip, "Ship");
	
	GrappleHook* grapple(entitySystem.add<GrappleHook>("Renderable"));
	grapple->setGraphicObject(new SDLGraphicObject);
	grapple->writeGraphicObject<SDLGraphicObject>().load("data/hook.bmp");
	grapple->setSource(playerShip);
	grapple->setTarget(enemyShip);
	
	for (Uint segment(0U); segment < 10U; ++segment) {
		HookSegment* hookSegment(entitySystem.add<HookSegment>("Renderable"));
		hookSegment->setGraphicObject(new SDLGraphicObject);
		hookSegment->writeGraphicObject<SDLGraphicObject>().load("data/segment.bmp");
		grapple->addSegment(hookSegment);
	}

	entitySystem.addToList(grapple, "Grapple");
	grapple->setSpeed(100.0F);
	grapple->writePosition() = playerShip->readPosition();
	grapple->fire();
	
	std::vector<Process*> processList;
	processList.push_back(new GameInputProcess);
	processList.push_back(new GamePhysicsProcess);
	processList.push_back(new GameRenderProcess);
	gameState->setProcessor(new Processor(processList));
	
	return Process::STOP;
}
Exemplo n.º 3
0
void Cannon::movement(float timeElapsed)
{
	if(KeyManager::getManager()->keyPressed(Control::getManager()->GetCannonMoveUp()))
	{
		action(timeElapsed);
	}
	else if(KeyManager::getManager()->keyPressed(Control::getManager()->GetCannonMoveDown()))
	{
		grapple(timeElapsed);
	}
	if(KeyManager::getManager()->keyDown(Control::getManager()->GetCannonMoveLeft()))
	{
		rotation-=20*timeElapsed;
	}
	else if(KeyManager::getManager()->keyDown(Control::getManager()->GetCannonMoveRight()))
	{
		rotation+=20*timeElapsed;
	}
}