Пример #1
0
void	Gui::dump() 
{
  glClear(GL_COLOR_BUFFER_BIT);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  init_picture(m_nibbler.getMap());
  glEnd();
  glFlush();
  aff_score(0);
  SDL_GL_SwapBuffers();   
  handleEvents(); 
}
Пример #2
0
void Module::processEventQueue() {
	if (!isRunning())
		return;

	replaceModule();

	if (!isRunning())
		return;

	handleEvents();
	handleActions();
}
Пример #3
0
//Run
void Framework::run()
{
	unsigned int counter = 0;
	while (pRenderWindow->isOpen())
	{
		counter += 1;
		//std::cout << "Main Loop: " << counter << std::endl;
		handleEvents();
		update();
		render();
	}
}
Пример #4
0
std::vector<AnswerCombo> Game::run()
{
	m_questionTimer.restart();
	while(m_stillPlaying && m_window->isOpen())
	{
		handleEvents();

		update();
		render();
	}
	return m_answers;
}
Пример #5
0
void game::play (
) {
	startUp ();
	while (m_gameaction != gameaction::Exit) {
		m_rw.clear (sf::Color::Green);
		prepareData ();
		prepareScreenElements ();
		draw (m_ses, m_rw);
		m_rw.display ();
		handleEvents ();
	}
	shutDown ();
}
Пример #6
0
void Game::mainLoop()
{
	m_bgMusic.play();
	while (m_running)
	{
		dt = 1.f / 60.f;

		handleEvents();
		update();
		draw();
	}
	SDL_Quit();
}
void StateBasedGame::run()
{
	sf::Font font;
	font.loadFromFile("sansation.ttf");
	sf::Text text;
	text.setFont(font);
	text.setCharacterSize(24);
	text.setColor(sf::Color::Cyan);

	sf::Clock dtimer;

	const float fps = 120;
	const float dt = 1 / fps;
	float accumulator = 0;

	while (window.isOpen())
	{
		// Store the time elapsed since the last frame began
		const float currentTime = dtimer.restart().asSeconds();
		accumulator += currentTime;

		// Avoid spiral of death and clamp dt, thus clamping
		// how many times the update can be called in
		// a single game loop.
		if(accumulator > 0.2f)
		{
			accumulator = 0.2f;
		}

		while(accumulator > dt)
		{
			update(window, dt);
			accumulator -= dt;
		}

		handleEvents(window);

		const float alpha = accumulator / dt;

		window.clear();
		render(window, alpha);

#ifdef DEBUG
		window.setView(window.getDefaultView());
		text.setString(static_cast<std::ostringstream*>( &(std::ostringstream() << (1/currentTime) ) )->str());
		window.draw(text);
#endif //DEBUG

		window.display();
	}
}
Пример #8
0
int
GameState::EventLoop()
{
	while (run_) {
		moveItems();
		renderItems();
		SDL_Event e;
		while (SDL_PollEvent(&e)) {
			handleEvents(e);
		}
		SDL_Delay(50);
	}
	return retCause_;
}
Пример #9
0
void EventManager::poll() {
	while (g_system->getEventManager()->pollEvent(_event)) {
		switch (_event.type) {
		case Common::EVENT_KEYDOWN:
		case Common::EVENT_KEYUP:
			// Handle keyboard events
			_vm->_keyboard->newKeyboard(_event);
			handleEvents();
			break;
		case Common::EVENT_MOUSEMOVE:
		case Common::EVENT_LBUTTONDOWN:
		case Common::EVENT_LBUTTONUP:
		case Common::EVENT_RBUTTONDOWN:
		case Common::EVENT_RBUTTONUP:
			// Handle mouse events
			_vm->_mouse->newMouse(_event);
			handleEvents();
			break;
		default:
			break;
		}
	}
}
Пример #10
0
void ApplicationContext::update()
{
  if (_app_state == ApplicationLifeState::RUNNABLE)
  {
    _app_state = ApplicationLifeState::RUNNING;
    handleEvents();
    handleTimers();
    if (_app_state == ApplicationLifeState::RUNNING)
      onUpdate();
    if (_app_state == ApplicationLifeState::RUNNING)
      _app_state = ApplicationLifeState::RUNNABLE;
    _last_update_time = System::getInstance()->getTime();
  }
}
void Level::DoLevel() {

    Application &App = Application::GetInstance();
    m_exit = false;

    m_bg_music.Play();
    Start();

    while(!m_exit) {
		handleEvents(App);
		Draw(App);
		nextFrame();
	}
}
Пример #12
0
void test_c64_vice_get_registers(void**)
{
    CPUState state;

    PDWriter* writer = s_session->currentWriter;
    PDWrite_eventBegin(writer, PDEventType_getRegisters);
    PDWrite_eventEnd(writer);
    PDBinaryWriter_finalize(writer);

    Session_update(s_session);

    assert_true(handleEvents(&state, s_session));
    assert_true(state.pc >= 0x80e && state.pc <= 0x81a);
}
Пример #13
0
void Module::processEventQueue() {
	if (!isRunning())
		return;

	replaceModule();
	enterArea();

	if (!isRunning())
		return;

	handleEvents();
	handleActions();

	_ingameGUI->updatePartyMember(0, *_pc);
}
Пример #14
0
	void frame()
	{
		float frame_time = m_frame_timer->tick();
		m_engine->update(*m_universe);
		m_pipeline->render();
		auto* renderer = m_engine->getPluginManager().getPlugin("renderer");
		static_cast<Lumix::Renderer*>(renderer)->frame();
		m_engine->getFileSystem().updateAsyncTransactions();
		if (frame_time < 1 / 60.0f)
		{
			PROFILE_BLOCK("sleep");
			Lumix::MT::sleep(Lumix::uint32(1000 / 60.0f - frame_time * 1000));
		}
		handleEvents();
	}
