MorriCraft v2.3.4: Fixed apple texture format (JPEG to PNG), refined eating logic to prevent block placement, and added UI fallbacks
This commit is contained in:
parent
4b915379e8
commit
28c674c19b
|
|
@ -106,7 +106,7 @@ A pre-built `MorriCraft-Windows.zip` is available in the repository root.
|
||||||
|
|
||||||
## 📜 Version History
|
## 📜 Version History
|
||||||
|
|
||||||
### v2.3.3 - Major Update: Smoother Update Progress & Final Polish (Current)
|
### v2.3.4 - Major Update: Refined Eating Mechanics & Texture Fixes (Current)
|
||||||
- **Hunger System**: Added player hunger bar, starvation mechanics, and health regeneration when full.
|
- **Hunger System**: Added player hunger bar, starvation mechanics, and health regeneration when full.
|
||||||
- **Apple Item**: Added edible Apple item to restore hunger.
|
- **Apple Item**: Added edible Apple item to restore hunger.
|
||||||
- **Grass Texture**: Improved `grass_top` texture with better pixel art.
|
- **Grass Texture**: Improved `grass_top` texture with better pixel art.
|
||||||
|
|
|
||||||
BIN
assets/apple.png
BIN
assets/apple.png
Binary file not shown.
|
Before Width: | Height: | Size: 427 KiB After Width: | Height: | Size: 14 KiB |
|
|
@ -1 +1 @@
|
||||||
v2.3.3
|
v2.3.4
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 427 KiB After Width: | Height: | Size: 14 KiB |
|
|
@ -1 +1 @@
|
||||||
v2.3.3
|
v2.3.4
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 427 KiB After Width: | Height: | Size: 14 KiB |
|
|
@ -1 +1 @@
|
||||||
v2.3.3
|
v2.3.4
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
v2.3.3
|
v2.3.4
|
||||||
|
|
|
||||||
51
src/main.cpp
51
src/main.cpp
|
|
@ -395,7 +395,7 @@ void RebuildChunkRenderList(Chunk* chunk, int cx, int cz) {
|
||||||
|
|
||||||
unsigned char faces = GetExposedFaces(lx, ly, lz, chunk, nxM, nxP, nzM, nzP);
|
unsigned char faces = GetExposedFaces(lx, ly, lz, chunk, nxM, nxP, nzM, nzP);
|
||||||
if (faces != 0) {
|
if (faces != 0) {
|
||||||
// Simple Torch Lighting (v2.3.3)
|
// Simple Torch Lighting (v2.3.4)
|
||||||
float blockLight = 0.0f;
|
float blockLight = 0.0f;
|
||||||
Vector3 bPos = {(float)(worldX+lx), (float)ly, (float)(worldZ+lz)};
|
Vector3 bPos = {(float)(worldX+lx), (float)ly, (float)(worldZ+lz)};
|
||||||
for (const auto& tp : torchPositions) {
|
for (const auto& tp : torchPositions) {
|
||||||
|
|
@ -705,7 +705,7 @@ float FindSpawnY(int spawnX, int spawnZ) {
|
||||||
// Feet land at top of block (y + 0.5).
|
// Feet land at top of block (y + 0.5).
|
||||||
// We use +0.6f + 1.6f to ensure we start slightly ABOVE the block
|
// We use +0.6f + 1.6f to ensure we start slightly ABOVE the block
|
||||||
// to avoid getting stuck in collision on frame 1.
|
// to avoid getting stuck in collision on frame 1.
|
||||||
// v2.3.3: Spawn higher (feet at y + 1.5, eyes at y + 3.1) to avoid ground-clipping
|
// v2.3.4: Spawn higher (feet at y + 1.5, eyes at y + 3.1) to avoid ground-clipping
|
||||||
return (float)y + 1.5f + 1.6f;
|
return (float)y + 1.5f + 1.6f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -746,7 +746,7 @@ void GenerateChunk(int cx, int cz) {
|
||||||
// Combine: broad hills (±12) + local detail (±4) = up to ±16 around Y=32
|
// Combine: broad hills (±12) + local detail (±4) = up to ±16 around Y=32
|
||||||
int height = 32 + (int)(continentNoise * 12.0f) + (int)(detailNoise * 4.0f);
|
int height = 32 + (int)(continentNoise * 12.0f) + (int)(detailNoise * 4.0f);
|
||||||
|
|
||||||
// Spawn Plateau (v2.3.3): Smoothly flatten area around (0,0)
|
// Spawn Plateau (v2.3.4): Smoothly flatten area around (0,0)
|
||||||
float distToSpawn = sqrtf(worldX * worldX + worldZ * worldZ);
|
float distToSpawn = sqrtf(worldX * worldX + worldZ * worldZ);
|
||||||
if (distToSpawn < 12.0f) {
|
if (distToSpawn < 12.0f) {
|
||||||
float plateauStrength = 1.0f - (distToSpawn / 12.0f);
|
float plateauStrength = 1.0f - (distToSpawn / 12.0f);
|
||||||
|
|
@ -758,7 +758,7 @@ void GenerateChunk(int cx, int cz) {
|
||||||
if (height < 10) height = 10;
|
if (height < 10) height = 10;
|
||||||
if (height >= CHUNK_HEIGHT - 2) height = CHUNK_HEIGHT - 2;
|
if (height >= CHUNK_HEIGHT - 2) height = CHUNK_HEIGHT - 2;
|
||||||
|
|
||||||
// Biome noise: determines surface type (v2.3.3: 4x larger biomes)
|
// Biome noise: determines surface type (v2.3.4: 4x larger biomes)
|
||||||
float biomeNoise = fbm(worldX * 0.002f, worldZ * 0.002f, globalSeedHash + 77777);
|
float biomeNoise = fbm(worldX * 0.002f, worldZ * 0.002f, globalSeedHash + 77777);
|
||||||
|
|
||||||
for (int y = 0; y <= height; y++) {
|
for (int y = 0; y <= height; y++) {
|
||||||
|
|
@ -1043,7 +1043,7 @@ int main(void)
|
||||||
// By default, windows have minimize, maximize, and close buttons on the top bar.
|
// By default, windows have minimize, maximize, and close buttons on the top bar.
|
||||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT);
|
SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT);
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "MorriCraft v2.3.3");
|
InitWindow(screenWidth, screenHeight, "MorriCraft v2.3.4");
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
SetExitKey(KEY_NULL); // Prevent ESC from closing the window
|
SetExitKey(KEY_NULL); // Prevent ESC from closing the window
|
||||||
|
|
||||||
|
|
@ -1114,7 +1114,7 @@ int main(void)
|
||||||
float updateTimer = 0.0f;
|
float updateTimer = 0.0f;
|
||||||
float downloadProgress = 0.0f;
|
float downloadProgress = 0.0f;
|
||||||
std::string latestVersion = "";
|
std::string latestVersion = "";
|
||||||
std::string localVersion = "v2.3.3"; // Default fallback
|
std::string localVersion = "v2.3.4"; // Default fallback
|
||||||
|
|
||||||
// Read local version
|
// Read local version
|
||||||
std::ifstream vfile("assets/version.txt");
|
std::ifstream vfile("assets/version.txt");
|
||||||
|
|
@ -1726,7 +1726,7 @@ int main(void)
|
||||||
|
|
||||||
|
|
||||||
// --- GLOBAL TIME & AUDIO MANAGEMENT ---
|
// --- GLOBAL TIME & AUDIO MANAGEMENT ---
|
||||||
float cycleLength = 600.0f; // Slower day cycle (v2.3.3: cut speed in half)
|
float cycleLength = 600.0f; // Slower day cycle (v2.3.4: cut speed in half)
|
||||||
if (currentState == GAMEPLAY) {
|
if (currentState == GAMEPLAY) {
|
||||||
gameTime += GetFrameTime();
|
gameTime += GetFrameTime();
|
||||||
|
|
||||||
|
|
@ -2139,7 +2139,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
NetSetBlock(hitX, hitY, hitZ, AIR);
|
NetSetBlock(hitX, hitY, hitZ, AIR);
|
||||||
|
|
||||||
// Tool Durability Logic (v2.3.3)
|
// Tool Durability Logic (v2.3.4)
|
||||||
InventorySlot* slot = &hotbar[activeHotbarSlot];
|
InventorySlot* slot = &hotbar[activeHotbarSlot];
|
||||||
if (slot->maxDurability > 0) {
|
if (slot->maxDurability > 0) {
|
||||||
slot->durability--;
|
slot->durability--;
|
||||||
|
|
@ -2162,12 +2162,15 @@ int main(void)
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) {
|
if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) {
|
||||||
// NEW: Eating Logic
|
// NEW: Eating Logic
|
||||||
if (hotbar[activeHotbarSlot].blockType == APPLE && playerHunger < 20.0f) {
|
if (hotbar[activeHotbarSlot].blockType == APPLE) {
|
||||||
|
if (playerHunger < 20.0f) {
|
||||||
playerHunger += 4.0f;
|
playerHunger += 4.0f;
|
||||||
if (playerHunger > 20.0f) playerHunger = 20.0f;
|
if (playerHunger > 20.0f) playerHunger = 20.0f;
|
||||||
hotbar[activeHotbarSlot].count--;
|
hotbar[activeHotbarSlot].count--;
|
||||||
if (hotbar[activeHotbarSlot].count <= 0) hotbar[activeHotbarSlot].blockType = AIR;
|
if (hotbar[activeHotbarSlot].count <= 0) hotbar[activeHotbarSlot].blockType = AIR;
|
||||||
PlaySound(digGrass);
|
PlaySound(digGrass);
|
||||||
|
}
|
||||||
|
// Note: We return/skip the 'else if (hitBlock)' to prevent placing the apple as a block
|
||||||
} else if (hitBlock) {
|
} else if (hitBlock) {
|
||||||
int targetBlock = GetBlock(hitX, hitY, hitZ);
|
int targetBlock = GetBlock(hitX, hitY, hitZ);
|
||||||
if (targetBlock == CRAFTING_TABLE) {
|
if (targetBlock == CRAFTING_TABLE) {
|
||||||
|
|
@ -2383,7 +2386,7 @@ int main(void)
|
||||||
DrawTextEx(customFont, "BACK", (Vector2){ backBtn.x + 70, backBtn.y + 10 }, 20, 1.0f, WHITE);
|
DrawTextEx(customFont, "BACK", (Vector2){ backBtn.x + 70, backBtn.y + 10 }, 20, 1.0f, WHITE);
|
||||||
} else {
|
} else {
|
||||||
DrawTextEx(customFont, "Downloading update...", (Vector2){ (float)currentWidth/2 - 90, (float)currentHeight/2 - 60 }, 24, 1.0f, YELLOW);
|
DrawTextEx(customFont, "Downloading update...", (Vector2){ (float)currentWidth/2 - 90, (float)currentHeight/2 - 60 }, 24, 1.0f, YELLOW);
|
||||||
// v2.3.3: Removed dynamic pulse to fix jitter
|
// v2.3.4: Removed dynamic pulse to fix jitter
|
||||||
|
|
||||||
int bw = 500, bh = 35;
|
int bw = 500, bh = 35;
|
||||||
Rectangle barBg = { (float)currentWidth/2 - bw/2, (float)currentHeight/2 - bh/2, (float)bw, (float)bh };
|
Rectangle barBg = { (float)currentWidth/2 - bw/2, (float)currentHeight/2 - bh/2, (float)bw, (float)bh };
|
||||||
|
|
@ -2678,8 +2681,8 @@ int main(void)
|
||||||
DrawTexturePro(titleTexture, sourceRec, destRec, origin, 0.0f, WHITE);
|
DrawTexturePro(titleTexture, sourceRec, destRec, origin, 0.0f, WHITE);
|
||||||
EndMode2D();
|
EndMode2D();
|
||||||
|
|
||||||
// Show Version Number (v2.3.3) in Red
|
// Show Version Number (v2.3.4) in Red
|
||||||
DrawTextEx(customFont, "v2.3.3", (Vector2){ 20, (float)currentHeight - 30 }, 22, 1.0f, RED);
|
DrawTextEx(customFont, "v2.3.4", (Vector2){ 20, (float)currentHeight - 30 }, 22, 1.0f, RED);
|
||||||
|
|
||||||
// --- PLAYER NAME POPUP (IF MISSING) ---
|
// --- PLAYER NAME POPUP (IF MISSING) ---
|
||||||
if (playerName == "") {
|
if (playerName == "") {
|
||||||
|
|
@ -2857,7 +2860,7 @@ int main(void)
|
||||||
spawnSavedX = 0; spawnSavedY = -1; spawnSavedZ = 0;
|
spawnSavedX = 0; spawnSavedY = -1; spawnSavedZ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load Chests (v2.3.3)
|
// Load Chests (v2.3.4)
|
||||||
chestInventories.clear();
|
chestInventories.clear();
|
||||||
std::ifstream cf("saves/" + currentWorldName + "/chests.dat", std::ios::binary);
|
std::ifstream cf("saves/" + currentWorldName + "/chests.dat", std::ios::binary);
|
||||||
if (cf.is_open()) {
|
if (cf.is_open()) {
|
||||||
|
|
@ -2875,7 +2878,7 @@ int main(void)
|
||||||
cf.close();
|
cf.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load Torches (v2.3.3)
|
// Load Torches (v2.3.4)
|
||||||
torchPositions.clear();
|
torchPositions.clear();
|
||||||
std::ifstream tf("saves/" + currentWorldName + "/torches.dat", std::ios::binary);
|
std::ifstream tf("saves/" + currentWorldName + "/torches.dat", std::ios::binary);
|
||||||
if (tf.is_open()) {
|
if (tf.is_open()) {
|
||||||
|
|
@ -3159,7 +3162,7 @@ int main(void)
|
||||||
snprintf(worldName, sizeof(worldName), "%s", currentWorldName.c_str());
|
snprintf(worldName, sizeof(worldName), "%s", currentWorldName.c_str());
|
||||||
worldNameLen = strlen(worldName);
|
worldNameLen = strlen(worldName);
|
||||||
|
|
||||||
gameTime = 150.0f; // Start new world at 7:00 AM (v2.3.3 adjusted for slower cycle)
|
gameTime = 150.0f; // Start new world at 7:00 AM (v2.3.4 adjusted for slower cycle)
|
||||||
|
|
||||||
if (serverMode) {
|
if (serverMode) {
|
||||||
serverSocket = socket(AF_INET, SOCK_STREAM, 0);
|
serverSocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
|
@ -3324,7 +3327,7 @@ int main(void)
|
||||||
} else if (renderType == TORCH) {
|
} else if (renderType == TORCH) {
|
||||||
for (Chunk* chunk : visibleChunks) {
|
for (Chunk* chunk : visibleChunks) {
|
||||||
for (auto& data : chunk->renderLists[TORCH]) {
|
for (auto& data : chunk->renderLists[TORCH]) {
|
||||||
// 3D Flickering Torch (v2.3.3)
|
// 3D Flickering Torch (v2.3.4)
|
||||||
float flicker = sinf(GetTime() * 12.0f) * 0.03f;
|
float flicker = sinf(GetTime() * 12.0f) * 0.03f;
|
||||||
float h = 0.6f + flicker;
|
float h = 0.6f + flicker;
|
||||||
float w = 0.12f;
|
float w = 0.12f;
|
||||||
|
|
@ -3590,6 +3593,8 @@ int main(void)
|
||||||
(float)(slotSize-8), (float)(slotSize-8) };
|
(float)(slotSize-8), (float)(slotSize-8) };
|
||||||
Color tint = (bt == GRASS) ? (Color){124,189,107,255} : WHITE;
|
Color tint = (bt == GRASS) ? (Color){124,189,107,255} : WHITE;
|
||||||
DrawTexturePro(tex, src, dst, (Vector2){0,0}, 0.0f, tint);
|
DrawTexturePro(tex, src, dst, (Vector2){0,0}, 0.0f, tint);
|
||||||
|
} else if (bt == APPLE) {
|
||||||
|
DrawCircle(sx + slotSize/2, hotbarY + slotSize/2, slotSize/2 - 10, RED);
|
||||||
}
|
}
|
||||||
// Item count centered bottom
|
// Item count centered bottom
|
||||||
Vector2 countSize = MeasureTextEx(customFont, TextFormat("%i", hotbar[s].count), 12, 1.0f);
|
Vector2 countSize = MeasureTextEx(customFont, TextFormat("%i", hotbar[s].count), 12, 1.0f);
|
||||||
|
|
@ -3597,7 +3602,7 @@ int main(void)
|
||||||
(Vector2){ (float)(sx + (slotSize/2) - (countSize.x/2)), (float)(hotbarY + slotSize - 14) },
|
(Vector2){ (float)(sx + (slotSize/2) - (countSize.x/2)), (float)(hotbarY + slotSize - 14) },
|
||||||
12, 1.0f, WHITE);
|
12, 1.0f, WHITE);
|
||||||
|
|
||||||
// Draw Hotbar Durability Bar (v2.3.3)
|
// Draw Hotbar Durability Bar (v2.3.4)
|
||||||
if (hotbar[s].maxDurability > 0 && hotbar[s].durability < hotbar[s].maxDurability) {
|
if (hotbar[s].maxDurability > 0 && hotbar[s].durability < hotbar[s].maxDurability) {
|
||||||
float durP = (float)hotbar[s].durability / hotbar[s].maxDurability;
|
float durP = (float)hotbar[s].durability / hotbar[s].maxDurability;
|
||||||
int barW = slotSize - 10;
|
int barW = slotSize - 10;
|
||||||
|
|
@ -3628,7 +3633,7 @@ int main(void)
|
||||||
DrawRectangleRec(slotRect, hov ? (Color){90,90,90,255} : (Color){60,60,60,255});
|
DrawRectangleRec(slotRect, hov ? (Color){90,90,90,255} : (Color){60,60,60,255});
|
||||||
DrawRectangleLinesEx(slotRect, 2.0f, hov ? WHITE : (Color){100,100,100,200});
|
DrawRectangleLinesEx(slotRect, 2.0f, hov ? WHITE : (Color){100,100,100,200});
|
||||||
|
|
||||||
// Draw Durability Bar (v2.3.3)
|
// Draw Durability Bar (v2.3.4)
|
||||||
if (slot.maxDurability > 0 && slot.durability < slot.maxDurability) {
|
if (slot.maxDurability > 0 && slot.durability < slot.maxDurability) {
|
||||||
float durPercent = (float)slot.durability / slot.maxDurability;
|
float durPercent = (float)slot.durability / slot.maxDurability;
|
||||||
int barW = slotRect.width - 10;
|
int barW = slotRect.width - 10;
|
||||||
|
|
@ -3649,6 +3654,8 @@ int main(void)
|
||||||
Rectangle dst = { (float)(px+5),(float)(py+5), (float)(invSlotSize-10),(float)(invSlotSize-10) };
|
Rectangle dst = { (float)(px+5),(float)(py+5), (float)(invSlotSize-10),(float)(invSlotSize-10) };
|
||||||
Color tint = (bt == GRASS) ? (Color){124,189,107,255} : WHITE;
|
Color tint = (bt == GRASS) ? (Color){124,189,107,255} : WHITE;
|
||||||
DrawTexturePro(tex, src, dst, (Vector2){0,0}, 0.0f, tint);
|
DrawTexturePro(tex, src, dst, (Vector2){0,0}, 0.0f, tint);
|
||||||
|
} else if (bt == APPLE) {
|
||||||
|
DrawCircle(px + invSlotSize/2, py + invSlotSize/2, invSlotSize/2 - 10, RED);
|
||||||
} else if (bt >= STICK) {
|
} else if (bt >= STICK) {
|
||||||
// Fallback rendering for items if texture failed
|
// Fallback rendering for items if texture failed
|
||||||
Color itemCol = (bt == STICK) ? BROWN : DARKGRAY;
|
Color itemCol = (bt == STICK) ? BROWN : DARKGRAY;
|
||||||
|
|
@ -3905,7 +3912,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hov && IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) {
|
if (hov && IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) {
|
||||||
// Right click: pick up/place one (v2.3.3)
|
// Right click: pick up/place one (v2.3.4)
|
||||||
if (mouseHeldItem.blockType == AIR) {
|
if (mouseHeldItem.blockType == AIR) {
|
||||||
if (chestInv[i].blockType != AIR && chestInv[i].count > 0) {
|
if (chestInv[i].blockType != AIR && chestInv[i].count > 0) {
|
||||||
mouseHeldItem = InventorySlot(chestInv[i].blockType, 1);
|
mouseHeldItem = InventorySlot(chestInv[i].blockType, 1);
|
||||||
|
|
@ -3952,7 +3959,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hov && IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) {
|
if (hov && IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) {
|
||||||
// Right click logic for player inv in chest GUI (v2.3.3)
|
// Right click logic for player inv in chest GUI (v2.3.4)
|
||||||
if (mouseHeldItem.blockType == AIR) {
|
if (mouseHeldItem.blockType == AIR) {
|
||||||
if (inventory[i].blockType != AIR && inventory[i].count > 0) {
|
if (inventory[i].blockType != AIR && inventory[i].count > 0) {
|
||||||
mouseHeldItem = InventorySlot(inventory[i].blockType, 1);
|
mouseHeldItem = InventorySlot(inventory[i].blockType, 1);
|
||||||
|
|
@ -4138,7 +4145,7 @@ int main(void)
|
||||||
invf.close();
|
invf.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save Chests (v2.3.3)
|
// Save Chests (v2.3.4)
|
||||||
std::ofstream cf("saves/" + currentWorldName + "/chests.dat", std::ios::binary);
|
std::ofstream cf("saves/" + currentWorldName + "/chests.dat", std::ios::binary);
|
||||||
if (cf.is_open()) {
|
if (cf.is_open()) {
|
||||||
uint32_t count = (uint32_t)chestInventories.size();
|
uint32_t count = (uint32_t)chestInventories.size();
|
||||||
|
|
@ -4154,7 +4161,7 @@ int main(void)
|
||||||
cf.close();
|
cf.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save Torches (v2.3.3)
|
// Save Torches (v2.3.4)
|
||||||
std::ofstream tf("saves/" + currentWorldName + "/torches.dat", std::ios::binary);
|
std::ofstream tf("saves/" + currentWorldName + "/torches.dat", std::ios::binary);
|
||||||
if (tf.is_open()) {
|
if (tf.is_open()) {
|
||||||
uint32_t count = (uint32_t)torchPositions.size();
|
uint32_t count = (uint32_t)torchPositions.size();
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
v2.3.3
|
v2.3.4
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue