Very convincing terminal
This commit is contained in:
commit
639d2ce889
29
.clang-format
Normal file
29
.clang-format
Normal file
@ -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
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
build/
|
||||||
|
build.win/
|
||||||
|
.vscode/
|
||||||
|
.cache/
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "dependencies/kekengine"]
|
||||||
|
path = dependencies/kekengine
|
||||||
|
url = https://git.cringe-studios.com/mr/KekEngine.git
|
69
CMakeLists.txt
Normal file
69
CMakeLists.txt
Normal file
@ -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)
|
1
dependencies/kekengine
vendored
Submodule
1
dependencies/kekengine
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit bbee789593fda91071e2d06a0320c05d12b59649
|
37
src/haxxorizer/cpp/elements.cpp
Normal file
37
src/haxxorizer/cpp/elements.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include <string>
|
||||||
|
|
||||||
|
#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);
|
||||||
|
}
|
72
src/haxxorizer/cpp/haxxorizer.cpp
Normal file
72
src/haxxorizer/cpp/haxxorizer.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <glm/geometric.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <tuple>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#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();
|
||||||
|
}
|
17
src/haxxorizer/include/elements.h
Normal file
17
src/haxxorizer/include/elements.h
Normal file
@ -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);
|
||||||
|
};
|
BIN
src/haxxorizer/res/image/console.png
Normal file
BIN
src/haxxorizer/res/image/console.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
20
toolchains/linux-mingw-windows.cmake
Normal file
20
toolchains/linux-mingw-windows.cmake
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user