diff --git a/Program.cs b/Program.cs
index 476637c..dc73294 100644
--- a/Program.cs
+++ b/Program.cs
@@ -32,7 +32,7 @@ static Config Settings(string file)
unsafe int Game()
{
var config = Settings("config.toml");
- InitWindow(config.Width, config.Height, $"PlayBark");
+ InitWindow(config.Width, config.Height, "PlayBark");
var pos = new Vector3(0.2f, 0.4f, 0.2f);
var target = new Vector3(0.0f, 0.0f, 0.0f);
@@ -41,13 +41,12 @@ unsafe int Game()
var imMap = LoadImage("resources/cubicmap.png");
var cubicmap = LoadTextureFromImage(imMap);
- var mesh = GenMeshCubicmap(imMap, new Vector3(1.0f, 1.0f, 1.0f));
- var model = LoadModelFromMesh(mesh);
+ var model = World3D.CubicMap(imMap);
var texture = LoadTexture("resources/cubicmap_atlas.png");
// Set map diffuse texture
- SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
+ Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
// Get image map data to be used for collission
var mapPixels = LoadImageColors(imMap);
@@ -60,9 +59,7 @@ unsafe int Game()
while (!WindowShouldClose())
{
- BeginDrawing();
- ClearBackground(Color.White);
-
+ // Update
var oldCamPos = camera.Position;
UpdateCamera(ref camera, CameraMode.FirstPerson);
@@ -117,7 +114,7 @@ unsafe int Game()
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawModel(model, mapPosition, 1.0f, Color.White);
- EndMode2D();
+ EndMode3D();
DrawTextureEx(cubicmap, new Vector2(GetScreenWidth() - cubicmap.Width * 4 - 20, 20), 0.0f, 4.0f, Color.White);
DrawRectangleLines(GetScreenWidth() - cubicmap.Width * 4 - 20, 20, cubicmap.Width * 4, cubicmap.Height * 4, Color.Green);
diff --git a/World3D.cs b/World3D.cs
index abf4a9a..be70601 100644
--- a/World3D.cs
+++ b/World3D.cs
@@ -1,8 +1,19 @@
// I hereby waive this project under the public domain - see UNLICENSE for details.
namespace PlayBark;
+///
+/// Provides utilities for creating and managing 3D world elements, including camera setup and map generation.
+///
internal static class World3D
{
+ ///
+ /// Creates and returns a configured Camera3D instance.
+ ///
+ /// The position of the camera in 3D space.
+ /// The point the camera is looking at.
+ /// The up direction for the camera.
+ /// The projection type of the camera.
+ /// A configured Camera3D instance.
public static Camera3D Camera(Vector3 pos, Vector3 target, Vector3 up, CameraProjection projection)
{
var camera = new Camera3D();
@@ -14,4 +25,17 @@ internal static class World3D
return camera;
}
+
+ ///
+ /// Generates a 3D cubic map model from a given image map.
+ ///
+ /// The image used to generate the cubic map.
+ /// A Model representing the cubic map.
+ public static Model CubicMap(Image imMap)
+ {
+ var mesh = GenMeshCubicmap(imMap, new Vector3(1.0f, 1.0f, 1.0f));
+ var model = LoadModelFromMesh(mesh);
+
+ return model;
+ }
}
\ No newline at end of file