diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 21:27:01 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 21:27:01 +0200 |
commit | 080ad535e6fc6666b919b1a21b6986aaf9b678eb (patch) | |
tree | f4d96cb68769ddd06087977ad7d26c3fd31ff4e8 /src | |
parent | de356f60b91fab37b1456992dc66ada8bd8e4dd7 (diff) |
initial nitpicking
Diffstat (limited to 'src')
-rwxr-xr-x | src/build.sh | 9 | ||||
-rw-r--r-- | src/crepe/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/crepe/Component.h | 6 | ||||
-rw-r--r-- | src/crepe/GameObject.hpp | 15 | ||||
-rw-r--r-- | src/crepe/Particle.h | 7 | ||||
-rw-r--r-- | src/crepe/Position.h | 11 | ||||
-rw-r--r-- | src/crepe/api/BehaviorScript.cpp | 7 | ||||
-rw-r--r-- | src/crepe/api/BehaviorScript.h | 2 | ||||
-rw-r--r-- | src/crepe/api/GameObject.hpp | 2 | ||||
-rw-r--r-- | src/crepe/crepe/CMakeFiles/CMakeDirectoryInformation.cmake | 16 | ||||
-rw-r--r-- | src/crepe/crepe/CMakeFiles/progress.marks | 1 | ||||
-rw-r--r-- | src/crepe/crepe/Makefile | 140 | ||||
-rw-r--r-- | src/crepe/crepe/cmake_install.cmake | 44 | ||||
-rw-r--r-- | src/crepe/util/log.h | 2 | ||||
-rw-r--r-- | src/example/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/example/components_internal.cpp | 6 | ||||
-rw-r--r-- | src/example/physics.cpp (renamed from src/example/Physics.cpp) | 0 |
17 files changed, 25 insertions, 248 deletions
diff --git a/src/build.sh b/src/build.sh deleted file mode 100755 index 05d086c..0000000 --- a/src/build.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -# creates the build dir and runs CMake with Ninja -cmake -B build -G Ninja - -ninja -C build - -ninja -C build/ rendering -ninja -C build/ asset_manager diff --git a/src/crepe/CMakeLists.txt b/src/crepe/CMakeLists.txt index 1b4b1c2..fcd169c 100644 --- a/src/crepe/CMakeLists.txt +++ b/src/crepe/CMakeLists.txt @@ -1,4 +1,3 @@ - target_sources(crepe PUBLIC Asset.cpp Sound.cpp diff --git a/src/crepe/Component.h b/src/crepe/Component.h index 9483dad..ccf95cb 100644 --- a/src/crepe/Component.h +++ b/src/crepe/Component.h @@ -3,14 +3,18 @@ namespace crepe { +class ComponentManager; + class Component { protected: + friend class crepe::ComponentManager; Component(uint32_t id); +public: + virtual ~Component() = default; public: uint32_t gameObjectId; bool active; - virtual ~Component() = default; }; } // namespace crepe diff --git a/src/crepe/GameObject.hpp b/src/crepe/GameObject.hpp deleted file mode 100644 index 8cd1abe..0000000 --- a/src/crepe/GameObject.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "GameObject.h" - -#include "ComponentManager.h" - -namespace crepe { - -template <typename T, typename... Args> -T & GameObject::add_component(Args &&... args) { - auto & mgr = ComponentManager::get_instance(); - return mgr.add_component<T>(id, std::forward<Args>(args)...); -} - -} // namespace crepe diff --git a/src/crepe/Particle.h b/src/crepe/Particle.h index c408ed9..006986a 100644 --- a/src/crepe/Particle.h +++ b/src/crepe/Particle.h @@ -1,11 +1,8 @@ #pragma once -namespace crepe { +#include "Position.h" -struct Position { - float x; - float y; - }; +namespace crepe { class Particle { public: diff --git a/src/crepe/Position.h b/src/crepe/Position.h new file mode 100644 index 0000000..5eb985e --- /dev/null +++ b/src/crepe/Position.h @@ -0,0 +1,11 @@ +#pragma once + +namespace crepe { + +struct Position { + float x = 0.0; + float y = 0.0; + }; + +} + diff --git a/src/crepe/api/BehaviorScript.cpp b/src/crepe/api/BehaviorScript.cpp index 74788ec..e69de29 100644 --- a/src/crepe/api/BehaviorScript.cpp +++ b/src/crepe/api/BehaviorScript.cpp @@ -1,7 +0,0 @@ -#include "../util/log.h" - -#include "BehaviorScript.h" - -using namespace crepe::api; - -BehaviorScript::BehaviorScript() : Component(gameObjectId) { dbg_trace(); } diff --git a/src/crepe/api/BehaviorScript.h b/src/crepe/api/BehaviorScript.h index 25d3cc5..cb37a78 100644 --- a/src/crepe/api/BehaviorScript.h +++ b/src/crepe/api/BehaviorScript.h @@ -17,7 +17,7 @@ class Script; class BehaviorScript : public Component { protected: friend class crepe::ComponentManager; - BehaviorScript(); + using Component::Component; public: virtual ~BehaviorScript() = default; diff --git a/src/crepe/api/GameObject.hpp b/src/crepe/api/GameObject.hpp index 8295ea3..3c7e867 100644 --- a/src/crepe/api/GameObject.hpp +++ b/src/crepe/api/GameObject.hpp @@ -9,7 +9,7 @@ namespace crepe::api { template <typename T, typename... Args> T & GameObject::add_component(Args &&... args) { auto & mgr = ComponentManager::get_instance(); - return mgr.add_component<T>(id, std::forward<Args>(args)...); + return mgr.add_component<T>(this->id, std::forward<Args>(args)...); } } // namespace crepe::api diff --git a/src/crepe/crepe/CMakeFiles/CMakeDirectoryInformation.cmake b/src/crepe/crepe/CMakeFiles/CMakeDirectoryInformation.cmake deleted file mode 100644 index 8d03506..0000000 --- a/src/crepe/crepe/CMakeFiles/CMakeDirectoryInformation.cmake +++ /dev/null @@ -1,16 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.28 - -# Relative path conversion top directories. -set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/jaro/crepe/src") -set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/jaro/crepe/src/crepe") - -# Force unix paths in dependencies. -set(CMAKE_FORCE_UNIX_PATHS 1) - - -# The C and CXX include file regular expressions for this directory. -set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$") -set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$") -set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN}) -set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN}) diff --git a/src/crepe/crepe/CMakeFiles/progress.marks b/src/crepe/crepe/CMakeFiles/progress.marks deleted file mode 100644 index 573541a..0000000 --- a/src/crepe/crepe/CMakeFiles/progress.marks +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/src/crepe/crepe/Makefile b/src/crepe/crepe/Makefile deleted file mode 100644 index 094215a..0000000 --- a/src/crepe/crepe/Makefile +++ /dev/null @@ -1,140 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.28 - -# Default target executed when no arguments are given to make. -default_target: all -.PHONY : default_target - -# Allow only one "make -f Makefile2" at a time, but pass parallelism. -.NOTPARALLEL: - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - -# Disable VCS-based implicit rules. -% : %,v - -# Disable VCS-based implicit rules. -% : RCS/% - -# Disable VCS-based implicit rules. -% : RCS/%,v - -# Disable VCS-based implicit rules. -% : SCCS/s.% - -# Disable VCS-based implicit rules. -% : s.% - -.SUFFIXES: .hpux_make_needs_suffix_list - -# Command-line flag to silence nested $(MAKE). -$(VERBOSE)MAKESILENT = -s - -#Suppress display of executed commands. -$(VERBOSE).SILENT: - -# A target that is always out of date. -cmake_force: -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake - -# The command to remove a file. -RM = /usr/bin/cmake -E rm -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/jaro/crepe/src - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/jaro/crepe/src/crepe - -#============================================================================= -# Targets provided globally by CMake. - -# Special rule for the target edit_cache -edit_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "No interactive CMake dialog available..." - /usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available. -.PHONY : edit_cache - -# Special rule for the target edit_cache -edit_cache/fast: edit_cache -.PHONY : edit_cache/fast - -# Special rule for the target rebuild_cache -rebuild_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake to regenerate build system..." - /usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : rebuild_cache - -# Special rule for the target rebuild_cache -rebuild_cache/fast: rebuild_cache -.PHONY : rebuild_cache/fast - -# The main all target -all: cmake_check_build_system - cd /home/jaro/crepe/src/crepe && $(CMAKE_COMMAND) -E cmake_progress_start /home/jaro/crepe/src/crepe/CMakeFiles /home/jaro/crepe/src/crepe/crepe//CMakeFiles/progress.marks - cd /home/jaro/crepe/src/crepe && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 crepe/all - $(CMAKE_COMMAND) -E cmake_progress_start /home/jaro/crepe/src/crepe/CMakeFiles 0 -.PHONY : all - -# The main clean target -clean: - cd /home/jaro/crepe/src/crepe && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 crepe/clean -.PHONY : clean - -# The main clean target -clean/fast: clean -.PHONY : clean/fast - -# Prepare targets for installation. -preinstall: all - cd /home/jaro/crepe/src/crepe && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 crepe/preinstall -.PHONY : preinstall - -# Prepare targets for installation. -preinstall/fast: - cd /home/jaro/crepe/src/crepe && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 crepe/preinstall -.PHONY : preinstall/fast - -# clear depends -depend: - cd /home/jaro/crepe/src/crepe && $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 -.PHONY : depend - -# Help Target -help: - @echo "The following are some of the valid targets for this Makefile:" - @echo "... all (the default if no target is provided)" - @echo "... clean" - @echo "... depend" - @echo "... edit_cache" - @echo "... rebuild_cache" -.PHONY : help - - - -#============================================================================= -# Special targets to cleanup operation of make. - -# Special rule to run CMake to check the build system integrity. -# No rule that depends on this can have commands that come from listfiles -# because they might be regenerated. -cmake_check_build_system: - cd /home/jaro/crepe/src/crepe && $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 -.PHONY : cmake_check_build_system - diff --git a/src/crepe/crepe/cmake_install.cmake b/src/crepe/crepe/cmake_install.cmake deleted file mode 100644 index cd57803..0000000 --- a/src/crepe/crepe/cmake_install.cmake +++ /dev/null @@ -1,44 +0,0 @@ -# Install script for directory: /home/jaro/crepe/src/crepe - -# Set the install prefix -if(NOT DEFINED CMAKE_INSTALL_PREFIX) - set(CMAKE_INSTALL_PREFIX "/usr/local") -endif() -string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") - -# Set the install configuration name. -if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) - if(BUILD_TYPE) - string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" - CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") - else() - set(CMAKE_INSTALL_CONFIG_NAME "Debug") - endif() - message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") -endif() - -# Set the component getting installed. -if(NOT CMAKE_INSTALL_COMPONENT) - if(COMPONENT) - message(STATUS "Install component: \"${COMPONENT}\"") - set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") - else() - set(CMAKE_INSTALL_COMPONENT) - endif() -endif() - -# Install shared libraries without execute permission? -if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) - set(CMAKE_INSTALL_SO_NO_EXE "1") -endif() - -# Is this installation the result of a crosscompile? -if(NOT DEFINED CMAKE_CROSSCOMPILING) - set(CMAKE_CROSSCOMPILING "FALSE") -endif() - -# Set default install directory permissions. -if(NOT DEFINED CMAKE_OBJDUMP) - set(CMAKE_OBJDUMP "/usr/bin/objdump") -endif() - diff --git a/src/crepe/util/log.h b/src/crepe/util/log.h index e2776c9..3e36f0a 100644 --- a/src/crepe/util/log.h +++ b/src/crepe/util/log.h @@ -9,7 +9,7 @@ #define _crepe_logf_here(fmt, ...) \ crepe::util::logf(util::log_level::DEBUG, "%s%s (%s:%d)%s" fmt "\n", \ crepe::util::color::FG_WHITE, __PRETTY_FUNCTION__, \ - __FILE__, __LINE__, crepe::util::color::RESET, \ + __FILE_NAME__, __LINE__, crepe::util::color::RESET, \ __VA_ARGS__) // very illegal global function-style macros diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt index 4295d19..587a7bd 100644 --- a/src/example/CMakeLists.txt +++ b/src/example/CMakeLists.txt @@ -17,9 +17,9 @@ function(add_example target_name) endfunction() add_example(audio_internal) -add_example(components_internal) +# add_example(components_internal) add_example(script) add_example(rendering) add_example(asset_manager) add_example(particle) -add_example(Physics) +add_example(physics) diff --git a/src/example/components_internal.cpp b/src/example/components_internal.cpp index ae6c765..3c68974 100644 --- a/src/example/components_internal.cpp +++ b/src/example/components_internal.cpp @@ -9,7 +9,6 @@ #include <crepe/Component.h> #include <crepe/ComponentManager.h> -#include <crepe/api/Collider.h> #include <crepe/api/GameObject.h> #include <crepe/api/Rigidbody.h> #include <crepe/api/Sprite.h> @@ -36,14 +35,13 @@ int main() { game_object[i]->add_component<Sprite>("test"); game_object[i]->add_component<Rigidbody>(0, 0, i); - game_object[i]->add_component<Collider>(i); } auto stop_adding = chrono::high_resolution_clock::now(); auto sprites = mgr.get_components_by_type<Sprite>(); - for (auto & sprite : sprites) { - assert(sprite.path == "test"); + for (auto sprite : sprites) { + assert(true); } auto stop_looping = chrono::high_resolution_clock::now(); diff --git a/src/example/Physics.cpp b/src/example/physics.cpp index ee75c5c..ee75c5c 100644 --- a/src/example/Physics.cpp +++ b/src/example/physics.cpp |