static void Main(string[] args) { RenderWindow app = new RenderWindow(new VideoMode(800, 600), "OMG, it works!"); app.Closed += new EventHandler(OnClose); Color windowColor = new Color(77, 255, 130); CircleShape shape = new CircleShape(10); shape.FillColor = new Color(Color.Red); RectangleShape square = new RectangleShape(); square.FillColor = new Color(Color.Red); square.Position = new Vector2f(app.Size.X / 2, app.Size.Y / 2); square.OutlineColor = new Color(0, 0, 0, 255); square.Size = new Vector2f(50, 50); // Start the game loop while (app.IsOpen()) { // Process events app.DispatchEvents(); // Clear screen app.Clear(windowColor); app.Draw(shape); app.Draw(square); Console.WriteLine(XboxController.RefreshButtonPressed()); Console.WriteLine(XboxController.RefreshAxisPressed()); if (JoyState.HasFlag(ControllerState.DPAD_UP_PRESSED)) { square.Position = new Vector2f(square.Position.X, square.Position.Y - 1); } if (JoyState.HasFlag(ControllerState.DPAD_DOWN_PRESSED)) { square.Position = new Vector2f(square.Position.X, square.Position.Y + 1); } if (JoyState.HasFlag(ControllerState.DPAD_LEFT_PRESSED)) { square.Position = new Vector2f(square.Position.X - 1, square.Position.Y); } if (JoyState.HasFlag(ControllerState.DPAD_RIGHT_PRESSED)) { square.Position = new Vector2f(square.Position.X + 1, square.Position.Y); } // Update the window app.Display(); } }
private void EngineDraw() { Window.Clear(ClearColor); Draw(); Window.DispatchEvents(); Window.Display(); }
public static void Main() { var window = new RenderWindow(new VideoMode(1536, 864), "SFML works!"); window.Closed += CloseWindow; window.KeyPressed += KeyPressed; _renderer = new Renderer(window, 16); playerLogic.PosUpdate += _renderer.UpdatePlayerPosition; var rnd = new Random(); var map = new List <bool>(); for (int i = 0; i < 10000; ++i) { map.Add(rnd.Next() % 4 != 1); } _renderer.Map = new Map(100, 100, map); playerLogic.Map = _renderer.Map; while (window.IsOpen()) { window.DispatchEvents(); _renderer.Render(); window.Display(); } }
public void Run() { rs = new RenderSystem(typeof(RenderComponent), typeof(TransformComponent)); ts = new TransformSystem(typeof(TransformComponent)); SystemManager.RegSystem(ts); RenderThread = new Thread(() => { Window.SetActive(true); while (Window.IsOpen) { _mutex.WaitOne(); rs.Update(); Window.Display(); _mutex.ReleaseMutex(); } }); RenderThread.Start(); while (Window.IsOpen) { _perfomance.Restart(); Console.WriteLine(_dt.ElapsedTime.AsMilliseconds()); if (_dt.ElapsedTime.AsMilliseconds() > 1000 / FPS) { Window.DispatchEvents(); SystemManager.Update(); _dt.Restart(); } //Console.WriteLine(_perfomance.ElapsedTime.AsMilliseconds()); } }
public void Run() { var mode = new VideoMode(Utils.WIDTH, Utils.HEIGHT); window = new RenderWindow(mode, "Discord Painter"); window.Closed += (_, __) => window.Close(); window.MouseButtonPressed += Window_MouseButtonPressed; window.MouseMoved += Window_MouseMoved; window.MouseButtonReleased += Window_MouseButtonReleased; gui = new Gui(window); canvas = new Canvas(); pressed = false; CreateGUI(); while (window.IsOpen) { window.DispatchEvents(); window.Clear(); canvas.Render(ref window); gui.Draw(); window.Display(); } }
public void StartGameLoop() { while (_window.IsOpen) { // check wave progress if (_targets.Count == 0) { NextWave(); } _window.DispatchEvents(); _window.Clear(Color.Black); DrawScore(); // Move player if (_arrowKeyDown != Direction.NONE) { _player.Move(_arrowKeyDown, screenRect); } // draw player _player.Draw(_window); // draw all targets to the screen foreach (Target t in _targets) { if (!_isSolving) { t.Oscillate(_waveOscilatingDir); } t.Draw(_window); } // revert target direction when outer targets hit the screen edge if (_targets.Count > 0 && Target.HasOuterTargetHitScreenEdge(_targets)) { if (_waveOscilatingDir == Direction.LEFT) { _waveOscilatingDir = Direction.RIGHT; } else if (_waveOscilatingDir == Direction.RIGHT) { _waveOscilatingDir = Direction.LEFT; } } if (_isSolving) { DrawEquationSolver(); } else { HandleTargetCollision(); } // refresh screen _window.Display(); } }
public void Run() { if (true == game.LoadGrid("Levels/level1.txt")) { window.SetActive(); while ((lastKeyPressed != Keyboard.Key.Escape) && window.IsOpen && (game.Update(lastKeyPressed) == EndGameResult.NotFinished)) { window.Clear(Color.Black); window.DispatchEvents(); game.Draw(window); window.Display(); } // <MikaGauthier> if (game.Update(lastKeyPressed) == EndGameResult.Win) { System.Windows.Forms.MessageBox.Show("Vous avez gagné", "Bravo !!!"); } else if (game.Update(lastKeyPressed) == EndGameResult.Losse) { System.Windows.Forms.MessageBox.Show("Vous avez perdu", "Et zut !!!"); } // </MikaGauthier> } else { System.Windows.Forms.MessageBox.Show("Format de fichier invalide.\n\nL'application va se terminer", "Erreur lors du chargement"); } }
/// <summary> /// Primary game loop. /// </summary> /// <param name="clock"></param> /// <param name="currentTime"></param> protected void Loop(Clock clock) { double newTime = clock.ElapsedTime.AsSeconds(); double frameTime = newTime - ct; if (frameTime > secondsPerFrame) { frameTime = secondsPerFrame; } ct = newTime; accumulator += frameTime; window.Clear(Color.Black); window.DispatchEvents(); while (accumulator >= deltatime) { Update(); accumulator -= deltatime; } Render(); window.Display(); }
static void Main(string[] args) { RenderWindow app = new RenderWindow(new VideoMode(800, 600), "Metonic Calendar"); app.Closed += new EventHandler(OnClose); Nodes nodes = new Nodes(); Sun sun = new Sun(nodes); Moon moon = new Moon(); IMetonicYear year = new MetonicYear(); IMonth month = new Month(year, sun, moon); Day day = new Day(month, year); SunCount sunCount = new SunCount(sun); Control controller = new Control(year, month, day, moon, sunCount, nodes, sun); controller.SetYearZero(); Color windowColor = new Color(255, 255, 255); while (app.IsOpen) { app.DispatchEvents(); app.Clear(windowColor); DrawCalendar(app, nodes, sun, moon, year, month, day, sunCount); app.Display(); controller.AddDay(); Thread.Sleep(1000); } }
static void Main(string[] args) { Orm.InitAsync().Wait(); Settings.Init(); MusicService.Init(); var mode = new VideoMode(800, 600); Window = new RenderWindow(mode, "YeomenSaga"); Window.Closed += (x, y) => Close(); Window.SetVerticalSyncEnabled(Settings.Instance.Vsync); // Services. SceneService.Init(Window); Fonts.Init(); Navigate(SceneService.TitleScene); while (Window.IsOpen) { lock (_lock) { CurrentScene.Progress(); Window.DispatchEvents(); Window.Clear(Color.Black); Window.Draw(CurrentScene); Window.Display(); } } }
static void Main(string[] args) { Height = Screen.PrimaryScreen.Bounds.Height; Width = Screen.PrimaryScreen.Bounds.Width; _Window.SetVerticalSyncEnabled(true); #region Events _Window.KeyPressed += _Window_KeyPressed; _Window.MouseButtonPressed += _Window_MouseButtonPressed; #endregion while (IsRunning) { _Window.DispatchEvents(); _Window.Clear(Color.Black); PathFinding x = new PathFinding(); x.FindPath(new SFML.System.Vector2i(0, 0), new SFML.System.Vector2i(29, 24), ref grid); grid.Draw(_Window); _Window.Display(); } }
static void Main(string[] args) { Content.Load(); // подгрузка текстур game = new Game(); window = new RenderWindow(new VideoMode(960, 540), "Game", Styles.Default); //window.SetFramerateLimit(60); view = new View(new FloatRect(0, 0, 960, 540)); world1 = new World(3, 3); game.UpdateAsync(world1); view.Center = new Vector2f(480, 270); window.SetView(view); game.Initialize(world1.WORLD_SIZE_X, world1.WORLD_SIZE_Y, world1.chunks); game.MouseClickAsync(); window.Closed += Win_Closed; while (window.IsOpen) { window.DispatchEvents(); window.SetView(view); window.Clear(new Color(63, 139, 191)); game.Draw(); window.Display(); } }
static void Main(string[] args) { mainWindow.Closed += new EventHandler(OnClose); mainWindow.KeyPressed += new EventHandler <KeyEventArgs>(OnKeyPressed); mainWindow.MouseWheelMoved += new EventHandler <MouseWheelEventArgs>(OnMouseScroll); mainWindow.MouseButtonPressed += new EventHandler <MouseButtonEventArgs>(OnClick); mainWindow.SetMouseCursorVisible(false); while (mainWindow.IsOpen) { mainWindow.DispatchEvents(); mainWindow.Clear(Color.White); mainWindow.Draw(nodeGrid); mainWindow.Draw(mainGrid); mainWindow.SetView(mainView); mainWindow.Draw(mainCursor); mainWindow.Draw(nodeCursor); for (int index = 0; index < logicEntities.Count; index++) { mainWindow.Draw(logicEntities[index]); } for (int index = 0; index < nodes.Count; index++) { mainWindow.Draw(nodes[index]); } mainWindow.Display(); } }
static void Main(string[] args) { Window = new RenderWindow(new VideoMode(800, 600), "My Terraria!"); Window.SetVerticalSyncEnabled(true); Window.Closed += Win_Closed; Window.Resized += Win_Resized; Window.KeyPressed += Win_KeyPressed; // Загрузка контента Content.Load(); Game = new Game(); // Создаём новый объект класса игры Clock clock = new Clock(); while (Window.IsOpen) { Delta = clock.Restart().AsSeconds(); Window.DispatchEvents(); Game.Update(); Window.Clear(Color.Cyan); Game.Draw(); Window.Display(); } }
/// <summary> /// Fonction dont le rôle est de lancer le jeu /// </summary> public void Run() { //Ajout des étoiles dans le jeu for (int i = 0; i < 250; i++) { stars.Add(new Star((r.Next(0, WIDTH)), r.Next(0, r.Next(0, HEIGHT)), DELTA_T)); } // ppoulin // Chargement de la StringTable. A décommenter au moment opportun if (ErrorCode.OK == StringTable.GetInstance().Parse(File.ReadAllText("Data/st.txt"))) { window.SetActive(); //Tant que la fenêtre est ouverte while (window.IsOpen) { //Afficher le contenu à l'écran window.Clear(Color.Black); window.DispatchEvents(); if (false == Update()) { break; } Draw(); window.Display(); } } }
public static void Main() { Init(); while (app.IsOpen) { app.DispatchEvents(); app.Clear(); states[currentState].Render(); if (deltaClock.ElapsedTime.AsMilliseconds() >= states[currentState].TickRate) { states[currentState].Update(deltaClock.ElapsedTime.AsMilliseconds() / 5); deltaClock.Restart(); } if (netClock.ElapsedTime.AsMilliseconds() >= states[currentState].NetTickRate) { states[currentState].ProcessNetworkMessages(); netClock.Restart(); } app.Display(); } }
// ReSharper disable once UnusedParameter.Local private static void Main(string[] args) { var image = new Image("cp437_16x16.png"); image.CreateMaskFromColor(Color.Black); var texture = new Texture(image); uint glyphWidth = 16; uint glyphHeight = 16; var renderWindow = new RenderWindow( new VideoMode(WidthInGlyphs * glyphWidth, HeightInGlyphs * glyphHeight), "Sokoban", Styles.Close | Styles.Titlebar); renderWindow.Closed += (s, e) => renderWindow.Close(); var windowColor = Color.Black; var terminal = new Terminal((int)glyphHeight, (int)glyphWidth, texture, renderWindow); var root = CreateRoot(glyphWidth, glyphHeight); root.IsFocused = true; renderWindow.KeyPressed += (s, e) => root.NotifyKeyboardInput(new SfmlInput(e)); renderWindow.MouseButtonPressed += (s, e) => root.NotifyMouseInput(new SfmlInput(e)); while (renderWindow.IsOpen && root.IsFocused) { renderWindow.Clear(windowColor); renderWindow.DispatchEvents(); root.Draw(terminal); renderWindow.Display(); } }
public void HandleMenu(RenderWindow window) { window.DispatchEvents(); window.Clear(); Menu.Display(window); window.Display(); }
private static void Main() { GameWindow = CreateRenderWindow(1366, 768, "Ideological War 1948", new ContextSettings()); var WindowMoving = new WindowMoving(GameWindow); Panels = new List <Panel>(); CurrentGameData = new GameData() { Provinces = MapLoader.LoadProvinces(@"data\country1.svg") }; var clock = new Clock(); while (GameWindow.IsOpen) { var dt = clock.Restart(); GameWindow.DispatchEvents(); UpdateGame(GameWindow, dt); Panels.RemoveAll(p => p.ToDelete); WindowMoving.Update(dt); GameWindow.Clear(); DrawGame(GameWindow, dt); foreach (var panel in Panels) { GameWindow.Draw(panel); } GameWindow.Display(); } }
public void Run() { BuiltinShaderRepository.SHADER_REPO = "../PlainCore.Shaders/Shaders/"; var window = new RenderWindow(); window.View.Viewport = new FloatRectangle(0, 0, 800, 600); var texture1 = PlainCore.Graphics.Texture.FromFile(window.Device, "Images/Planet.png"); var texture2 = PlainCore.Graphics.Texture.FromFile(window.Device, "Images/Moon.png"); var batch = new SpriteBatch(window.Device); var font = FontLoader.LoadFromTruetypeFont(window.Device, "Fonts/OpenSans-Regular.ttf", 40); var clock = new Clock(); while (window.IsOpen) { window.DispatchEvents(); window.Clear(RgbaFloat.CornflowerBlue); batch.Begin(window); batch.Draw(texture1, 0, 0, 800f, 600f); font.Draw(batch, "Test.", 0, 0, RgbaFloat.Red); batch.End(); window.Display(); } Environment.Exit(0); }
public void Run() { r = new Random(); Clock c = new Clock(); GenerateImage(); int dur = c.ElapsedTime.AsMilliseconds(); duration.DisplayedString = Convert.ToString(dur); ContextSettings cs = new ContextSettings(); cs.AntialiasingLevel = 4; VideoMode mode = new VideoMode(800, 600, 32); RenderWindow window = new RenderWindow(mode, "Space Scene Window", Styles.Close | Styles.Titlebar, cs); window.Closed += (object sender, EventArgs e) => window.Close(); window.KeyPressed += KeyPress; while (window.IsOpen) { window.DispatchEvents(); window.Clear(); window.Draw(s); window.Draw(duration); window.Display(); } }