void wsGameLoop::updateGameState() {
  wsAssert(_mInitialized, "The object wsGame must be initialized via the startUp() method before use.");

  wsSounds.updateStreams();
  game->onLoop();
  handleInputs();
  //  Update physics
  game->getCurrentScene()->updatePhysics(frameDuration);
  handleEvents();
  if (quit) { return; }

  game->getCurrentScene()->updateAnimations(frameDuration);

  wsMem.swapFrames(); //  Swap the current memory buffer on the frame stack
}
Пример #16
0
int Button(void)
/* Function Button returns:
   1 if any mouse button is pressed,
   0 if no button is pressed */
{
   if (isgraphic)
   {
      handleEvents();
//  if(XQueryPointer(display,win,
//                 &win_root,&win_child,&root_x,&root_y,&win_x,&win_y,&bttn_mask))
//  return (bttn_mask);
      return buttonState;
   }
   return 0;
}
Пример #17
0
void MapView::run()
{
    // Render graphics once at the beginning
    update();

    isRunning = true;
    SDL_Event event;
    while (isRunning)
    {
        while (SDL_PollEvent(&event))
        {
            handleEvents(event);
        }
    }
}
Пример #18
0
	void Game::gameLoop()
	{
		running = true;
		
		const sf::Time dt = sf::seconds(1.f / ticksPerSecond);
		
		sf::Time lastTime = gameTime.getElapsedTime();
		sf::Time lag = sf::seconds(0);
		
#ifdef DEBUG
		const float FRAMES_TO_TIME = 60.f;
		sf::Clock framesClock;
		unsigned int frameCounter = 0;
#endif
		
		while(running)
		{
			sf::Time newTime = gameTime.getElapsedTime();
			sf::Time frameTime = newTime - lastTime;
			
			lastTime = newTime;
			
			lag += frameTime;
			
			while(lag >= dt)
			{
				handleEvents();
				update(dt);
				lag -= dt;
			}
			
			draw();
			
#ifdef DEBUG
			// frames per second measurement
			frameCounter++;
			
			if(frameCounter >= FRAMES_TO_TIME)
			{
				fps.setString(std::to_string(FRAMES_TO_TIME / framesClock.restart().asSeconds()).substr(0, 8));
				frameCounter = 0;
			}
#endif
			
			// make state changes last, since they affect everything else
			manageStates();
		}
	}
