+ KillZone & Ball Movements (bases)

This commit is contained in:
2022-10-18 12:14:02 +02:00
parent 55b74246e9
commit 1d93d70024
4 changed files with 209 additions and 23 deletions
+32 -7
View File
@@ -9,6 +9,8 @@ namespace client
private Player pl1;
private Player pl2;
private Ball ball;
private KillZone killZone1;
private KillZone killZone2;
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
@@ -28,7 +30,7 @@ namespace client
15,
100,
100f
);
).SetControllable(true);
pl2 = new Player(
new Vector2(_graphics.PreferredBackBufferWidth - 30, _graphics.PreferredBackBufferHeight / 2 - 50),
@@ -41,11 +43,27 @@ namespace client
ball = new Ball(
new Vector2(_graphics.PreferredBackBufferWidth / 2 - 5, _graphics.PreferredBackBufferHeight / 2 - 5),
10,
0.5f,
0.1f,
100
0.2f
);
// KILLZONE
killZone1 = new KillZone(
new Vector2(0, 0),
15,
_graphics.PreferredBackBufferHeight
);
killZone2 = new KillZone(
new Vector2(_graphics.PreferredBackBufferWidth - 15, 0),
15,
_graphics.PreferredBackBufferHeight
);
killZone2.isLeft = false;
// TEST
ball.StartMoving();
base.Initialize();
}
@@ -56,9 +74,13 @@ namespace client
protected override void Update(GameTime gameTime)
{
/*if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();*/
pl1.InputsControls(gameTime, _graphics.PreferredBackBufferHeight);
ball.Move(gameTime, _graphics.PreferredBackBufferHeight, _graphics.PreferredBackBufferWidth, pl1, pl2);
killZone1.Collisions(ball);
killZone2.Collisions(ball);
base.Update(gameTime);
}
@@ -72,6 +94,9 @@ namespace client
ball.Draw(_spriteBatch, GraphicsDevice);
killZone1.Draw(_spriteBatch, GraphicsDevice);
killZone2.Draw(_spriteBatch, GraphicsDevice);
_spriteBatch.End();
base.Draw(gameTime);
}