64 lines
2.2 KiB
C#
64 lines
2.2 KiB
C#
// See https://aka.ms/new-console-template for more information
|
|
|
|
using System.Numerics;
|
|
using BakeryGame.Components.Player;
|
|
using BakeryGame.Entities;
|
|
using Raylib_cs;
|
|
using Scellecs.Morpeh;
|
|
|
|
namespace BakeryGame;
|
|
|
|
internal class Program
|
|
{
|
|
private static World _world;
|
|
private static int WindowWidth = 800;
|
|
private static int WindowHeight = 480;
|
|
|
|
private unsafe static void Main(string[] args)
|
|
{
|
|
_world = World.Create();
|
|
var playerFactory = new PlayerFactory(_world);
|
|
var blockFactory = new BlockFactory(_world);
|
|
var floorFactory = new FloorFactory(_world);
|
|
Raylib.InitWindow(WindowWidth, WindowHeight, "Hello World");
|
|
|
|
CameraComponent camera;
|
|
var player = playerFactory.CreatePlayer(out camera);
|
|
var block = RoomBuilder.GenerateMapOfBlocks(blockFactory, floorFactory).ToList();
|
|
|
|
var mesh = Raylib.GenMeshPlane(RoomBuilder.RoomSize, RoomBuilder.RoomSize, 10, 10);
|
|
var model = Raylib.LoadModelFromMesh(mesh);
|
|
var texture = Raylib.LoadTexture("plasma.png");
|
|
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
|
|
|
|
// var material = Raylib.LoadMaterialDefault();
|
|
// Raylib.SetMaterialTexture(ref material, MaterialMapIndex.Normal, texture);
|
|
//
|
|
SystemRegistrations.RegisterLogicGroup(_world);
|
|
SystemRegistrations.RegisterGraphicsGroup(_world);
|
|
|
|
Raylib.SetTargetFPS(60);
|
|
while (!Raylib.WindowShouldClose())
|
|
{
|
|
var deltaTime = Raylib.GetFrameTime();
|
|
Raylib.BeginDrawing();
|
|
Raylib.ClearBackground(Color.White);
|
|
Raylib.BeginMode3D(camera.Camera.GetCamera3D());
|
|
_world.Update(deltaTime);
|
|
|
|
Raylib.DrawModel(model, new Vector3(), 1.0f, Color.White);
|
|
//Raylib.DrawGrid(RoomBuilder.RoomSize, 1.0f);
|
|
_world.CleanupUpdate(deltaTime);
|
|
Raylib.EndMode3D();
|
|
Raylib.DrawFPS(WindowWidth - 100, 12);
|
|
_world.LateUpdate(deltaTime);
|
|
_world.Commit();
|
|
Raylib.EndDrawing();
|
|
}
|
|
|
|
Raylib.UnloadModel(model);
|
|
Raylib.UnloadTexture(texture);
|
|
|
|
Raylib.CloseWindow();
|
|
}
|
|
} |