Example #1
0
void Screen::Draw()
{
	CalculateFps();

	// Reset screen buffer
	memset(buffer, 0, width * height * sizeof(uint));

	DrawSkybox();
	renderer->Render();
	DrawHud();

	if (core->menu)
		core->menu->Draw(drawer);

	// Debug
	sprintf(debug, "fps: %d", frameRate);
	drawer->Draw(debug, 10, 10, 0xffffff);

	if (showMessageTime)
	{
		drawer->Fill(0, 0, width, height - core->art->gamepanel->h, Color::Black);
		drawer->Draw(message, width / 2 - drawer->TextWidth(message) / 2, (height - core->art->gamepanel->h) / 2, 0xffff80);
		--showMessageTime;
	}

	BufferToScreen();
}
Example #2
0
void Update (int timer)
{
   float32 timeStep = 1 /
                      60.0f;    //the length of time passed to simulate (seconds)
   int32 velocityIterations = 6;   //how strongly to correct velocity
   int32 positionIterations = 3;   //how strongly to correct position

   myWorld.Step ( timeStep, velocityIterations, positionIterations);
   for ( b2Body * b = myWorld.GetBodyList (); b; b = b->GetNext () )
   {
      //do something with the body 'b'
      if (b->GetUserData () == 0)
      { break; }
   }
   glutPostRedisplay ();
   CalculateFps ();
   glutTimerFunc (1000.0f / 60.0f , Update, 1);
}