Advertisement
EEJesse

EEPhysics Exmaple

Jul 10th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. using PlayerIOClient;
  5. using EEPhysics;
  6.  
  7. namespace Enter_Project_Name
  8. {
  9.     class Program
  10.     {
  11.         private static Connection Connection { get; set; }
  12.         private static PhysicsWorld World { get; set; }
  13.  
  14.         static void Main(string[] args)
  15.         {
  16.             Connection = PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", "guest", "guest", null).Multiplayer.JoinRoom("PW01", null);
  17.             World = new PhysicsWorld();
  18.  
  19.             Connection.OnMessage += (sender, m) =>
  20.             {
  21.                 World.HandleMessage(m);
  22.                 if (m.Type == "init") Connection.Send("init2");
  23.                 else if (m.Type == "init2") StalkPlayers();
  24.             };
  25.             Connection.Send("init");
  26.  
  27.             Thread.Sleep(-1);
  28.         }
  29.  
  30.         private static async void StalkPlayers()
  31.         {
  32.             while (true)
  33.             {
  34.                 foreach (var player in World.Players.Values)
  35.                 {
  36.                     Connection.Send("b", 0, (int)player.X / 16, (int)player.Y / 16, 9);
  37.                     await Task.Delay(10);
  38.                 }
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement