public void SimulateFrame() { // TODO: Not sure about creating hundreds of objects per second. // Doesn't seem to cause high memory usage, but further investigation is needed. PreUpdate.Raise(this, new UpdateEventArgs(_monitor.FrameRate, _monitor.LastFrameTime, UpdateTimeStep)); _unprocessedTime += _monitor.LastFrameTime; _updates = 0; while (_unprocessedTime >= UpdateTimeStep && _updates < MaxSkippedFrames) { OnUpdate.Raise(this, new UpdateEventArgs(_monitor.FrameRate, _monitor.LastFrameTime, UpdateTimeStep)); _simulationEngine.Simulate(); _unprocessedTime -= UpdateTimeStep; _updates++; } PostUpdate.Raise(this, new UpdateEventArgs(_monitor.FrameRate, _monitor.LastFrameTime, UpdateTimeStep)); if (EnableRender) { _renderer.Frame(); _renderer.Render(); } }
protected override void Update(GameTime gameTime) { OnPreUpdate.Raise(this, new GameTimeEventArgs(gameTime)); OnUpdate.Raise(this, new GameTimeEventArgs(gameTime)); base.Update(gameTime); OnPostUpdate.Raise(this, new GameTimeEventArgs(gameTime)); }