protected override void Update(GameTime gameTime) { Network.totalTime = gameTime.TotalGameTime.Milliseconds; ks = Keyboard.GetState(); ms = Mouse.GetState(); if ((ks.IsKeyDown(Keys.LeftAlt) || ks.IsKeyDown(Keys.RightAlt)) && ks.IsKeyDown(Keys.F4)) { this.Exit(); } if (inGame) { lockMouse = me.IsActive; IsMouseVisible = !me.IsActive; world.Update(gameTime); } else { if (!loading) { if (ks.IsKeyDown(Keys.Space) && lastks.IsKeyUp(Keys.Space)) { world = new World(10, 10, false); ThreadPool.QueueUserWorkItem(new WaitCallback(world.load), 16); NetworkHost.listenForConnections(7777); } else if (ks.IsKeyDown(Keys.F) && lastks.IsKeyUp(Keys.F)) { //NetworkClient.tryConnect("68.7.50.111",7777); // jon NetworkClient.tryConnect("98.176.183.63", 7777); // me //NetworkClient.tryConnect("192.168.1.144", 7777); // dad //NetworkClient.tryConnect("127.0.0.1", 7777); // local me } } } fpstime += (float)gameTime.ElapsedGameTime.TotalSeconds; if (fpstime >= 1f) { fps = frames; fpstime = 0; frames = 0; } lastks = ks; lastms = ms; base.Update(gameTime); }
static void Main(string[] args) { Thread backThread = new Thread(new ThreadStart(delegate() { using (Main game = new Main()) { game.Run(); } })); backThread.Start(); backThread.Join(); QuadTree.Main.inGame = false; NetworkHost.shutdown(); NetworkClient.shutdown(); }