public Game() { Started = false; Running = false; // Setup Window Bounds = new FloatRect(0, 0, ResolutionDefault.X, ResolutionDefault.Y); WindowSettings = new ContextSettings(); WindowSettings.AntialiasingLevel = 6; CreateWindow(); // Black Bars (for fullscreen) Layer_BlackBars = new Layer(); RectangleShape BlackBarLeft = new RectangleShape(new Vector2f(2000, 5000)); BlackBarLeft.Position = new Vector2f(-BlackBarLeft.Size.X, 0); BlackBarLeft.FillColor = new Color(0, 0, 0); Layer_BlackBars.AddChild(BlackBarLeft); RectangleShape BlackBarRight = new RectangleShape(new Vector2f(2000, 5000)); BlackBarRight.Position = new Vector2f(Size.X, 0); BlackBarRight.FillColor = new Color(0, 0, 0); Layer_BlackBars.AddChild(BlackBarRight); // Setup Layer_Background = new Layer(); Layer_Other = new Layer(); Layer_Objects = new Layer(); Layer_OtherAbove = new Layer(); Layer_GUI = new Layer(); // Start Menu StartMenu = new StartMenu(this); Layer_GUI.AddChild(StartMenu); Music = new Music("assets/audio/music/Speed Pirate - LuigiSounds.ogg"); Music.Loop = true; Music.Play(); // Game Loop Stopwatch clock = new Stopwatch(); clock.Start(); while (Window.IsOpen()) { // Process events Window.DispatchEvents(); if (clock.Elapsed.TotalSeconds >= (1.0f / FPS)) { if (CloseNextUpdate) { Window.Close(); return; } // Clear screen Window.Clear(); // Update Game Update((float)clock.Elapsed.TotalSeconds); clock.Restart(); // Draw Game Draw(); // Update the window Window.Display(); } } }
private void OnKeyReleased(Object sender, KeyEventArgs e) { switch (e.Code) { case Keyboard.Key.Escape: { if (StartMenu != null) return; if (Running) { PauseMenu = new PauseMenu(this); Layer_GUI.AddChild(PauseMenu); } else if (PauseMenu != null) Layer_GUI.RemoveChild(PauseMenu); break; } case Keyboard.Key.F11: ToggleFullscreen(); break; // Testing case Keyboard.Key.F2: { GraphicsMode = GraphicsMode == GRAPHICSMODE_NORMAL ? GRAPHICSMODE_BLUEPRINT : GRAPHICSMODE_NORMAL; if (!Started) { if (StartMenu != null) Layer_GUI.RemoveChild(StartMenu); StartMenu = new StartMenu(this); Layer_GUI.AddChild(StartMenu); } else Reset(); } break; #if DEBUG case Keyboard.Key.F3: DEBUG_MOUSE_CONTROLS = !DEBUG_MOUSE_CONTROLS; break; case Keyboard.Key.F5: Player.StartPowerup(Powerup.DOUBLE_EXPLOSION_RADIUS); break; case Keyboard.Key.F6: Player.StartPowerup(Powerup.AIM_SPEED_INCREASE); break; case Keyboard.Key.F7: Player.StartPowerup(Powerup.FREEZE_TIME); break; case Keyboard.Key.F8: Player.StartPowerup(Powerup.RED_HOT_BEACH); break; case Keyboard.Key.F9: Player.StartPowerup(Powerup.TRIPLE_CANNON); break; case Keyboard.Key.F10: Player.StartPowerup(Powerup.OCTUPLE_CANNON); break; #endif } }
private void OnKeyReleased(Object sender, KeyEventArgs e) { switch (e.Code) { case Keyboard.Key.Escape: { if (StartMenu != null) { return; } if (Running) { PauseMenu = new PauseMenu(this); Layer_GUI.AddChild(PauseMenu); } else if (PauseMenu != null) { Layer_GUI.RemoveChild(PauseMenu); } break; } case Keyboard.Key.F11: ToggleFullscreen(); break; // Testing case Keyboard.Key.F2: { GraphicsMode = GraphicsMode == GRAPHICSMODE_NORMAL ? GRAPHICSMODE_BLUEPRINT : GRAPHICSMODE_NORMAL; if (!Started) { if (StartMenu != null) { Layer_GUI.RemoveChild(StartMenu); } StartMenu = new StartMenu(this); Layer_GUI.AddChild(StartMenu); } else { Reset(); } } break; #if DEBUG case Keyboard.Key.F3: DEBUG_MOUSE_CONTROLS = !DEBUG_MOUSE_CONTROLS; break; case Keyboard.Key.F5: Player.StartPowerup(Powerup.DOUBLE_EXPLOSION_RADIUS); break; case Keyboard.Key.F6: Player.StartPowerup(Powerup.AIM_SPEED_INCREASE); break; case Keyboard.Key.F7: Player.StartPowerup(Powerup.FREEZE_TIME); break; case Keyboard.Key.F8: Player.StartPowerup(Powerup.RED_HOT_BEACH); break; case Keyboard.Key.F9: Player.StartPowerup(Powerup.TRIPLE_CANNON); break; case Keyboard.Key.F10: Player.StartPowerup(Powerup.OCTUPLE_CANNON); break; #endif } }