public PicoGame() { Instance = this; PicoPlatform.Initialize(); _gfx = new PicoGfx(); _input = new PicoInput(); PicoPlatform.TerminateRequested += (sender, args) => this.Quit(); PicoPlatform.DisplayResized += OnDisplayResize; PicoPlatform.GamePadAdded += (sender, gamepadDesc) => _input.AddGamePad(gamepadDesc); PicoPlatform.GamePadRemoved += (sender, slot) => _input.RemoveGamePad(slot); }
internal void UpdateState() { _prevKeyboardState = _curKeyboardState; _curKeyboardState = PicoPlatform.GetKeyboardState(); _prevMouseState = _curMouseState; _curMouseState = PicoPlatform.GetMouseState(); foreach (var gamepad in _gamepads) { gamepad.Value.Update(PicoPlatform.GetGamepadState(gamepad.Key)); } }
/// <summary> /// Creates the platform for the specified project using the specified /// platform name. /// </summary> /// <param name="project">The project to create a platform for.</param> /// <param name="platformName">The name of the platform to create.</param> /// <returns></returns> public Platform CreatePlatform(Project project, string platformName) { Platform pl; switch (platformName.ToLower()) { case "picocomputer": pl = new PicoPlatform(project, Program.MainForm); break; default: throw new ArgumentException("Platform \"" + platformName + "\" is not supported.", "platformName"); } pl.Initialize(); return(pl); }
public void Start() { _running = true; if (!Fullscreen) { PicoPlatform.SetDisplaySize(DisplaySize); } else { PicoPlatform.SetDisplayFullscreen(true); } _gfx.Initialize(PicoPlatform.DisplHandle, DisplaySize.Width, DisplaySize.Height); PicoPlatform.ShowDisplay(); _gameTimer = Stopwatch.StartNew(); _gameTime = new GameTime() { Delta = TimeSpan.Zero, Total = TimeSpan.Zero }; float dt; while (_running) { _gameTime.Delta = _gameTimer.Elapsed - _gameTime.Total; _gameTime.Total = _gameTimer.Elapsed; PicoPlatform.ProcessEvents(); _input.UpdateState(); dt = (float)_gameTime.Delta.TotalSeconds; Update(dt); if (!_displayModeChanged) { _gfx.Begin(); Draw(_gfx); _gfx.End(); } else { if (_fullscreen) { PicoPlatform.SetDisplayFullscreen(true); } else { PicoPlatform.SetDisplayFullscreen(false); PicoPlatform.SetDisplaySize(_requestedDisplaySize); } _displayModeChanged = false; } if (_titleChanged) { PicoPlatform.SetTitle(_title); _titleChanged = false; } } }
public void Dispose() { _gfx.Dispose(); PicoPlatform.Shutdown(); }