Пример #1
0
 public void Awake()
 {
     name              = "Player";
     renderer.sprite   = EngineRenderer.LoadTexture("Images/Player65.png");
     renderer.tint     = Color.White;
     rigidbody.enabled = true;
     GameForm.debug3   = "Gravity OFF";
     rigidbody.gravity = Vector2.Down * 2024;
 }
Пример #2
0
        // 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();
        }
Пример #3
0
        // GameForm constructor
        public GameForm()
        {
            // set static instance to this GameForm
            if (instance == null)
            {
                instance = this;
            }

            InitializeComponent();
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);

            EngineRenderer.Initialize(this);
            Input.Initialize(this);

            // tell core to initialize the game engine
            Core.Initialize();
            // tell core to start the engine
            Core.Start();
#if DEBUG
            //if in debug mode, start with debug info being shown
            showDebug = true;
#endif
        }