commit 639d2ce889ed999ddc354979953d63701364a63e Author: MrLetsplay Date: Mon Oct 16 20:54:53 2023 +0200 Very convincing terminal diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..b7c077b --- /dev/null +++ b/.clang-format @@ -0,0 +1,29 @@ +Language: Cpp +BasedOnStyle: LLVM +IndentWidth: 4 +UseTab: Always +TabWidth: 4 +ColumnLimit: 0 +IndentCaseLabels: true +AllowShortIfStatementsOnASingleLine: true +FixNamespaceComments: false +SpaceBeforeParens: Never +SpaceAfterCStyleCast: true +SeparateDefinitionBlocks: Always +PackConstructorInitializers: Never +IncludeBlocks: Preserve +SpaceBeforeInheritanceColon: false +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignTrailingComments: false +AlignOperands: false +AlignEscapedNewlines: false +AlignConsecutiveMacros: false +AllowShortCaseLabelsOnASingleLine: false +SpaceBeforeCtorInitializerColon: false +SpaceBeforeAssignmentOperators: true +AllowShortLoopsOnASingleLine: true +AlignAfterOpenBracket: DontAlign +LambdaBodyIndentation: Signature +LineEnding: LF +ContinuationIndentWidth: 4 diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..359a391 --- /dev/null +++ b/.clangd @@ -0,0 +1,2 @@ +CompileFlags: + Add: [-std=c++20] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ac3775 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +build/ +build.win/ +.vscode/ +.cache/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..9be7397 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "dependencies/kekengine"] + path = dependencies/kekengine + url = https://git.cringe-studios.com/mr/KekEngine.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6ccb944 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,69 @@ +cmake_minimum_required(VERSION 3.13) + +project(Haxxorizer VERSION 1.0) + +option(HAXXORIZER_DEBUG "Build with debug information" OFF) + +if(UNIX) + set(HAXXORIZER_TARGET_PLATFORM Linux) +endif() +if(WIN32) + set(HAXXORIZER_TARGET_PLATFORM Windows) +endif() + +message("Debug: ${HAXXORIZER_DEBUG}") +message("Target platform: ${HAXXORIZER_TARGET_PLATFORM}") + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) + +set(HAXXORIZER_RESOURCE_DIR "${PROJECT_SOURCE_DIR}/src/haxxorizer/res") + +file(GLOB_RECURSE HAXXORIZER_SOURCE_FILES "src/haxxorizer/cpp/*.cpp") +file(GLOB_RECURSE HAXXORIZER_RESOURCE_FILES "${HAXXORIZER_RESOURCE_DIR}/*") +file(GLOB_RECURSE HAXXORIZER_RELATIVE_RESOURCE_FILES RELATIVE ${HAXXORIZER_RESOURCE_DIR} "${HAXXORIZER_RESOURCE_DIR}/*") + +if(${HAXXORIZER_DEBUG}) + add_compile_options(-Wall -g) +else() + add_compile_options(-Wall -O3) +endif() + +add_subdirectory(dependencies/kekengine) + +# haxxorizer resources +add_custom_target(haxxorizer_res ALL DEPENDS ${KEKENGINE_RESOURCE_FILES}) + +add_dependencies(haxxorizer_res kekengine_static) + +get_target_property(KEKENGINE_BINARY_DIR kekengine "RUNTIME_OUTPUT_DIRECTORY") + +add_custom_command(TARGET haxxorizer_res PRE_BUILD + BYPRODUCTS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources.tar + COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" + COMMAND ${CMAKE_COMMAND} -E + copy "${KEKENGINE_BINARY_DIR}/resources.tar" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources.tar" + COMMAND ${CMAKE_COMMAND} -E + chdir ${HAXXORIZER_RESOURCE_DIR} + tar rf ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources.tar ${HAXXORIZER_RELATIVE_RESOURCE_FILES}) + +# haxxorizer +add_executable(haxxorizer ${HAXXORIZER_SOURCE_FILES}) +add_dependencies(haxxorizer haxxorizer_res) + +target_include_directories(haxxorizer PUBLIC "src/haxxorizer/include") + +find_package(PkgConfig REQUIRED) + +pkg_check_modules(FREETYPE REQUIRED freetype2) +target_include_directories(haxxorizer PUBLIC ${FREETYPE_INCLUDE_DIRS}) + +pkg_check_modules(BULLET REQUIRED bullet) +target_include_directories(haxxorizer PUBLIC ${BULLET_INCLUDE_DIRS}) + +if(WIN32) + target_link_options(haxxorizer PUBLIC -static-libgcc -static-libstdc++ -static) +endif() + +target_link_libraries(haxxorizer PUBLIC kekengine_static) diff --git a/dependencies/kekengine b/dependencies/kekengine new file mode 160000 index 0000000..bbee789 --- /dev/null +++ b/dependencies/kekengine @@ -0,0 +1 @@ +Subproject commit bbee789593fda91071e2d06a0320c05d12b59649 diff --git a/src/haxxorizer/cpp/elements.cpp b/src/haxxorizer/cpp/elements.cpp new file mode 100644 index 0000000..4ed697a --- /dev/null +++ b/src/haxxorizer/cpp/elements.cpp @@ -0,0 +1,37 @@ +#include + +#include "color.h" +#include "elements.h" +#include "ui.h" +#include "uielements.h" +#include "utils.h" + +ConsoleElement::ConsoleElement(kek::UIValue x, kek::UIValue y, kek::UIValue w, kek::UIValue h) + : kek::RectangleElement(x, y, w, h) { + color = kek::Colors::BLACK; + + this->textElement = new kek::TextElement(x, y); + addChild(textElement); + + kek::TextElement *text = new kek::TextElement(uiPx(0), uiPh(1)); + text->textBounds = kek::TextBounds::LINE; + text->origin = kek::Origin::BOTTOM_LEFT; + text->setText("user@cringe-studios.com $ "); + addChild(text); + + this->textFieldElement = new kek::TextFieldElement(uiPx(text->getBounds().w), uiPh(1), uiPw(1) - uiPx(text->getBounds().w)); + textFieldElement->origin = kek::Origin::BOTTOM_LEFT; + textFieldElement->color = kek::Colors::BLACK; + textFieldElement->focusColor = kek::Colors::BLACK; + textFieldElement->cursor->color = kek::Colors::WHITE; + textFieldElement->textElement->color = kek::Colors::WHITE; + addChild(textFieldElement); +} + +ConsoleElement::~ConsoleElement() { + delete textElement; +} + +void ConsoleElement::setText(std::string text) { + textElement->setText(text); +} diff --git a/src/haxxorizer/cpp/haxxorizer.cpp b/src/haxxorizer/cpp/haxxorizer.cpp new file mode 100644 index 0000000..935e4af --- /dev/null +++ b/src/haxxorizer/cpp/haxxorizer.cpp @@ -0,0 +1,72 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "BulletCollision/CollisionDispatch/btCollisionObject.h" +#include "BulletCollision/CollisionShapes/btBoxShape.h" +#include "LinearMath/btVector3.h" +#include "constants.h" +#include "elements.h" +#include "engine.h" +#include "gameobject.h" +#include "input.h" +#include "internal/physics.h" +#include "kekengine.h" +#include "light.h" +#include "mesh.h" +#include "player.h" +#include "scene.h" +#include "texture.h" +#include "ui.h" +#include "uielements.h" +#include "utils.h" + +using namespace kek; + +#define CHUNK_SIZE 64 +#define CHUNK_RADIUS 2 +#define WALLS_PER_CHUNK 20 +#define WALL_HEIGHT 10 +#define LIGHT_SPACING 16 + +static ButtonElement *buttonPlay; + +void gameLoop(GLFWwindow *window, void *) {} + +void startGame() { + ConsoleElement *console = new ConsoleElement(uiPx(10), uiPx(10), uiSw(1) - uiPx(20), uiSh(1) - uiPx(20)); + console->textFieldElement->onSubmit = SubmitCallback([](std::string text, void *data) { + ConsoleElement *_console = (ConsoleElement *) data; + _console->textElement->setText(_console->textElement->getText() + "\n" + "> " + text); + _console->textFieldElement->setText(""); + UI::focusElement(_console->textFieldElement); + }, + console); + UI::addElement(console); +} + +int main() { + if(Engine::init() != KEK_SUCCESS) + return 1; + + buttonPlay = new ButtonElement(uiSw(0.5), uiSh(0.5), uiPx(500), uiPx(75)); + buttonPlay->origin = Origin::CENTER; + buttonPlay->text->setText("Play"); + buttonPlay->text->sizePixels = 50; + buttonPlay->text->color = Colors::BLACK; + buttonPlay->onClick = Callable(startGame); + + UI::addElement(buttonPlay); + Input::setCursorMode(GLFWCursorMode::FREE); + + if(Engine::start() != KEK_SUCCESS) + return 1; + + Engine::exit(); +} diff --git a/src/haxxorizer/include/elements.h b/src/haxxorizer/include/elements.h new file mode 100644 index 0000000..4de8015 --- /dev/null +++ b/src/haxxorizer/include/elements.h @@ -0,0 +1,17 @@ +#pragma once + +#include "ui.h" +#include "uielements.h" + +class ConsoleElement: public kek::RectangleElement { + + public: + kek::TextElement *textElement; + kek::TextFieldElement *textFieldElement; + + ConsoleElement(kek::UIValue x, kek::UIValue y, kek::UIValue w, kek::UIValue h); + + virtual ~ConsoleElement(); + + void setText(std::string text); +}; diff --git a/src/haxxorizer/res/image/console.png b/src/haxxorizer/res/image/console.png new file mode 100644 index 0000000..2a66dce Binary files /dev/null and b/src/haxxorizer/res/image/console.png differ diff --git a/toolchains/linux-mingw-windows.cmake b/toolchains/linux-mingw-windows.cmake new file mode 100644 index 0000000..73bf791 --- /dev/null +++ b/toolchains/linux-mingw-windows.cmake @@ -0,0 +1,20 @@ +set(CMAKE_SYSTEM_NAME Windows) + +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) + +set(CMAKE_C_FLAGS -w) +set(CMAKE_CXX_FLAGS -w) + +set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) +set(CMAKE_PREFIX_PATH /usr/x86_64-w64-mingw32) +set(ENV{PKG_CONFIG_PATH} "${CMAKE_PREFIX_PATH}/sys-root/mingw/lib/pkgconfig/") +link_directories(dependencies/kekengine/windows/lib/) +include_directories(dependencies/kekengine/windows/include/) +link_directories(dependencies/kekengine/dependencies/openvr/bin/win64) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) + +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)