Added ui labels for debugging and playability
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using OpenTK.Mathematics;
|
||||
using System.Net.Sockets;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
using Voxel.Core;
|
||||
using Voxel.Graphics;
|
||||
using Voxel.UI;
|
||||
|
||||
namespace Voxel.Entities
|
||||
{
|
||||
@@ -15,11 +17,14 @@ namespace Voxel.Entities
|
||||
private int _jumpTicks = 0;
|
||||
|
||||
private Blocks _selectedBlock = Blocks.OakPlanks;
|
||||
private Vector3 previousPosition;
|
||||
private Vector3 _previousPosition;
|
||||
private Label _positionLabel = new Label("Position:", 16, 48, 24, Vector4.One);
|
||||
private Label _blockLabel = new Label("Selected Block:", 16, 80, 24, Vector4.One);
|
||||
|
||||
public Player(Vector3 startPos, World world) : base(startPos, 0.5f, 1.8f, world)
|
||||
{
|
||||
Input.OnMouseWheel += SwitchBlock;
|
||||
_blockLabel.Text = $"Selected block: {_selectedBlock}";
|
||||
}
|
||||
|
||||
public void PlaceBlock()
|
||||
@@ -48,7 +53,7 @@ namespace Voxel.Entities
|
||||
|
||||
_world.UpdateChunkLoading(Position);
|
||||
|
||||
previousPosition = Position;
|
||||
_previousPosition = Position;
|
||||
|
||||
float forwards = 0;
|
||||
float sidewards = 0;
|
||||
@@ -94,6 +99,8 @@ namespace Voxel.Entities
|
||||
}
|
||||
}
|
||||
else _jumpTicks = 0;
|
||||
|
||||
_positionLabel.Text = $"Position: {Position.X:F2}, {Position.Y:F2}, {Position.Z:F2}";
|
||||
}
|
||||
|
||||
public void Jump()
|
||||
@@ -104,9 +111,12 @@ namespace Voxel.Entities
|
||||
|
||||
public void Update(float deltaTime, float alpha)
|
||||
{
|
||||
Camera.Position = Vector3.Lerp(previousPosition, Position, alpha) + Vector3.UnitY * 1.62f;
|
||||
Camera.Position = Vector3.Lerp(_previousPosition, Position, alpha) + Vector3.UnitY * 1.62f;
|
||||
Rotation = Camera.Yaw;
|
||||
|
||||
Renderer.RenderLabel(_positionLabel);
|
||||
Renderer.RenderLabel(_blockLabel);
|
||||
|
||||
if (lastClick > 0)
|
||||
{
|
||||
lastClick -= deltaTime;
|
||||
@@ -159,7 +169,7 @@ namespace Voxel.Entities
|
||||
|
||||
_blockIndex = (_blockIndex + direction + count) % count;
|
||||
_selectedBlock = BlockDefinitions.CreativeInventory[_blockIndex];
|
||||
|
||||
_blockLabel.Text = $"Selected block: {_selectedBlock}";
|
||||
Console.WriteLine(_selectedBlock);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user