+ 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
+64
View File
@@ -0,0 +1,64 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace client
{
internal class KillZone
{
private Vector2 Position;
private int Width;
private int Height;
public bool isLeft = true;
public bool Debug = false;
public KillZone(Vector2 position, int width, int height)
{
Position = position;
Width = width;
Height = height;
}
public void Draw(SpriteBatch spriteBatch, GraphicsDevice graphicsDevice)
{
Texture2D texture = new Texture2D(graphicsDevice, this.Width, this.Height);
Color[] data = new Color[this.Width * this.Height];
for (int i = 0; i < data.Length; ++i)
{
if (Debug)
{
data[i] = Color.Red;
} else
{
data[i] = Color.Transparent;
}
}
texture.SetData(data);
spriteBatch.Draw(texture, this.Position, Color.White);
}
public void Collisions(Ball ball)
{
if (this.isLeft)
{
if (ball.Position.X < this.Position.X + this.Width && ball.CanMove)
{
ball.StopMoving();
}
}
else
{
if (ball.Position.X > this.Position.X && ball.CanMove)
{
ball.StopMoving();
}
}
}
}
}