public void Update(Player player, Ball ball) { if (ball.Position.Y > player.Position.Y + player.Origin.Y * 0.8f) player.MoveDown(); else if (ball.Position.Y < player.Position.Y - player.Origin.Y * 0.8f) player.MoveUp(); }
public World(BaseScreen parent, GameMode mode) { this.parent = parent; this.mode = mode; // Static variables top = (int)(-parent.GetCamera().Viewport.Height * 0.5f); bottom = -top; left = (int)(-parent.GetCamera().Viewport.Width * 0.5f); right = -left; p1 = new Player(parent.LoadTexture("Player")); p2 = new Player(parent.LoadTexture("Player")); ball = new Ball(parent.LoadTexture("Ball")); p1.Position = new Vector2(-parent.GetCamera().Viewport.Width * 0.45f, 0); p2.Position = new Vector2(parent.GetCamera().Viewport.Width * 0.45f, 0); switch (mode) { case GameMode.AI: c1 = new PlayerController(Keys.Up, Keys.Down); //AI2 = new PlayerAI(); playerAI = new PlayerAI(); break; case GameMode.Versus: c1 = new PlayerController(Keys.W, Keys.S); c2 = new PlayerController(Keys.Up, Keys.Down); break; case GameMode.Host: running = true; listener = new TcpListener(IPAddress.Any, 50000); connThread = new Thread(new ThreadStart(ConnectionListener)); connThread.Start(); break; case GameMode.Client: break; } }
public void Update(Player player, Ball ball) { }