Example #1
0
        /// <summary>
        /// Main game loop - update - draw - sleep
        /// </summary>
        private void GameLoop()
        {
            LoadGui();
            LoadSolarSystem();
            LoadKernels();

            Dispatcher.BeginInvoke(new Action(OnFinishLoading), DispatcherPriority.Render, null);

            _camera = new Camera(_gravitationalBodies[_targetIndex], 0.3);
            //_camera = new Camera(_gravitationalBodies[_targetIndex], 5000);

            _timeStepIndex = TimeStep.RealTimeIndex;
            _timeSteps     = TimeStep.Defaults();

            var frameTimer = new FpsManager(60);

            while (_isActive)
            {
                frameTimer.StartFrame();

                TimeStep timeStep = _timeSteps[_timeStepIndex];

                Update(timeStep);
                DrawFrame(timeStep, frameTimer);
                WriteFrameToScreen();

                frameTimer.FinishFrame();
            }
        }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();
            InitializeScreen();

            LoadGui();
            LoadSolarSystem();
            LoadKernels();

            _camera = new Camera(_gravitationalBodies[_targetIndex], 0.3);
            //_camera = new Camera(_gravitationalBodies[_targetIndex], 5000);

            _timeStepIndex = TimeStep.RealTimeIndex;
            _timeSteps     = TimeStep.Defaults();

            _isPaused     = true;
            _isActive     = true;
            _updateThread = new Thread(GameLoop);
            _updateThread.Start();
        }