From 11a7308820dbed89d5f974e03ab825b1ee7e2115 Mon Sep 17 00:00:00 2001 From: Nefrace Date: Sun, 14 Apr 2024 23:31:49 +0300 Subject: [PATCH] Textured floor, some tests of matrices --- src/main.odin | 31 ++++++++++++++++++++++++++++++- src/player.odin | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main.odin b/src/main.odin index 7f3b1dd..9b8a274 100644 --- a/src/main.odin +++ b/src/main.odin @@ -30,6 +30,17 @@ main :: proc() { rl.InitWindow(800, 400, "By The Fire") rl.SetTargetFPS(60) + + img := rl.GenImageChecked(64, 64, 8, 8, PAL[1], PAL[2]) + defer rl.UnloadImage(img) + tex := rl.LoadTextureFromImage(img) + defer rl.UnloadTexture(tex) + rl.SetTextureFilter(tex, rl.TextureFilter.POINT) + + plane := rl.GenMeshPlane(32, 32, 16, 16) + defer rl.UnloadMesh(plane) + mat := rl.LoadMaterialDefault() + rl.SetMaterialTexture(&mat, rl.MaterialMapIndex.ALBEDO, tex) player := player_create() @@ -43,7 +54,25 @@ main :: proc() { BeginMode3D(player.camera) ClearBackground(PAL[0]) - DrawPlane({0, 0, 0}, {32,32}, PAL[1]) + rlPushMatrix() + rlRotatef(45, 0, 1, 0) + DrawMesh(plane, mat, rl.MatrixIdentity()) + rlPopMatrix() + + + rlPushMatrix() + rlTranslatef(player.position.x, player.position.y, player.position.z) + rlTranslatef(player.cameraOffset.x, player.cameraOffset.y, player.cameraOffset.z) + rlRotatef(math.to_degrees(player.direction), 0, 1, 0) + rlRotatef(math.to_degrees(-player.yaw), 1, 0, 0) + rlTranslatef(-1, -0.3, 1) + rlScalef(0.5, 0.5, 0.5) + DrawCube({0, 0, 0}, 1,1,1, PAL[4]) + rlTranslatef(0, 0, 1) + rlScalef(0.4, 0.4, 1) + DrawCube({0, 0, 0}, 1,1,1, PAL[4]) + + rlPopMatrix() EndMode3D() EndDrawing() diff --git a/src/player.odin b/src/player.odin index b7c0869..862f02e 100644 --- a/src/player.odin +++ b/src/player.odin @@ -18,6 +18,7 @@ player_create :: proc() -> Player { camera = rl.Camera3D{ up = {0, 1, 0}, fovy = 80, + target = {0, 0, 10}, projection = rl.CameraProjection.PERSPECTIVE, }, }