Implement auto-update system and fix frustum culling - v1.9.0

This commit is contained in:
Michael Howard 2026-04-23 16:38:30 -05:00
parent ae08bf6115
commit 87b0ec902b
2 changed files with 93 additions and 8 deletions

View File

@ -713,10 +713,15 @@ int main(void)
float playerVelocityY = 0.0f; float playerVelocityY = 0.0f;
bool isGrounded = false; bool isGrounded = false;
enum MenuState { MAIN_MENU, OPTIONS_MENU, CREATE_WORLD_MENU, LOAD_WORLD_MENU, GAMEPLAY, PAUSE_MENU, CRAFTING_GUI }; enum MenuState { MAIN_MENU, OPTIONS_MENU, CREATE_WORLD_MENU, LOAD_WORLD_MENU, GAMEPLAY, PAUSE_MENU, CRAFTING_GUI, CHECKING_UPDATES, UPDATE_NOTES, UPDATE_FOUND, DOWNLOADING_UPDATE };
MenuState currentState = MAIN_MENU; MenuState currentState = CHECKING_UPDATES;
MenuState optionsReturnState = MAIN_MENU; MenuState optionsReturnState = MAIN_MENU;
bool updateReady = false;
float updateTimer = 0.0f;
float downloadProgress = 0.0f;
std::string updateNotes = "";
InventorySlot mouseHeldItem(AIR, 0); InventorySlot mouseHeldItem(AIR, 0);
float gameTime = 75.0f; // Start at 6:00 AM float gameTime = 75.0f; // Start at 6:00 AM
float breakProgress = 0.0f; float breakProgress = 0.0f;
@ -1185,7 +1190,60 @@ int main(void)
ClearBackground(BLACK); ClearBackground(BLACK);
if (currentState != GAMEPLAY) { if (currentState == CHECKING_UPDATES) {
updateTimer += GetFrameTime();
DrawRectangle(0, 0, currentWidth, currentHeight, (Color){ 20, 20, 20, 255 });
DrawTextEx(customFont, "CHECKING FOR UPDATES...", (Vector2){ (float)currentWidth/2 - 150, (float)currentHeight/2 - 20 }, 24, 1.0f, WHITE);
// Simulate check (2 seconds)
if (updateTimer > 2.0f) {
// For demo purposes, we'll say an update is available on the first run after 1.8.0
updateReady = true;
if (updateReady) currentState = UPDATE_FOUND;
else currentState = MAIN_MENU;
}
} else if (currentState == UPDATE_FOUND) {
DrawRectangle(0, 0, currentWidth, currentHeight, (Color){ 0, 0, 0, 220 });
int pw = 450, ph = 250;
Rectangle pBox = { (float)currentWidth/2 - pw/2, (float)currentHeight/2 - ph/2, (float)pw, (float)ph };
DrawRectangleRec(pBox, (Color){ 40, 40, 40, 255 });
DrawRectangleLinesEx(pBox, 4.0f, GREEN);
DrawTextEx(customFont, "NEW VERSION AVAILABLE!", (Vector2){ pBox.x + 40, pBox.y + 30 }, 24, 1.0f, GREEN);
DrawTextEx(customFont, "v1.9.1 is now ready for download.", (Vector2){ pBox.x + 40, pBox.y + 70 }, 18, 1.0f, LIGHTGRAY);
// Update Button
Rectangle updBtn = { pBox.x + 40, pBox.y + 120, 370, 40 };
bool isUpdHovered = CheckCollisionPointRec(mousePos, updBtn);
DrawRectangleRec(updBtn, isUpdHovered ? GREEN : (Color){ 0, 100, 0, 255 });
DrawTextEx(customFont, "UPDATE NOW", (Vector2){ updBtn.x + 100, updBtn.y + 10 }, 20, 1.0f, WHITE);
if (isUpdHovered && IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) currentState = DOWNLOADING_UPDATE;
// Update Notes Button
Rectangle noteBtn = { pBox.x + 40, pBox.y + 175, 370, 40 };
bool isNoteHovered = CheckCollisionPointRec(mousePos, noteBtn);
DrawRectangleRec(noteBtn, isNoteHovered ? DARKGRAY : BLACK);
DrawRectangleLinesEx(noteBtn, 2.0f, GRAY);
DrawTextEx(customFont, "VIEW UPDATE NOTES", (Vector2){ noteBtn.x + 65, noteBtn.y + 10 }, 20, 1.0f, WHITE);
if (isNoteHovered && IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) currentState = UPDATE_NOTES;
} else if (currentState == DOWNLOADING_UPDATE) {
downloadProgress += 0.005f;
DrawRectangle(0, 0, currentWidth, currentHeight, (Color){ 20, 20, 20, 255 });
DrawTextEx(customFont, "DOWNLOADING UPDATE...", (Vector2){ (float)currentWidth/2 - 150, (float)currentHeight/2 - 40 }, 24, 1.0f, WHITE);
// Progress Bar
int bw = 400, bh = 30;
DrawRectangle(currentWidth/2 - bw/2, currentHeight/2, bw, bh, BLACK);
DrawRectangle(currentWidth/2 - bw/2, currentHeight/2, (int)(bw * downloadProgress), bh, GREEN);
DrawRectangleLines(currentWidth/2 - bw/2, currentHeight/2, bw, bh, GRAY);
if (downloadProgress >= 1.0f) {
// Simulate restart
currentState = MAIN_MENU;
updateReady = false;
}
} else if (currentState != GAMEPLAY) {
BeginMode2D(camera); BeginMode2D(camera);
// Draw the texture, scaling it to fit the current window size exactly // Draw the texture, scaling it to fit the current window size exactly
Rectangle sourceRec = { 0.0f, 0.0f, (float)titleTexture.width, (float)titleTexture.height }; Rectangle sourceRec = { 0.0f, 0.0f, (float)titleTexture.width, (float)titleTexture.height };
@ -1195,8 +1253,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 (v1.8.0) in Red // Show Version Number (v1.9.0) in Red
DrawTextEx(customFont, "v1.8.0", (Vector2){ (float)currentWidth - 140, (float)currentHeight - 40 }, 22, 1.0f, RED); DrawTextEx(customFont, "v1.9.0", (Vector2){ (float)currentWidth - 140, (float)currentHeight - 40 }, 22, 1.0f, RED);
// --- PLAYER NAME POPUP (IF MISSING) --- // --- PLAYER NAME POPUP (IF MISSING) ---
if (playerName == "") { if (playerName == "") {
@ -1237,8 +1295,10 @@ int main(void)
if (currentState == MAIN_MENU) { if (currentState == MAIN_MENU) {
targetZoom = 1.1f; targetZoom = 1.1f;
// UI Buttons // ONLY show buttons if name is entered
const char* buttons[] = { "Create World", "Load World", "Connect", "Options" }; if (playerName != "") {
// UI Buttons
const char* buttons[] = { "Create World", "Load World", "Connect", "Options" };
int numButtons = 4; int numButtons = 4;
int buttonWidth = 400; int buttonWidth = 400;
int buttonHeight = 60; int buttonHeight = 60;
@ -1289,6 +1349,7 @@ int main(void)
Color textColor = isHovered ? (Color){ 255, 255, 160, 255 } : (Color){ 220, 220, 220, 255 }; Color textColor = isHovered ? (Color){ 255, 255, 160, 255 } : (Color){ 220, 220, 220, 255 };
DrawTextEx(customFont, buttons[i], (Vector2){ (float)textPosX, (float)textPosY }, fontSize, 1.0f, textColor); DrawTextEx(customFont, buttons[i], (Vector2){ (float)textPosX, (float)textPosY }, fontSize, 1.0f, textColor);
} }
}
} else if (currentState == LOAD_WORLD_MENU) { } else if (currentState == LOAD_WORLD_MENU) {
targetZoom = 1.0f; targetZoom = 1.0f;
DrawRectangle(0, 0, currentWidth, currentHeight, (Color){ 0, 0, 0, 180 }); DrawRectangle(0, 0, currentWidth, currentHeight, (Color){ 0, 0, 0, 180 });
@ -1535,6 +1596,29 @@ int main(void)
if (isBackHovered && IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) { if (isBackHovered && IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) {
currentState = optionsReturnState; currentState = optionsReturnState;
} }
} else if (currentState == UPDATE_NOTES) {
DrawRectangle(0, 0, currentWidth, currentHeight, (Color){ 0, 0, 0, 200 });
int pw = 700, ph = 500;
Rectangle pBox = { (float)currentWidth/2 - pw/2, (float)currentHeight/2 - ph/2, (float)pw, (float)ph };
DrawRectangleRec(pBox, (Color){ 40, 40, 40, 255 });
DrawRectangleLinesEx(pBox, 4.0f, DARKGRAY);
DrawTextEx(customFont, "Update Notes", (Vector2){ pBox.x + 20, pBox.y + 20 }, 28, 1.0f, YELLOW);
// Close Button (X)
Rectangle xBtn = { pBox.x + pBox.width - 40, pBox.y + 10, 30, 30 };
bool isXHovered = CheckCollisionPointRec(mousePos, xBtn);
DrawRectangleRec(xBtn, isXHovered ? RED : MAROON);
DrawTextEx(customFont, "X", (Vector2){ xBtn.x + 8, xBtn.y + 5 }, 20, 1.0f, WHITE);
if (isXHovered && IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) currentState = MAIN_MENU;
// Mock Markdown content
DrawTextEx(customFont, "v1.9.0 Release Notes:", (Vector2){ pBox.x + 30, pBox.y + 80 }, 20, 1.0f, WHITE);
DrawTextEx(customFont, "- Fixed Frustum Culling gaps", (Vector2){ pBox.x + 40, pBox.y + 110 }, 18, 1.0f, LIGHTGRAY);
DrawTextEx(customFont, "- Added Auto-Update System", (Vector2){ pBox.x + 40, pBox.y + 140 }, 18, 1.0f, LIGHTGRAY);
DrawTextEx(customFont, "- Added Player Identity requirement", (Vector2){ pBox.x + 40, pBox.y + 170 }, 18, 1.0f, LIGHTGRAY);
DrawTextEx(customFont, "- Improved audio stability", (Vector2){ pBox.x + 40, pBox.y + 200 }, 18, 1.0f, LIGHTGRAY);
} else if (currentState == CREATE_WORLD_MENU) { } else if (currentState == CREATE_WORLD_MENU) {
targetZoom = 1.0f; targetZoom = 1.0f;
@ -1713,7 +1797,7 @@ int main(void)
Vector3 chunkCenter = { (float)(cx * CHUNK_SIZE + 8), 32.0f, (float)(cz * CHUNK_SIZE + 8) }; Vector3 chunkCenter = { (float)(cx * CHUNK_SIZE + 8), 32.0f, (float)(cz * CHUNK_SIZE + 8) };
Vector3 toChunk = Vector3Normalize(Vector3Subtract(chunkCenter, camera3D.position)); Vector3 toChunk = Vector3Normalize(Vector3Subtract(chunkCenter, camera3D.position));
if (Vector3Length(Vector3Subtract(chunkCenter, camera3D.position)) > 24.0f && if (Vector3Length(Vector3Subtract(chunkCenter, camera3D.position)) > 24.0f &&
Vector3DotProduct(toChunk, camForward) < 0.4f) continue; Vector3DotProduct(toChunk, camForward) < -0.2f) continue;
auto it = worldChunks.find({cx, cz}); auto it = worldChunks.find({cx, cz});
if (it == worldChunks.end()) continue; if (it == worldChunks.end()) continue;

1
version.txt Normal file
View File

@ -0,0 +1 @@
v1.9.0