public void Run(uint desiredFps) { bool quit = false; uint ticksPerFrame = FPSToTicksPerFrame(desiredFps); uint ticks; while (!quit) { _timer.Start(); SDL.SDL_Event e; while (SDL.SDL_PollEvent(out e) != 0) { switch (e.type) { case SDL.SDL_EventType.SDL_QUIT: quit = true; break; case SDL.SDL_EventType.SDL_KEYDOWN: _input.KeyboardBindings.UpdateStateAndDispatchEvents(); break; case SDL.SDL_EventType.SDL_KEYUP: _input.KeyboardBindings.UpdateStateAndDispatchEvents(); break; case SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN: this.HandleMouseButtonEvent(e); break; case SDL.SDL_EventType.SDL_MOUSEBUTTONUP: this.HandleMouseButtonEvent(e); break; } } _scene.Render(); ticks = _timer.GetElapsedTicks(); if (ticks < ticksPerFrame) { _timer.Sleep((ticksPerFrame - ticks)); } double elapsedMillisecods = _timer.GetElapsedTicks() / 10000.0; _physics.Update(elapsedMillisecods); elapsedMillisecods = _timer.GetElapsedTicks() / 10000.0; _updater.UpdateObjects(elapsedMillisecods); } }