Session::Session() { window = new Window(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE); initGL(); loadAllTextures(); initFBO(); camera = new Camera(h_uP, h_uV, h_uView); world = new World(shaders[SHADER_DEFAULT]->getPID(), camera); clicks = new Clicks(); fontEngine = new FontEngine(WINDOW_WIDTH, WINDOW_HEIGHT, shaders[SHADER_TEXT], shaders[SHADER_DEFAULT]); sound = new Sound(); sound->initSound(); camera->booths = world->booths; camera->structures = world->structures; minigame = new Minigame(); game_state = TITLE_STATE; game_start = false; global_points = 0; xInc = 1.0f; startTime = 25.0; punLine = 0; world->initParticles(shaders[SHADER_BILLBOARD]); fontEngine->init(shaders[SHADER_TEXT]->getPID()); camera->pov = false; }
/* Main Loop * Open window with initial window size, title bar, * RGBA display mode, and handle input events. */ int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize (1024, 768); glutCreateWindow (argv[0]); init(); loadAllTextures(); glutReshapeFunc(reshape); glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutIdleFunc(timerDisplay); glutMainLoop(); return 0; }
int main() { window.setFramerateLimit(60); loadAllTextures(); Player p(1280/2,720/2); Projectiles.push_back(new Projectile (1280/2, 100, 90.f)); //gameloop while (window.isOpen()) { //handles events sf::Event event; while (window.pollEvent(event)) { switch (event.type) { case sf::Event::Closed: window.close(); break; } } b2Vec2 playerVel = p.Body->GetLinearVelocity(); if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) { playerVel.x = -p.speed; } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)) { playerVel.x = p.speed; } else { playerVel.x = 0; } if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)) { playerVel.y = -p.speed; } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::S)) { playerVel.y = p.speed; } else { playerVel.y = 0; } p.Body->SetLinearVelocity(playerVel); world.Step(1/FPS, 8, 3); window.clear(sf::Color::White); //player step p.step(window); //projectiles step //prj.step(window); for (prjIterator=Projectiles.begin(); prjIterator!=Projectiles.end();++prjIterator) { (*prjIterator)->step(window); } for (b2Body *b = world->GetBodyList(); b != NULL; b = b->GetNext()) { } window.display(); } return 0; }