Files
voxel/Player.cs
2025-09-03 00:37:42 +02:00

41 lines
854 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 (hit, x, y, z) = _world.Raycast(5f); // max 5 blocks
if (hit != Blocks.Air)
{
_world.SetBlock(x, y, z, Blocks.Air);
}
}
public void Update(float deltaTime)
{
Camera.Update(deltaTime);
if (Input.GetKey(OpenTK.Windowing.GraphicsLibraryFramework.Keys.Space))
{
BreakBlock();
}
}
}
}