From 5abebc5f1e81506b0d978154ab6d030b376c3f4b Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Fri, 7 Jan 2022 17:36:36 +0100 Subject: interface work in progress --- CMakeLists.txt | 2 ++ src/main.cpp | 37 +++++++++++++++++++++++++++++++++---- src/window.hpp | 2 +- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 025c271..5d9e149 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ find_package(raylib 3.0 REQUIRED) # Requires at least version 3.0 set(CMAKE_C_STANDARD 11) # Requires C11 standard +set (CMAKE_CXX_STANDARD 17) + add_executable(${PROJECT_NAME} src/main.cpp src/window.cpp diff --git a/src/main.cpp b/src/main.cpp index 92cdc56..009ff9a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,8 @@ #include "window.hpp" #include "gameplay.hpp" #include +#include +#include gameState gs = TITLE; @@ -19,18 +21,29 @@ int main(void) { // Main game loop InitWindow(SCREENWIDTH, SCREENHEIGHT, "WIP -- coolspace"); - Game* game = new Game("../meta/maps/stage_1_start.bfm"); + Game* game = nullptr; while (!WindowShouldClose()) /* Detect window close button or ESC key */ { switch (gs) { case (TITLE): + { + if (IsKeyPressed(KEY_ENTER)) + { + gs = PICK; + } + break ; + } + case (PICK): { if (IsKeyPressed(KEY_ENTER)) { gs = GAMEPLAY; game->start(); } - break ; + if (IsKeyPressed(KEY_DOWN)) + { + // pick++ + } } case (GAMEPLAY): { @@ -72,11 +85,27 @@ int main(void) { switch (gs) { case (TITLE): { - DrawRectangle((SCREENWIDTH / 2), (SCREENHEIGHT / 2), 200, 200, BLACK); - DrawText("THRESHOLD", (SCREENWIDTH / 2) - 140, SCREENHEIGHT / 2, 40, RED); + DrawRectangle(200, 100, 1200, 700, RAYWHITE); + DrawRectangle(250, 150, 1100, 600, COOLPURPLE); + DrawRectangle(300, 200, 1000, 500, RAYWHITE); + DrawText("THRESHOLD", 260, 160, 30, RAYWHITE); DrawText("PRESS ENTER", (SCREENWIDTH / 2) - 140, (SCREENHEIGHT / 2) + 50, 40, MAROON); break ; } + case (PICK): + { + std::string path = "../meta/maps"; + int i = 0; + DrawRectangle(200, 100, 1200, 700, RAYWHITE); + DrawRectangle(250, 150, 1100, 600, COOLPURPLE); + DrawRectangle(300, 200, 1000, 500, RAYWHITE); + for (const auto & entry : std::filesystem::directory_iterator(path)) { + DrawText("TEST", SCREENWIDTH / 2, (SCREENHEIGHT / 2) + i * 40, 40, COOLPURPLE); + i++; + } + DrawText("THRESHOLD", 260, 160, 30, RAYWHITE); + break ; + } case (GAMEPLAY): { if (auto code = game->getKeys()) { diff --git a/src/window.hpp b/src/window.hpp index bba7c07..24d6f4c 100644 --- a/src/window.hpp +++ b/src/window.hpp @@ -17,7 +17,7 @@ int initWindow(void); #define SCREENHEIGHT 900 typedef enum gameState { -TITLE = 0, GAMEPLAY, NEXT, ENDING +TITLE = 0, PICK, GAMEPLAY, NEXT, ENDING } gameState ; #endif // WINDOW_H_ -- cgit v1.2.3