void newMatch(void) { buildMaze(glmaze, Graph_Space, tileSpace, Tilesize, Resources_Manager.texture("wall.tga"), Resources_Manager.texture("floor.tga"), Resources_Manager.texture("ceil.tga"), &Config_Info); restartMatch(); }
void Pong::ballOut(int player) { if(app->playersActive == 2) { app->soundPlayer->effect("point"); app->players[player]->incrementScore(); if(app->players[player]->getScore() >= Application::scoreToWin) { app->soundPlayer->effect("win"); restartMatch(); if(player == app->PLAYER_RIGHT) { app->osmHuge.setMessage("Right WINS", 3.0f); } else if(player == app->PLAYER_LEFT) { app->osmHuge.setMessage("Left WINS", 3.0f); } } else { if(player == app->PLAYER_RIGHT) { app->osmShout.setMessage("Right Scores", 2.0f); } else if(player == app->PLAYER_LEFT) { app->osmShout.setMessage("Left Scores", 2.0f); } spawnBall = true; timeToSpawnBall = 3000.0f; } } else { /* if(entities.size() <= app->ANZ_BALS_DEMO) { makeBall(); }*/ } }
void GuiManager::processMainWindowEvents(sf::RenderWindow *window, GfxManager *gfxManager, int viewWidth, int viewHeight) { sf::Event event; bool resized = false; while (window->pollEvent(event)) { bool modifierDown = (event.key.system || event.key.control); #ifdef __WXOSX__ // For some reason, the dash key (between 0 and =) generates no KeyPressed // event on Mac OS X, but it does generate a TextEntered event. Also, as of // Yosemite + SFML 2.3, we no longer receive the dash key at all when cmd or // ctrl is pressed. So on OS X, just look for +, -, and 0 keys with no // modifier, to be consistent. if (event.type == sf::Event::TextEntered && event.text.unicode == 45) { gfxManager->decreaseWindowSize(window, viewWidth, viewHeight); } modifierDown = true; #endif if (event.type == sf::Event::Closed) { window->close(); quit(); } if (event.type == sf::Event::MouseWheelMoved) { sf::Event::MouseWheelEvent wheelEvent = event.mouseWheel; gfxManager->processMouseWheel(wheelEvent.x, wheelEvent.y, wheelEvent.delta); } if (event.type == sf::Event::Resized && !resized) { resized = true; gfxManager->onResize(window, viewWidth, viewHeight); } if (event.type == sf::Event::MouseButtonPressed) { gfxManager->processMouseDown(event.mouseButton.x, event.mouseButton.y); } if (event.type == sf::Event::MouseButtonReleased) { gfxManager->processMouseUp(event.mouseButton.x, event.mouseButton.y); } if (event.type == sf::Event::MouseMoved || event.type == sf::Event::MouseEntered) { gfxManager->processMouseMoved(event.mouseMove.x, event.mouseMove.y); } if (event.type == sf::Event::MouseLeft) { gfxManager->processMouseMoved(-1, -1); } if (event.type == sf::Event::KeyPressed) { switch (event.key.code) { case sf::Keyboard::Space: togglePause(); break; case sf::Keyboard::BackSpace: restartMatch(); break; case sf::Keyboard::Escape: showNewMatchDialog(); break; #ifdef __WXOSX__ case sf::Keyboard::LSystem: case sf::Keyboard::RSystem: gfxManager->showKeyboardShortcuts(); break; #else case sf::Keyboard::LAlt: case sf::Keyboard::RAlt: gfxManager->showKeyboardShortcuts(); break; #endif case sf::Keyboard::N: showNewMatchDialog(); break; case sf::Keyboard::P: showPackageShipDialog(); break; case sf::Keyboard::T: showPackageStageDialog(); break; case sf::Keyboard::G: showGameRunnerDialog(); break; case sf::Keyboard::Equal: case sf::Keyboard::Add: if (modifierDown) { gfxManager->increaseWindowSize(window, viewWidth, viewHeight); } break; case sf::Keyboard::Dash: case sf::Keyboard::Subtract: if (modifierDown) { gfxManager->decreaseWindowSize(window, viewWidth, viewHeight); } break; case sf::Keyboard::Num0: if (modifierDown) { gfxManager->defaultWindowSize(window, viewWidth, viewHeight); } break; case sf::Keyboard::LBracket: gfxManager->decreaseGameSpeed(); break; case sf::Keyboard::RBracket: gfxManager->increaseGameSpeed(); break; default: break; } } if (event.type == sf::Event::KeyReleased) { switch (event.key.code) { #ifdef __WXOSX__ case sf::Keyboard::LSystem: case sf::Keyboard::RSystem: gfxManager->hideKeyboardShortcuts(); break; #else case sf::Keyboard::LAlt: case sf::Keyboard::RAlt: gfxManager->hideKeyboardShortcuts(); break; #endif default: break; } } // On Mac/Cocoa, when using a different Space, the rest of the OS UI slows // to a crawl unless you have a frame rate limit set. But the frame rate is // smoother if we use vsync instead of a fixed frame rate, so do that when // we have focus. // TODO: Determine if this is necessary/preferable on Linux/Windows. // TODO: Might be better to restrict this to the Spaces case specifically, // or when window isn't visible to user. if (event.type == sf::Event::LostFocus) { window->setVerticalSyncEnabled(false); window->setFramerateLimit(paused_ ? 5 : 60); } else if (event.type == sf::Event::GainedFocus) { updateFramerate(); } } // On Linux/GTK and Windows, the wxWidgets windows don't get events while // this thread has control unless we wxYield each frame. Seems to be // unnecessary on Mac/Cocoa. #ifndef __WXOSX__ wxYield(); #endif }