예제 #1
0
파일: Game.cpp 프로젝트: AlmasB/tetris3d
void Game::handleKeyEvents() {
	if (nullptr == selected) {
		handlePlayerMovement();
	}
	else {
		if (eventSystem->isPressed(Key::W)) selected->move(player->getDirection());
		if (eventSystem->isPressed(Key::S)) selected->move(player->getDirection()*(-1.0f));
		if (eventSystem->isPressed(Key::A)) selected->move(Vector3f(-player->getDirection().z, 0, player->getDirection().x));
		if (eventSystem->isPressed(Key::D)) selected->move(Vector3f(player->getDirection().z, 0, -player->getDirection().x));
	}

	if (eventSystem->isPressed(Key::UP)) player->lookUp(20);
	if (eventSystem->isPressed(Key::DOWN)) player->lookUp(-20);
	if (eventSystem->isPressed(Key::LEFT)) player->lookRight(-20);
	if (eventSystem->isPressed(Key::RIGHT)) player->lookRight(20);

	if (eventSystem->isPressed(Key::SPACE)) onPrimaryAction();
	if (eventSystem->isPressed(Key::ESC)) running = false;
}
예제 #2
0
void InputHandler::handleInput(Player &player, const sf::RenderWindow& window)
{
	handlePlayerMovement(player);
	getMousePos(window);
}