void handleEvents() { const sf::Input& Input = App->GetInput(); bool shiftDown = Input.IsKeyDown(sf::Key::LShift) || Input.IsKeyDown(sf::Key::RShift); sf::Event Event; while (App->GetEvent(Event)) { if (Event.Type == sf::Event::Closed) App->Close(); if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape)) App->Close(); // This is for grading your code. DO NOT REMOVE if(Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Space) { firing = 6; } if(Event.Type == sf::Event::KeyReleased && Event.Key.Code == sf::Key::Space) { firing = 0; } if(Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::F12){ render = RenderEngine(); render.init(); } if (Event.Type == sf::Event::Resized) { glViewport(0, 0, Event.Size.Width, Event.Size.Height); } } }
void handleEvents(sf::Window & window, WorldState & state) { sf::Event event; while (window.pollEvent(event)) { // Close window : exit if (event.type == sf::Event::Closed) state.setRunning(false); // Escape key : exit if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)) state.setRunning(false); if (event.type == sf::Event::TextEntered) { Model const & model = state.getModel(); float time = state.getCurrentTime(); RenderEngine render = RenderEngine(render); switch (static_cast<char>(event.key.code)) { case 'q': printf("'q' should scale\n"); // scale = true. //if(!state.scaleEnabled()) state.toggleScale(); break; case 'w': printf("'w' should enable bouncing\n"); state.toggleTranslate(); break; case 'e': printf("'e' should enable z rotation\n"); // rotZ = true. state.toggleRotZ(); break; case 'r': printf("'r' should enable y rotation\n"); // rotY = true. state.toggleRotY(); break; default: printf("nothing\n"); break; } } // std::cout << "Your Input: " << static_cast<char>(event.key.code) << std::endl; //TODO add event handlers for qwer //'q' should scale //'w' should enable bouncing //'e' should enable z rotation //'r' should enable y rotation } }