// holds runs all events needed per update tick public static void MainLoop(object sender, EventArgs e) { // update the current time Time.UpdateTime(); // update all inputs Input.UpdateInputs(); GameForm.debug2 = ObjectManager.totalNumberOfObjects.ToString(); // tell GameObjects to run the Awake method OnAwakeMethod?.Invoke(); // tell GameObjects to run the Start method OnStartMethod?.Invoke(); // if its time for a fixed update... if (Time.time - Time.lastFixedUpdateTime >= fixedUpdateTime) { // update the real time it took between fixed updates Time.UpdateFixedDeltaTime(); // tell GameObjects to run the FixedUpdate method OnInvokeMethod?.Invoke("FixedUpdate"); // tell GameObjects to run the OnPhysicsUpdate method OnPhysicsUpdate?.Invoke(); // update the real time it took between updates } // update the real time it took between updates Time.UpdateDeltaTime(); // tell GameObjects to run the Update method OnInvokeMethod?.Invoke("Update"); // run any additional code AdditionalFrameCode(); // tell GameObjects to submit all drawing information OnDrawObjects?.Invoke(); // render the frame EngineRenderer.Render(); }
public void FixedUpdate() { OnPhysicsUpdate.Invoke(); }