diff --git a/assets/stick.png b/assets/stick.png index 484b512..3955e20 100644 Binary files a/assets/stick.png and b/assets/stick.png differ diff --git a/assets/wooden_axe.png b/assets/wooden_axe.png index 495e2e4..09d6419 100644 Binary files a/assets/wooden_axe.png and b/assets/wooden_axe.png differ diff --git a/build-linux/assets/stick.png b/build-linux/assets/stick.png index 484b512..3955e20 100644 Binary files a/build-linux/assets/stick.png and b/build-linux/assets/stick.png differ diff --git a/build-linux/assets/wooden_axe.png b/build-linux/assets/wooden_axe.png index 495e2e4..09d6419 100644 Binary files a/build-linux/assets/wooden_axe.png and b/build-linux/assets/wooden_axe.png differ diff --git a/build-windows/assets/stick.png b/build-windows/assets/stick.png index 484b512..3955e20 100644 Binary files a/build-windows/assets/stick.png and b/build-windows/assets/stick.png differ diff --git a/build-windows/assets/wooden_axe.png b/build-windows/assets/wooden_axe.png index 495e2e4..09d6419 100644 Binary files a/build-windows/assets/wooden_axe.png and b/build-windows/assets/wooden_axe.png differ diff --git a/src/main.cpp b/src/main.cpp index 21a1db3..8c8f7b0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -659,7 +659,7 @@ int main(void) camera3D.projection = CAMERA_PERSPECTIVE; // 3D Block Textures Setup - Texture2D blockTextures[16] = {0}; + Texture2D blockTextures[32] = {0}; blockTextures[DIRT] = LoadTexture("assets/dirt.png"); blockTextures[GRASS] = LoadTexture("assets/grass.png"); blockTextures[COBBLESTONE] = LoadTexture("assets/cobblestone.png"); @@ -686,6 +686,10 @@ int main(void) blockTextures[STICK] = LoadTexture("assets/stick.png"); blockTextures[WOOD_AXE] = LoadTexture("assets/wooden_axe.png"); + // Explicitly check for successful load and print warning if fail + if (blockTextures[STICK].id == 0) TraceLog(LOG_WARNING, "FAILED TO LOAD STICK TEXTURE"); + if (blockTextures[WOOD_AXE].id == 0) TraceLog(LOG_WARNING, "FAILED TO LOAD AXE TEXTURE"); + // Inventory Crafting State InventorySlot craftingSlots[4]; // Default to AIR/0 InventorySlot craftingResult(AIR, 0); @@ -1054,8 +1058,8 @@ int main(void) DrawTexturePro(titleTexture, sourceRec, destRec, origin, 0.0f, WHITE); EndMode2D(); - // Show Version Number (v1.6.1) in Red - DrawTextEx(customFont, "v1.6.1", (Vector2){ (float)currentWidth - 140, (float)currentHeight - 40 }, 22, 1.0f, RED); + // Show Version Number (v1.6.2) in Red + DrawTextEx(customFont, "v1.6.2", (Vector2){ (float)currentWidth - 140, (float)currentHeight - 40 }, 22, 1.0f, RED); } Vector2 mousePos = GetMousePosition(); @@ -1651,7 +1655,8 @@ int main(void) rlDisableDepthTest(); // Draw on top rlPushMatrix(); - // Transform to camera space manually for the viewmodel + // Build a stable viewmodel matrix + // We use the camera's right/up/forward but dampen the vertical tilt Vector3 forwardVM = Vector3Subtract(camera3D.target, camera3D.position); forwardVM = Vector3Normalize(forwardVM); Vector3 rightVM = Vector3CrossProduct(forwardVM, camera3D.up); @@ -1659,27 +1664,40 @@ int main(void) Vector3 upVM = Vector3CrossProduct(rightVM, forwardVM); upVM = Vector3Normalize(upVM); - Vector3 handPos = Vector3Add(camera3D.position, Vector3Scale(forwardVM, 0.4f)); - handPos = Vector3Add(handPos, Vector3Scale(rightVM, 0.25f)); - handPos = Vector3Add(handPos, Vector3Scale(upVM, -0.2f - swingVal * 0.1f)); + // Horizontal-only forward for arm orientation + Vector3 hForward = { forwardVM.x, 0, forwardVM.z }; + hForward = Vector3Normalize(hForward); - // Draw Arm - DrawCube(handPos, 0.08f, 0.2f, 0.08f, (Color){220, 180, 150, 255}); + float swingVal = sinf(swingTime * PI); + + // Hand position relative to camera + Vector3 handPos = Vector3Add(camera3D.position, Vector3Scale(forwardVM, 0.45f)); + handPos = Vector3Add(handPos, Vector3Scale(rightVM, 0.28f)); + handPos = Vector3Add(handPos, Vector3Scale(upVM, -0.25f - swingVal * 0.15f)); + + // Draw Arm (rotated cube) + // We use rlgl to rotate it to point roughly forward + rlPushMatrix(); + rlTranslatef(handPos.x, handPos.y, handPos.z); + rlRotatef(camYaw * 180.0f/PI, 0, 1, 0); // Yaw with camera + rlRotatef(-20.0f - swingVal * 30.0f, 1, 0, 0); // Slight slant + DrawCube((Vector3){0,0,0}, 0.08f, 0.1f, 0.35f, (Color){220, 180, 150, 255}); + rlPopMatrix(); // Draw Held Item int heldBT = hotbar[activeHotbarSlot].blockType; if (heldBT != AIR) { - Vector3 itemPos = Vector3Add(handPos, Vector3Scale(upVM, 0.1f)); - itemPos = Vector3Add(itemPos, Vector3Scale(forwardVM, 0.1f)); + Vector3 itemPos = Vector3Add(handPos, Vector3Scale(forwardVM, 0.12f)); + itemPos = Vector3Add(itemPos, Vector3Scale(upVM, 0.12f)); + itemPos = Vector3Add(itemPos, Vector3Scale(rightVM, -0.05f)); - if (heldBT < STICK) { - // Block - DrawCube(itemPos, 0.15f, 0.15f, 0.15f, blockTint); - DrawCubeWires(itemPos, 0.151f, 0.151f, 0.151f, BLACK); + Texture2D itemTex = (heldBT == GRASS) ? grassTopTexture : (heldBT == CRAFTING_TABLE ? craftingSideTexture : blockTextures[heldBT]); + if (itemTex.id > 0) { + // Draw as a billboard facing the camera for best clarity + DrawBillboard(camera3D, itemTex, itemPos, 0.18f, WHITE); } else { - // Item (Stick/Axe) - use small thin cube for now - Color itemColor = (heldBT == STICK) ? BROWN : DARKGRAY; - DrawCube(itemPos, 0.03f, 0.25f, 0.03f, itemColor); + // Fallback + DrawCube(itemPos, 0.1f, 0.1f, 0.1f, RED); } } rlPopMatrix();