static void Main(string[] args) { string IPAddress = "127.0.0.1"; ushort Port = 8355; Networking.NetworkServer server = Networking.NetworkServer.Instance(); server.Start(IPAddress, Port); Networking.NetworkActionProcessor processor = new Networking.NetworkActionProcessor(ref Networking.NetworkServer.recvQueue); while (true) { string input = Console.ReadLine(); Console.WriteLine(input); } }
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(); }
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(); }