/// <summary> /// Runs main Visualisation loop. /// </summary> public void Run() { var mode = new SFML.Window.VideoMode(width, height); var window = new SFML.Graphics.RenderWindow(mode, visualisation.GetType().ToString()); window.KeyPressed += Window_KeyPressed; window.SetFramerateLimit(FPS); // Start the game loop while (window.IsOpen) { visualisation.Update(); window.Clear(); // Process events window.DispatchEvents(); visualisation.Draw(window); // Finally, display the rendered frame on screen window.Display(); } visualisation.Quit(); soundBuffer.Dispose(); window.Close(); }
public void startWindow(uint width, uint height) { window = new SFML.Graphics.RenderWindow(new SFML.Window.VideoMode(width, height), "window"); window.Resized += new EventHandler <SFML.Window.SizeEventArgs>(onResize); window.Closed += new EventHandler(onClosed); window.SetActive(); }
public InputHandler(SFML.Graphics.RenderWindow window) { //Defining the Commands here _go = new GoCommand(); _jump = new JumpCommand(); turnCommand = new TurnCommand(); attack = new AttackCommand(); //Building the Commandlist commandList = new List <Command>(); GameCommandList = new List <GameCommand>(); restartCommand = new restartCommand(); //Setup the Joysticksettings joystickNr = 0; setupJoystick(joystickNr); //Setup the Keys of the Keyboard setupKeyboard(); caX = new CommandAttributes(1); caY = new CommandAttributes(0, 1); caXN = new CommandAttributes(-1); caYN = new CommandAttributes(0, -1); timed = new CommandAttributes(Time.FromSeconds(.5f)); mousePosition = Mouse.GetPosition(); this.window = window; }
public void update(SFML.Graphics.RenderWindow window) { int decider = random.Next(2); if (decider == 0) { if (this.Position.X - 100 > 0) { this.Position = new SFML.System.Vector2f(this.Position.X - 100, 100); this.airshipShape.Position = this.Position; } else if (this.Position.X - 100 <= 0) { this.Position = new SFML.System.Vector2f(80, 100); this.airshipShape.Position = this.Position; } } else if (decider == 1) { if (this.Position.X + 100 < 720) { this.Position = new SFML.System.Vector2f(this.Position.X + 100, 100); this.airshipShape.Position = this.Position; } else if (this.Position.X + 100 >= 720) { this.Position = new SFML.System.Vector2f(780, 100); this.airshipShape.Position = this.Position; } } }
public void draw(GameTime gameTime, SFML.Graphics.RenderWindow window) { foreach (Particle particle in particles) { particle.draw(gameTime, window); } }
static SFML.Graphics.RenderWindow InitWindow() { SFML.Graphics.RenderWindow window = new SFML.Graphics.RenderWindow(VideoMode.FullscreenModes[0], "Space Shooter", Styles.Fullscreen); window.SetVerticalSyncEnabled(true); window.SetFramerateLimit(61); return(window); }
private void CreateSFMLWindow() { if (MainWindow != null) { throw new InvalidOperationException("Cannot recreate SFML window once created!"); } Styles sfmlStyles = 0; switch (CurrentMode.Style) { case WindowStyle.Windowed: sfmlStyles = Styles.Titlebar | Styles.Close; break; case WindowStyle.FullScreen: sfmlStyles = Styles.Fullscreen; break; } var sfmlContext = new ContextSettings(0, 0); MainWindow = new SFML.Graphics.RenderWindow( new VideoMode( (uint)CurrentMode.Width, (uint)CurrentMode.Height, 64 ), Title, sfmlStyles, sfmlContext); }
/// <summary> /// Constructor /// </summary> /// <param name="app"></param> public WindowManager(SFML.Graphics.RenderWindow app) { front = null; windows = new List <Window>(); App = app; App.MouseButtonPressed += OnMouseDown; }
public void drawFront(SFML.Graphics.RenderWindow window, Camera cam, Vec2f relPos) { if (m_sprite_front != null) { m_sprite_front.Position = relPos * Camera.m_FieldSize; window.Draw(m_sprite_front); } }
public void drawGround(SFML.Graphics.RenderWindow window, Camera cam, Vec2f relPos) { if (m_sprite_ground != null) { m_sprite_ground.Position = relPos * Camera.m_FieldSize; window.Draw(m_sprite_ground); } }
public Canvas() { InitializeComponent(); renderwindow = new SFML.Graphics.RenderWindow(this.Handle); PreviewKeyDown += Canvas_PreviewKeyDown; KeyDown += Canvas_KeyDown; KeyUp += Canvas_KeyUp; }
public IGraphicsContext CreateWindow(string title, Size size, SFML.Window.Styles style = SFML.Window.Styles.Default) { SFML.Window.ContextSettings contextSettings = new SFML.Window.ContextSettings(24, 8, 8); var mode = new SFML.Window.VideoMode((uint)size.Width, (uint)size.Height); var window = new SFML.Graphics.RenderWindow(mode, title, style); window.SetFramerateLimit(_frameRate); return(new GraphicsContext(window)); }
public void Draw(SFML.Graphics.RenderWindow target) { target.DispatchEvents(); SFML.Graphics.RectangleShape background = new SFML.Graphics.RectangleShape(new SFML.System.Vector2f(800f, 600f)); background.Texture = SFML.Graphics.Sprite.; target.Draw(background); player.Draw(target); obstacle.Draw(target); target.Display(); }
override internal void handle(msg.Startup startup) { base.handle(startup); var mode = new SFML.Window.VideoMode(1280, 1024); m_window = new SFML.Graphics.RenderWindow(mode, "Client"); m_window.KeyPressed += Window_KeyPressed; m_state = State.Running; }
static void w_MouseMoved(object sender, SFML.Window.MouseMoveEventArgs e) { if (_point.HasValue) { SFML.Window.Vector2f newPoint = new SFML.Window.Vector2f(e.X, e.Y); SFML.Window.Vector2f delta = _point.Value - newPoint; SFML.Graphics.RenderWindow w = (SFML.Graphics.RenderWindow)sender; w.SetView(new SFML.Graphics.View(w.GetView().Center + delta, w.GetView().Size)); _point = newPoint; } }
static void Main(string[] args) { SFML.Window.VideoMode mode = new SFML.Window.VideoMode(800, 600); SFML.Graphics.RenderWindow window = new SFML.Graphics.RenderWindow(mode, "Flappy Bird"); GameState myState = new GameState(); while (true) { myState.Update(); myState.Draw(window); } }
public void drawSelecRect(SFML.Graphics.RenderWindow window, Vec2f topLeft, Vec2f bottomRight) { float Xstart = Math.Min(topLeft.X, bottomRight.X); float Xend = Math.Max(topLeft.X, bottomRight.X); float Ystart = Math.Min(topLeft.Y, bottomRight.Y); float Yend = Math.Max(topLeft.Y, bottomRight.Y); m_sprite = new SFML.Graphics.Sprite(Helper.t_DebugWhite, new SFML.Graphics.IntRect(0, 0, (int)(Xstart - Xend), (int)(Ystart - Yend))); m_sprite.Position = new Vec2f(Xstart, Ystart); m_sprite.Color = new SFML.Graphics.Color(0, 128, 0, 128); window.Draw(m_sprite); }
public void Run() { GameManager gameManager = new GameManager(); //Window Options var mode = new SFML.Window.VideoMode(WINDOW, WINDOW); var window = new SFML.Graphics.RenderWindow(mode, "Malikaz Snake"); //Keyboard Event Handlers window.KeyPressed += Window_KeyPressed; window.KeyPressed += gameManager.SetMoveDirection; window.KeyPressed += gameManager.RestartGame; //Time DateTime timer1 = DateTime.Now; // Start the game loop while (window.IsOpen) { System.Threading.Thread.Sleep(5); //Clear Window window.Clear(); DateTime timer2 = DateTime.Now; // Process events window.DispatchEvents(); TimeSpan timeSinceLastUpdate = timer2 - timer1; if (timeSinceLastUpdate.TotalSeconds >= .1 && gameManager.GameIsActive == true) { gameManager.MoveSnake(ref gameManager.snakeArray); gameManager.CheckForColision(ref gameManager.snakeArray, ref gameManager.food); timer1 = DateTime.Now; } else if (gameManager.GameIsActive == false) { window.Draw(gameManager.gameText.GameOverText); } for (int counter = 0; counter < gameManager.snakeArray.Length; counter++) { if (gameManager.snakeArray[counter].IsActive == true) { window.Draw(gameManager.snakeArray[counter].SnakeShape); } } window.Draw(gameManager.gameText.ScoreText); window.Draw(gameManager.food.FoodShape); // Finally, display the rendered frame on screen window.Display(); } }
public void draw(SFML.Graphics.RenderWindow window, Camera camera) { if (m_active) { // Red Rectangle m_active_sprite.Position = m_position; m_active_sprite.Color = new SFML.Graphics.Color(255, 0, 0); window.Draw(m_active_sprite); } updateSprite(); m_sprite.Position = m_position; window.Draw(m_sprite); }
public void Create(int lastZedIndex) { ZedIndex = _currentZedIndex = lastZedIndex; Theme = (Theme)Activator.CreateInstance(Application.ThemeType); _graphicsContext = _graphicsDriver.CreateWindow(Title, Size); _nativeWindow = _graphicsContext.Window; NativeHandle = _graphicsContext.NativeWindowHandle; Theme.GraphicsContext = _graphicsContext; WindowManager.Add(this); EventManager.RegisterEvents(_graphicsContext.Window); }
public void drawMinimap(SFML.Graphics.RenderWindow window, Camera cam) { m_minimapSprite.Color = new SFML.Graphics.Color(0, 0, 0); m_minimapSprite.Position = cam.m_minimapPosition; window.Draw(m_minimapSprite); for (int i = 0; i < m_fields.X; i++) { for (int j = 0; j < m_fields.Y; j++) { m_map[i, j].drawMiniMap(window, cam, new Vec2f(i, j)); } } }
public void Render(SFML.Graphics.RenderWindow renderWindow) { if (texture is FramedTexture) { FramedTexture framed = (FramedTexture)texture; framed.Position = position; framed.Render(renderWindow); } else { renderWindow.Draw(sprite); } }
static void Main(string[] args) { SFML.Graphics.RenderWindow window = InitWindow(); BackgroundManager bg = new BackgroundManager(); Dialog d = new Dialog("1"); Battlefield battle = new Battlefield(window); ManageMenu menu = new ManageMenu(); while (window.IsOpen) { window.Clear(); if (d.Active && !menu.Active) { d.Update(); } if (menu.Active) { menu.Update(); } if (!menu.Active && !d.Active) { battle.Update(); } window.Draw(bg); if (battle.Player.Life > 0) { window.Draw(battle); } else { battle = new Battlefield(window); menu.Active = true; // d = new Dialog("1"); } if (d.Active) { window.Draw(d); } if (menu.Active) { window.Draw(menu); } window.Display(); } }
public void Update(SFML.Graphics.RenderWindow window, orientation orientation, List <IObject> list, Stopwatch touch, Stopwatch shot) { if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Left) && (_sprite.Position.X - 0.1f > 0)) { _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X - 0.1f, _sprite.Position.Y); } else if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Right) && (_sprite.Position.X + 0.1f < window.Size.X - 32)) // !!! Moins la taille du sprite { _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X + 0.1f, _sprite.Position.Y); } else if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Up) && (_sprite.Position.Y - 0.1f > 0)) { _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X, _sprite.Position.Y - 0.1f); } else if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Down) && (_sprite.Position.Y + 0.1f < window.Size.Y - 32)) { _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X, _sprite.Position.Y + 0.1f); } if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Space)) { if (touch.ElapsedMilliseconds >= 200) { list.Add(new Shot(_sprite.Position, _userShipData._weaponSprite, _userShipData._damage, _userShipData._fireRate)); touch.Restart(); } } for (var x = 0; x < list.Count; x++) { if (list[x].isEnemy()) { if (list[x]._sprite.Position.X <= _sprite.Position.X && _sprite.Position.X <= list[x]._sprite.Position.X + 32 && list[x]._sprite.Position.Y <= _sprite.Position.Y && _sprite.Position.Y <= list[x]._sprite.Position.Y + 32) { if (shot.ElapsedMilliseconds >= 200) { _life--; if (_life <= 0) { list.Remove(this); } shot.Restart(); } } } } }
private void DrawPreviewNoLighting(SFML.Graphics.RenderWindow rw) { foreach (var layer in m_previewLayers) { foreach (var d in layer) { rw.Draw(d); } if (layer == m_previewLayers[(int)Layer.Background] && checkBoxSnap.Checked) { rw.Draw(m_grid); } } }
public void update(SFML.Graphics.RenderWindow window, orientation orientation, List <IObject> list, Stopwatch touch, Stopwatch shot) { if (orientation == orientation.vertical) { _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X, _sprite.Position.Y + 0.03f); } else if (orientation == orientation.horizontal) { _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X + 0.03f, _sprite.Position.Y); } if (_sprite.Position.X > window.Size.X || _sprite.Position.Y > window.Size.Y) { list.Remove(this); } }
public void drawGround(SFML.Graphics.RenderWindow window, Camera cam) { for (int i = 0; i < m_fields.X; i++) { for (int j = 0; j < m_fields.Y; j++) { if ((!(i * Camera.m_FieldSize < cam.m_topPosition.X - 100)) && (!(j * Camera.m_FieldSize < cam.m_topPosition.Y - 100)) && (!(i * Camera.m_FieldSize > cam.m_topPosition.X + window.Size.X + 100)) && (!(j * Camera.m_FieldSize > cam.m_topPosition.Y + window.Size.Y + 100))) { m_map[i, j].drawGround(window, cam, new Vec2f(i, j)); } } } }
//////////////////////___CONSTRUCTORS___////////////////////// #region Constructors public Control(SFML.Graphics.RenderWindow window) { List <SFML.Window.Keyboard.Key> usedkeys = new List <SFML.Window.Keyboard.Key>(); usedkeys.Add(SFML.Window.Keyboard.Key.W); usedkeys.Add(SFML.Window.Keyboard.Key.A); usedkeys.Add(SFML.Window.Keyboard.Key.S); usedkeys.Add(SFML.Window.Keyboard.Key.D); usedkeys.Add(SFML.Window.Keyboard.Key.Q); usedkeys.Add(SFML.Window.Keyboard.Key.LControl); usedkeys.Add(SFML.Window.Keyboard.Key.Space); Keyboard = new KeyboardInput(usedkeys); Mouse = new MouseInput(window); }
public InputEvents(CluwneWindow window) { // if dummy don't attach events if (window == null) { return; } SFML.Graphics.RenderWindow SWindow = window.SFMLWindow; SWindow.KeyPressed += (sender, args) => KeyPressed?.Invoke(sender, (KeyEventArgs)args); SWindow.KeyReleased += (sender, args) => KeyReleased?.Invoke(sender, (KeyEventArgs)args); SWindow.MouseButtonPressed += (sender, args) => MouseButtonPressed?.Invoke(sender, (MouseButtonEventArgs)args); SWindow.MouseButtonReleased += (sender, args) => MouseButtonReleased?.Invoke(sender, (MouseButtonEventArgs)args); SWindow.MouseMoved += (sender, args) => MouseMoved?.Invoke(sender, (MouseMoveEventArgs)args); SWindow.MouseWheelScrolled += (sender, args) => MouseWheelMoved?.Invoke(sender, (MouseWheelScrollEventArgs)args); SWindow.MouseEntered += (sender, args) => MouseEntered?.Invoke(sender, args); SWindow.MouseLeft += (sender, args) => MouseLeft?.Invoke(sender, args); SWindow.TextEntered += (sender, args) => TextEntered?.Invoke(sender, (TextEventArgs)args); }
public void Run() { var mode = new SFML.Window.VideoMode(WindowX, WindowY); var window = new SFML.Graphics.RenderWindow(mode, "Point Wrapper"); window.KeyPressed += Window_KeyPressed; while (window.IsOpen) { window.DispatchEvents(); for (int counter = 0; counter < drawables.Length; counter++) { if (drawables[counter] != null) { window.Draw(drawables[counter]); } } window.Display(); } }
private void Form2_Load(object sender, EventArgs e) { using (NetworkDialog dialog = new NetworkDialog()) { dialog.ShowDialog(); if (!dialog.checkBox1.Checked && (string.IsNullOrEmpty(dialog.textBox2.Text) || string.IsNullOrEmpty(dialog.textBox1.Text))) { Close(); return; } networkOptions.Name = dialog.textBox1.Text; networkOptions.IP = dialog.textBox2.Text; networkOptions.Hosting = dialog.checkBox1.Checked; } if (networkOptions.Hosting) server = new Networking.NetworkServer(); else client = new Networking.NetworkClient(System.Net.IPAddress.Parse(networkOptions.IP), networkOptions.Name); renderWindow = new SFML.Graphics.RenderWindow(pictureBox1.Handle, new ContextSettings(32, 0, 12)); renderWindow.Resized += new EventHandler<SizeEventArgs>(render_Resized); //renderWindow.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(renderWindow_MouseButtonPressed); //renderWindow.MouseButtonReleased += new EventHandler<MouseButtonEventArgs>(renderWindow_MouseButtonReleased); //renderWindow.MouseMoved += new EventHandler<MouseMoveEventArgs>(renderWindow_MouseMoved); renderWindow.KeyPressed += new EventHandler<SFML.Window.KeyEventArgs>(renderWindow_KeyPressed); renderWindow.KeyReleased += new EventHandler<SFML.Window.KeyEventArgs>(renderWindow_KeyReleased); renderWindow.Show(true); InitOpenGL(pictureBox1.Size, _currentZoom, PointF.Empty); Tao.FreeGlut.Glut.glutInit(); Il.ilInit(); Ilut.ilutInit(); _debugDraw = new GDIDebugThing(); if (networkOptions.Hosting) { // Define the gravity vector. Vector2 gravity = new Vector2(0.0f, -17.0f); // Construct a world object, which will hold and simulate the rigid bodies. FarseerPhysics.Settings.UseFPECollisionCategories = true; FarseerPhysics.Settings.PositionIterations = 8; FarseerPhysics.Settings.VelocityIterations = 16; world = new World(gravity); world.ContactManager.BeginContact += BeginContact; { float bottom = (float)(86); float left = (float)(86); FixtureFactory.CreateEdge(world, new Vector2(-left, -bottom), new Vector2(left, -bottom)).Body.UserData = new GroundBodyDescriptor(); FixtureFactory.CreateEdge(world, new Vector2(-left, bottom), new Vector2(-left, -bottom)).Body.UserData = new GroundBodyDescriptor(); FixtureFactory.CreateEdge(world, new Vector2(left, bottom), new Vector2(left, -bottom)).Body.UserData = new GroundBodyDescriptor(); FixtureFactory.CreateEdge(world, new Vector2(left, bottom), new Vector2(-left, bottom)).Body.UserData = new GroundBodyDescriptor(); } players[0] = new Player(world, new Vector2(-24, 0), 9, 9); players[1] = new Player(world, new Vector2(24, 0), -9, 9); } simulationThread = new System.Threading.Thread(SimulationLoop); simulationThread.Start(); }