diff options
-rw-r--r-- | game/GameScene.cpp | 2 | ||||
-rw-r--r-- | game/prefab/PlayerObject.cpp | 3 | ||||
-rw-r--r-- | game/prefab/PlayerScript.cpp | 8 | ||||
-rw-r--r-- | game/prefab/PlayerScript.h | 1 | ||||
-rw-r--r-- | game/prefab/ZapperObject.cpp | 92 | ||||
-rw-r--r-- | game/prefab/ZapperObject.h | 1 | ||||
-rw-r--r-- | game/prefab/ZapperScript.cpp | 9 | ||||
-rw-r--r-- | game/prefab/ZapperScript.h | 1 | ||||
-rw-r--r-- | src/crepe/api/Animator.cpp | 1 | ||||
-rw-r--r-- | src/crepe/api/Animator.h | 2 | ||||
-rw-r--r-- | src/crepe/api/Engine.cpp | 3 | ||||
-rw-r--r-- | src/crepe/facade/SignalCatch.cpp | 9 | ||||
-rw-r--r-- | src/crepe/facade/SignalCatch.h | 3 | ||||
-rw-r--r-- | src/crepe/manager/SystemManager.cpp | 10 | ||||
-rw-r--r-- | src/crepe/manager/SystemManager.hpp | 2 | ||||
-rw-r--r-- | src/crepe/system/AnimatorSystem.cpp | 2 | ||||
-rw-r--r-- | src/crepe/system/ScriptSystem.cpp | 12 |
17 files changed, 77 insertions, 84 deletions
diff --git a/game/GameScene.cpp b/game/GameScene.cpp index 90a8b58..b287763 100644 --- a/game/GameScene.cpp +++ b/game/GameScene.cpp @@ -14,8 +14,8 @@ #include <crepe/api/Transform.h> #include <crepe/types.h> -#include "GameScene.h" #include "Config.h" +#include "GameScene.h" #include "MoveCameraManualyScript.h" #include "StartGameScript.h" diff --git a/game/prefab/PlayerObject.cpp b/game/prefab/PlayerObject.cpp index ef7b6cc..2d48bf8 100644 --- a/game/prefab/PlayerObject.cpp +++ b/game/prefab/PlayerObject.cpp @@ -1,5 +1,5 @@ -#include "Config.h" #include "PlayerObject.h" +#include "Config.h" #include "PlayerScript.h" using namespace crepe; @@ -69,4 +69,3 @@ PlayerObject::PlayerObject(crepe::GameObject && base) sprite.jetpack.active = false; controller.active = false; } - diff --git a/game/prefab/PlayerScript.cpp b/game/prefab/PlayerScript.cpp index 67aadb6..3d06476 100644 --- a/game/prefab/PlayerScript.cpp +++ b/game/prefab/PlayerScript.cpp @@ -1,15 +1,13 @@ -#include <crepe/api/Rigidbody.h> #include <cassert> +#include <crepe/api/Rigidbody.h> #include "PlayerScript.h" using namespace crepe; using namespace std; -PlayerScript::PlayerScript(const PlayerObject & player) : player(player) { } +PlayerScript::PlayerScript(const PlayerObject & player) : player(player) {} void PlayerScript::fixed_update(crepe::duration_t dt) { - if (this->get_key_state(Keycode::SPACE)) - player.body.add_force_linear({ 0, -10 }); + if (this->get_key_state(Keycode::SPACE)) player.body.add_force_linear({0, -10}); } - diff --git a/game/prefab/PlayerScript.h b/game/prefab/PlayerScript.h index 131c73f..cc0f0aa 100644 --- a/game/prefab/PlayerScript.h +++ b/game/prefab/PlayerScript.h @@ -14,4 +14,3 @@ protected: protected: PlayerObject player; }; - diff --git a/game/prefab/ZapperObject.cpp b/game/prefab/ZapperObject.cpp index 2791162..b848f18 100644 --- a/game/prefab/ZapperObject.cpp +++ b/game/prefab/ZapperObject.cpp @@ -1,5 +1,5 @@ -#include "Config.h" #include "ZapperObject.h" +#include "Config.h" #include "ZapperScript.h" using namespace crepe; @@ -11,74 +11,70 @@ ZapperObject::ZapperObject(crepe::GameObject && base) Asset {"asset/obstacles/zapper/orbAnim.png"}, Sprite::Data { .sorting_in_layer = SORT_IN_LAY_OBSTACLES, - .order_in_layer = 1, - .size = vec2{0, 1} * SCALE, - .position_offset = {0, 100}, + .order_in_layer = 1, + .size = vec2 {0, 1} * SCALE, + .position_offset = {0, 100}, } ), .orb_end = add_component<Sprite>( - sprite.orb_start.source, - Sprite::Data { - .flip = {true, true}, - .sorting_in_layer = SORT_IN_LAY_OBSTACLES, - .order_in_layer = 1, - .size = vec2{0, 1} * SCALE, - .position_offset = {0, -100}, - } + sprite.orb_start.source, + Sprite::Data { + .flip = {true, true}, + .sorting_in_layer = SORT_IN_LAY_OBSTACLES, + .order_in_layer = 1, + .size = vec2 {0, 1} * SCALE, + .position_offset = {0, -100}, + } ), .glow_start = add_component<Sprite>( Asset {"asset/obstacles/zapper/regular_zappers/glow.png"}, Sprite::Data { .sorting_in_layer = SORT_IN_LAY_OBSTACLES, - .order_in_layer = -1, - .size = vec2{2, 2} * SCALE, - .position_offset = {0, 100}, + .order_in_layer = -1, + .size = vec2 {2, 2} * SCALE, + .position_offset = {0, 100}, } ), .glow_end = add_component<Sprite>( - sprite.glow_start.source, - Sprite::Data { - .flip = {true, true}, - .sorting_in_layer = SORT_IN_LAY_OBSTACLES, - .order_in_layer = -1, - .size = vec2{2, 2} * SCALE, - .position_offset = {0, -100}, - } + sprite.glow_start.source, + Sprite::Data { + .flip = {true, true}, + .sorting_in_layer = SORT_IN_LAY_OBSTACLES, + .order_in_layer = -1, + .size = vec2 {2, 2} * SCALE, + .position_offset = {0, -100}, + } ), - .beam = add_component<Sprite>( + .beam = add_component<Sprite>( Asset {"asset/obstacles/zapper/regular_zappers/zapEffect.png"}, Sprite::Data { .sorting_in_layer = SORT_IN_LAY_OBSTACLES, - .order_in_layer = 0, - .size = vec2{200, 50}, - .angle_offset = 90, + .order_in_layer = 0, + .size = vec2 {200, 50}, + .angle_offset = 90, } - ), + ), }, animator { - .orb_start = add_component<Animator>( + .orb_start = add_component<Animator>( sprite.orb_start, ivec2(62, 42), uvec2(4, 1), Animator::Data { .fps = 10, .looping = true, } - ), - .orb_end = add_component<Animator>( - sprite.orb_end, ivec2(62, 42), uvec2(4, 1), - animator.orb_start.data - ), - .glow_start = add_component<Animator>( - sprite.glow_start, ivec2(128, 128), uvec2(4, 4), - Animator::Data { - .fps = 30, - .looping = true, - } - ), - .glow_end = add_component<Animator>( - sprite.glow_end, ivec2(128, 128), uvec2(4, 4), - animator.glow_start.data - ), + ), + .orb_end = add_component<Animator>( + sprite.orb_end, ivec2(62, 42), uvec2(4, 1), animator.orb_start.data + ), + .glow_start = add_component<Animator>( + sprite.glow_start, ivec2(128, 128), uvec2(4, 4), + Animator::Data { + .fps = 30, + .looping = true, + } + ), + .glow_end = add_component<Animator>( + sprite.glow_end, ivec2(128, 128), uvec2(4, 4), animator.glow_start.data + ), }, - controller(add_component<BehaviorScript>().set_script<ZapperScript>(*this)) -{ } - + controller(add_component<BehaviorScript>().set_script<ZapperScript>(*this)) {} diff --git a/game/prefab/ZapperObject.h b/game/prefab/ZapperObject.h index 6b68146..151e368 100644 --- a/game/prefab/ZapperObject.h +++ b/game/prefab/ZapperObject.h @@ -34,4 +34,3 @@ public: private: static constexpr int SCALE = 60; }; - diff --git a/game/prefab/ZapperScript.cpp b/game/prefab/ZapperScript.cpp index b9b24be..01eb7aa 100644 --- a/game/prefab/ZapperScript.cpp +++ b/game/prefab/ZapperScript.cpp @@ -1,12 +1,12 @@ -#include <crepe/api/Rigidbody.h> #include <cassert> +#include <crepe/api/Rigidbody.h> #include "ZapperScript.h" using namespace crepe; using namespace std; -ZapperScript::ZapperScript(const ZapperObject & zapper) : zapper(zapper) { } +ZapperScript::ZapperScript(const ZapperObject & zapper) : zapper(zapper) {} void ZapperScript::init() { zapper.sprite.beam.mask = { @@ -17,7 +17,4 @@ void ZapperScript::init() { }; } -void ZapperScript::frame_update(duration_t delta_time) { - zapper.sprite.beam.mask.x += 4; -} - +void ZapperScript::frame_update(duration_t delta_time) { zapper.sprite.beam.mask.x += 4; } diff --git a/game/prefab/ZapperScript.h b/game/prefab/ZapperScript.h index 5a960df..b090c8d 100644 --- a/game/prefab/ZapperScript.h +++ b/game/prefab/ZapperScript.h @@ -15,4 +15,3 @@ protected: protected: ZapperObject zapper; }; - diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index 5ac0617..f6f2654 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -44,4 +44,3 @@ void Animator::set_cycle_range(int start, int end) { this->data.cycle_start = start; this->data.cycle_end = end; } - diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h index 8be693e..bcf6379 100644 --- a/src/crepe/api/Animator.h +++ b/src/crepe/api/Animator.h @@ -1,7 +1,7 @@ #pragma once -#include "../types.h" #include "../manager/LoopTimerManager.h" +#include "../types.h" #include "Component.h" #include "Sprite.h" diff --git a/src/crepe/api/Engine.cpp b/src/crepe/api/Engine.cpp index bf3f50c..8766aea 100644 --- a/src/crepe/api/Engine.cpp +++ b/src/crepe/api/Engine.cpp @@ -1,7 +1,7 @@ #include <segvcatch.h> -#include "../util/Log.h" #include "../facade/SignalCatch.h" +#include "../util/Log.h" #include "Engine.h" @@ -77,4 +77,3 @@ void Engine::frame_update() { this->system_manager.frame_update(); this->loop_timer.enforce_frame_rate(); } - diff --git a/src/crepe/facade/SignalCatch.cpp b/src/crepe/facade/SignalCatch.cpp index ad92d28..4988047 100644 --- a/src/crepe/facade/SignalCatch.cpp +++ b/src/crepe/facade/SignalCatch.cpp @@ -15,11 +15,6 @@ SignalCatch::~SignalCatch() { segvcatch::init_fpe(); } -void SignalCatch::segv() { - throw runtime_error("segmentation fault"); -} - -void SignalCatch::fpe() { - throw domain_error("floating point exception"); -} +void SignalCatch::segv() { throw runtime_error("segmentation fault"); } +void SignalCatch::fpe() { throw domain_error("floating point exception"); } diff --git a/src/crepe/facade/SignalCatch.h b/src/crepe/facade/SignalCatch.h index 4562215..cf86b56 100644 --- a/src/crepe/facade/SignalCatch.h +++ b/src/crepe/facade/SignalCatch.h @@ -20,5 +20,4 @@ public: SignalCatch & operator=(SignalCatch &&) = delete; }; -} - +} // namespace crepe diff --git a/src/crepe/manager/SystemManager.cpp b/src/crepe/manager/SystemManager.cpp index c8f4f3d..fea59aa 100644 --- a/src/crepe/manager/SystemManager.cpp +++ b/src/crepe/manager/SystemManager.cpp @@ -37,7 +37,10 @@ void SystemManager::fixed_update() noexcept { try { entry.system.fixed_update(); } catch (const exception & e) { - Log::logf(Log::Level::WARNING, "Uncaught exception in {} fixed update: {}", entry.name, e.what()); + Log::logf( + Log::Level::WARNING, "Uncaught exception in {} fixed update: {}", entry.name, + e.what() + ); } } } @@ -48,7 +51,10 @@ void SystemManager::frame_update() noexcept { try { entry.system.frame_update(); } catch (const exception & e) { - Log::logf(Log::Level::WARNING, "Uncaught exception in {} frame update: {}", entry.name, e.what()); + Log::logf( + Log::Level::WARNING, "Uncaught exception in {} frame update: {}", entry.name, + e.what() + ); } } } diff --git a/src/crepe/manager/SystemManager.hpp b/src/crepe/manager/SystemManager.hpp index a4c11e3..a19a253 100644 --- a/src/crepe/manager/SystemManager.hpp +++ b/src/crepe/manager/SystemManager.hpp @@ -38,7 +38,7 @@ void SystemManager::load_system() { throw runtime_error(format("SystemManager: {} is already initialized", type.name())); System * system = new T(this->mediator); this->systems[type] = unique_ptr<System>(system); - this->system_order.push_back(SystemEntry{ + this->system_order.push_back(SystemEntry { .system = *this->systems[type], .name = type.name(), }); diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp index 467d2a2..6c93372 100644 --- a/src/crepe/system/AnimatorSystem.cpp +++ b/src/crepe/system/AnimatorSystem.cpp @@ -30,7 +30,7 @@ void AnimatorSystem::frame_update() { if (animator.elapsed > frame_duration) { animator.elapsed = 0ms; animator.data.frame++; - + if (animator.data.looping && animator.data.frame >= animator.data.cycle_end) animator.data.frame = animator.data.cycle_start; } diff --git a/src/crepe/system/ScriptSystem.cpp b/src/crepe/system/ScriptSystem.cpp index 411a9a3..f1e31f9 100644 --- a/src/crepe/system/ScriptSystem.cpp +++ b/src/crepe/system/ScriptSystem.cpp @@ -36,7 +36,11 @@ void ScriptSystem::update( script->init(); script->initialized = true; } catch (const exception & e) { - Log::logf(Log::Level::WARNING, "Disabled script \"{}\" due to exception in init function: {}", behavior_script.name, e.what()); + Log::logf( + Log::Level::WARNING, + "Disabled script \"{}\" due to exception in init function: {}", + behavior_script.name, e.what() + ); behavior_script.active = false; } } @@ -45,7 +49,11 @@ void ScriptSystem::update( (*script.*update_function)(delta_time); } catch (const exception & e) { // TODO: discern between fixed/frame update - Log::logf(Log::Level::WARNING, "Disabled script \"{}\" due to exception in update function: {}", behavior_script.name, e.what()); + Log::logf( + Log::Level::WARNING, + "Disabled script \"{}\" due to exception in update function: {}", + behavior_script.name, e.what() + ); behavior_script.active = false; } } |