From a5325cece65bef1446c7ec7c3bed86c4df90ec84 Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Wed, 1 Jan 2025 21:04:05 +0100 Subject: [PATCH] Start menu --- game.h | 15 +++++++++++++-- renderer.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/game.h b/game.h index 7ce7864..c5d4a68 100644 --- a/game.h +++ b/game.h @@ -641,8 +641,19 @@ uint8_t LCR_gameStep(uint32_t time) while (time >= LCR_game.nextRenderFrameTime) LCR_game.nextRenderFrameTime += 1000 / LCR_SETTING_FPS; - - LCR_gameDraw3DView(); + +if (LCR_game.state == LCR_GAME_STATE_MENU) +{ + +const char *aaa[] = +{ + "menu","absa","sasas","sasqw" +}; + +LCR_rendererDrawMenu(aaa,4,2); +} +else + LCR_gameDraw3DView(); } else { diff --git a/renderer.h b/renderer.h index 9ad2dea..682a0ac 100644 --- a/renderer.h +++ b/renderer.h @@ -1676,6 +1676,62 @@ void LCR_rendererCameraFollow(void) #endif } +void LCR_rendererDrawMenu(const char **items, unsigned char itemCount, + char selectedItem) +{ + int stripHeight = LCR_EFFECTIVE_RESOLUTION_Y / 5; + int stripHeight2 = LCR_EFFECTIVE_RESOLUTION_Y / 8; + + int i = 0; + + while (i < stripHeight * LCR_EFFECTIVE_RESOLUTION_X) + { + LCR_drawPixel(i,0x8ddc); + ++i; + } + + for (int y = 0; y < stripHeight2; ++y) // strip with arrows + { + int limit = y > stripHeight2 / 2 ? + (stripHeight2 / 2 - y) : (y - stripHeight2 / 2); + + + for (int x = 0; x < LCR_EFFECTIVE_RESOLUTION_X; ++x) + { + LCR_drawPixel(i,(x > LCR_EFFECTIVE_RESOLUTION_X / 4 - limit && + x < LCR_EFFECTIVE_RESOLUTION_X - LCR_EFFECTIVE_RESOLUTION_X / 4 + limit) + ? 0x73ae : 0x31a6); + i++; + } + } + + while (i < LCR_EFFECTIVE_RESOLUTION_Y * LCR_EFFECTIVE_RESOLUTION_X) + { + LCR_drawPixel(i,0xbdf7); + ++i; + } + + i = stripHeight + + (stripHeight2 - LCR_rendererComputeTextHeight(4)) / 2; + + for (int j = 0; j < itemCount; ++j) + { + if (j == selectedItem) + for (int y = i - 10; y < i + LCR_rendererComputeTextHeight(4) + 10; ++y) + for (int x = LCR_EFFECTIVE_RESOLUTION_X / 4; + x < LCR_EFFECTIVE_RESOLUTION_X - LCR_EFFECTIVE_RESOLUTION_X / 4; ++x) + LCR_drawPixelXYSafe(x,y,0x5c1b); + + LCR_rendererDrawText(items[j],(LCR_EFFECTIVE_RESOLUTION_X - + LCR_rendererComputeTextWidth(items[j],4)) / 2,i,0xffff,4); + + if (j == 0) + i = stripHeight + stripHeight2; + + i += LCR_rendererComputeTextHeight(7); + } +} + void LCR_rendererCameraReset(void) { LCR_renderer.scene.camera.transform.translation =