// Set the label text
void ModalProgressDialog::setTextAndFraction(const std::string& text, double fraction)
{
	// If the aborted flag is set, throw an exception here
	if (_aborted) {
		throw OperationAbortedException("Operation cancelled by user");
	}

	// Set the text
	gtk_label_set_markup(GTK_LABEL(_label), text.c_str());
	
	// Pulse the progress bar
	gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(_progressBar), fraction);
	
	// Handle GTK events to make changes visible
	handleEvents();
}
Пример #20
0
	Program4()
	{
		getWindowContext();

		state.currentRes[0] = RESOLUTION;
		state.currentRes[1] = RESOLUTION;
		render.init(state);
		resize(window->getSize().x, window->getSize().y);
		
		previousPos = glm::vec2(0);
		buttonDown[0]=false;
		buttonDown[1]=false;
		buttonDown[2]=false;
		
		sf::Clock c;
		float lastFrame = c.restart().asSeconds();
		float lastPrint = lastFrame;
		float targetFrameTime = 1.0f/(float)TARGET_FPS;
		
		while (state.isRunning())
		{			
			window->setActive();
			float currentTime = c.getElapsedTime().asSeconds();
			float sinceLastFrame = currentTime - lastFrame;
			float sleepTime = targetFrameTime - sinceLastFrame;
			if(sleepTime > 0)
				sf::sleep(sf::seconds(sleepTime));
			
			currentTime = c.getElapsedTime().asSeconds();
			lastFrame = currentTime;
			float sinceLastPrint = currentTime - lastPrint;
			
			handleEvents(state, render);
			state.timeStep(currentTime);
			
			if(sinceLastPrint > PRINT_FPS_INTERVAL) {
				lastPrint = currentTime;
				state.printFPS();
			}
			
			render.display(state);
			window->display();
			
			if(state.getIncreaseVelocity())
				state.toggleIncreaseVelocity();
		}
	}
