Files
voxel/Player.cs
maxwes08 b6655d71d9 update
2025-09-09 10:57:28 +02:00

39 lines
851 B
C#

using OpenTK.Mathematics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Voxel
{
public class Player
{
public Vector3 Position;
private World _world;
public Player(World world, Vector3 startPos)
{
_world = world;
}
public void BreakBlock()
{
var (success, hit, x, y, z) = _world.Raycast(Camera.Position, Camera.Front * 10, 100);
if (!success) return;
_world.SetBlock(x, y, z, Blocks.Air);
}
public void Update(float deltaTime)
{
Camera.Update(deltaTime);
if (Input.GetKey(OpenTK.Windowing.GraphicsLibraryFramework.Keys.Space))
{
BreakBlock();
}
}
}
}