Пример #21
0
void MenuSystem::update() {
	if (_currMenuID != _newMenuID) {
		_currMenuID = _newMenuID;
		//debug("_currMenuID = %d", _currMenuID);
		initMenu(_currMenuID);
	}

	handleEvents();

	if (_needRedraw) {
		//_vm->_system->copyRectToScreen(_vm->_screen->_frontScreen + 39 * 640 + 60, 640, 60, 39, 520, 247);
		_vm->_system->copyRectToScreen(_vm->_screen->_frontScreen, 640, 0, _top, 640, 400 - _top);
		_needRedraw = false;
	}

	_vm->_system->delayMillis(5);
}
Пример #22
0
void Application::run() {
	while(m_window.isOpen()) {
		handleEvents();

		m_clock.updateGame([&] {
			m_stateStack.top()->update();
		});

		m_clock.drawGame([&] {
			m_window.clear();

			m_stateStack.top()->draw();

			m_window.update();
		});
	}
}
Пример #23
0
// Set the label text
void ModalProgressDialog::setText(const std::string& text)
{
	// If the aborted flag is set, throw an exception here
	if (_aborted)
	{
		throw OperationAbortedException(_("Operation cancelled by user"));
	}

	// Set the text
	_label->set_markup(text);

	// Pulse the progress bar
	_progressBar->pulse();

	// Handle GTK events to make changes visible
	handleEvents();
}
Пример #24
0
int Application::run()
{
    // run the program as long as the m_window is open
    while (m_window.isOpen())
    {
        // handle events
        handleEvents();

        // update everything
        update();

        // draw everything
        draw();
    }

    return 0;
}
Пример #25
0
int main(int argc, char ** argv)
{
  
  // tests
  tests();
  
  // initialize stuff
  init();
  
  // create landmarks
  if(argc>1)
    loadLandmarks(std::string(argv[1]));
  else
    loadLandmarks("assets/landmarks.txt");

  // prepare variables for the main loop
  current_pose.x = 0;
  current_pose.y = 0;
  current_pose.theta = 0;
  last_captured_pose = current_pose;
  fake_current_pose = current_pose;
  fake_last_captured_pose = current_pose;
  double sleep_time = 0; // used for waiting next step
  
  sf::Clock clock;
  clock.Reset();
  float next_step_time = clock.GetElapsedTime();
  int loop = 0;
  while(true){
    loop = 0;
    
    while((clock.GetElapsedTime() > next_step_time) && (loop < MAX_FRAMESKIP)){
      next_step_time += SKIP_TICKS;
      handleEvents();
      update();
      loop++;
      sleep_time = next_step_time - clock.GetElapsedTime();
      if(sleep_time > 0){
	usleep(sleep_time*1000);
      }
    }
    draw();
  }
  
  return 0;
}
Пример #26
0
int SDLGLMain::run()
{

    while (!m_quit)
    {
        SDL_Event event;
        while (SDL_PollEvent( &event) )
        {
            handleEvents(event);
        }
        draw();
        SDL_Delay(10);
    }


    return 0;
}
Пример #27
0
int
Game::exec()
{
    try{
        init();
        while(!m_end){
            handleEvents();
            update();
            render();
        }
    }catch(std::exception& e){
        std::cerr << "FATAL ERROR : " << e.what() << std::endl;
        cleanUp();
    }
    cleanUp();
    return 0;
}
Пример #28
0
	GLBox()
	{
		App = new sf::Window(sf::VideoMode(RESOLUTION, RESOLUTION, 32), "Spherio");
		
		cameraLookMode = false;
		lastPos[0] = -1;
		lastPos[1] = -1;
		cameraTheta = tiltX = tiltZ = 0;
		cameraPhi = 50;
		gfxinit();
		
		double a[] = {20, 0, -20};
		double b[] = {20, 10, -20};

		double block1Color[3] = {1, 0, 0};
		double block1Center[3] = {2, 0, 0};
		level[0] = Block(block1Color, block1Center, 4, 1, 4, 0, 0);
		double ballColor[3] = {0,1,1};
		double ballCenter[3] = {0,1,0};
		ball = Sphere(ballColor,ballCenter,0.1);

		//double block2Color[3] = {0, 0, 1};
		//double block2Center[3] = {2, 0, -5};
		//level[1] = Block(block2Color, block2Center, 1, 1, 1, 0, 45);
		/*level[2] = Block(0, 0, -200, 0, 10, -200, 2);
		level[3] = Block(0, -10, -20, 0, 10, -20, 2);
		level[4] = Block(-10, 0, -20, 10, 0, -2, 2);
		*/
		//level[0].toString();
		while (App->IsOpened())
		{
			
			App->SetActive();
			
			handleEvents();
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
			
			updateModelviewMatrix();
			for (int i = 0; i < 1; ++i)
			{
				level[i].display();
			}
			ball.display();
			App->Display();
		}
	}
Пример #29
0
void kajiya2D::runKajiya2D()
{
    while (inputHandlerThread_->globalflags_.Running)
    {
        handleEvents();
        if(inputHandlerThread_->globalflags_.displaySpritesLibrary)
        {
            displaySpritesLibrary();
        }
        else
        {
            displayLevel();
        }
        appWindow_->Display();
        appWindow_->Clear();
    }
}
Пример #30
0
int main(void)
{
    initIO();
    initTimer0();
    initA2D();
    initUART();
    initLCD();

    sei();

    while(1)
    {
        handleEvents();
    }

    return 0;
}