diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-06 11:58:27 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-06 11:58:27 +0100 |
commit | 7126db6e1d97b7ede4cc929abfdeadd360e4cb74 (patch) | |
tree | b93d87321025b3730ef5534033a3a790abf41138 | |
parent | d4f443070017c5c2e6a938bf4d0a86b70ae6beaa (diff) |
WIP
-rw-r--r-- | game/prefab/CMakeLists.txt | 1 | ||||
-rw-r--r-- | game/prefab/ZapperObject.cpp | 8 | ||||
-rw-r--r-- | game/prefab/ZapperObject.h | 2 | ||||
-rw-r--r-- | game/prefab/ZapperScript.cpp | 20 | ||||
-rw-r--r-- | game/prefab/ZapperScript.h | 17 | ||||
-rwxr-xr-x | game/util/scrollgen | 36 |
6 files changed, 39 insertions, 45 deletions
diff --git a/game/prefab/CMakeLists.txt b/game/prefab/CMakeLists.txt index 03084e4..5585a32 100644 --- a/game/prefab/CMakeLists.txt +++ b/game/prefab/CMakeLists.txt @@ -2,6 +2,5 @@ target_sources(main PUBLIC PlayerObject.cpp PlayerScript.cpp ZapperObject.cpp - ZapperScript.cpp ) diff --git a/game/prefab/ZapperObject.cpp b/game/prefab/ZapperObject.cpp index b848f18..e63a5f2 100644 --- a/game/prefab/ZapperObject.cpp +++ b/game/prefab/ZapperObject.cpp @@ -1,6 +1,5 @@ #include "ZapperObject.h" #include "Config.h" -#include "ZapperScript.h" using namespace crepe; @@ -67,14 +66,13 @@ ZapperObject::ZapperObject(crepe::GameObject && base) 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), + sprite.glow_start, ivec2(128, 128), uvec2(16, 1), Animator::Data { .fps = 30, .looping = true, } ), .glow_end = add_component<Animator>( - sprite.glow_end, ivec2(128, 128), uvec2(4, 4), animator.glow_start.data + sprite.glow_end, ivec2(128, 128), uvec2(16, 1), animator.glow_start.data ), - }, - controller(add_component<BehaviorScript>().set_script<ZapperScript>(*this)) {} + } {} diff --git a/game/prefab/ZapperObject.h b/game/prefab/ZapperObject.h index 151e368..cc2d37c 100644 --- a/game/prefab/ZapperObject.h +++ b/game/prefab/ZapperObject.h @@ -1,7 +1,6 @@ #pragma once #include <crepe/api/Animator.h> -#include <crepe/api/BehaviorScript.h> #include <crepe/api/BoxCollider.h> #include <crepe/api/GameObject.h> #include <crepe/api/Rigidbody.h> @@ -29,7 +28,6 @@ public: // crepe::Rigidbody & body; // crepe::BoxCollider & collider; - crepe::BehaviorScript & controller; private: static constexpr int SCALE = 60; diff --git a/game/prefab/ZapperScript.cpp b/game/prefab/ZapperScript.cpp deleted file mode 100644 index 01eb7aa..0000000 --- a/game/prefab/ZapperScript.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include <cassert> -#include <crepe/api/Rigidbody.h> - -#include "ZapperScript.h" - -using namespace crepe; -using namespace std; - -ZapperScript::ZapperScript(const ZapperObject & zapper) : zapper(zapper) {} - -void ZapperScript::init() { - zapper.sprite.beam.mask = { - .w = 350, - .h = 117, - .x = 0, - .y = 0, - }; -} - -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 deleted file mode 100644 index b090c8d..0000000 --- a/game/prefab/ZapperScript.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include <crepe/api/Script.h> - -#include "ZapperObject.h" - -class ZapperScript : public crepe::Script { -public: - ZapperScript(const ZapperObject & zapper); - -protected: - void init(); - void frame_update(crepe::duration_t delta_time); - -protected: - ZapperObject zapper; -}; diff --git a/game/util/scrollgen b/game/util/scrollgen new file mode 100755 index 0000000..0389107 --- /dev/null +++ b/game/util/scrollgen @@ -0,0 +1,36 @@ +#!/bin/sh +INPUT="$1" +FRAMES="$2" + +die() { + echo "$@" + exit 1 +} +check_command() { + cmd="$1" + command -v "$cmd" > /dev/null || die "command '$cmd' not found" +} + +check_command magick +check_command identify +[ "$#" -eq 2 ] || die "usage: $0 <input image> <frame count>" +[ -e "$INPUT" ] || die "file not found: $INPUT" +[ "$FRAMES" -gt 0 ] || die "invalid frame count: $FRAMES" + +tile_width=$(identify -format "%w" "$INPUT") +tile_height=$(identify -format "%h" "$INPUT") + +OUTPUT="$INPUT.scroll.png" +magick -size "${tile_width}x$(( $tile_height * $FRAMES ))" 'xc:#ff00ff00' "$OUTPUT" + +for i in $(seq 0 $(( $FRAMES - 1 ))); do + offset_x=$(( $tile_width * $i / $FRAMES )) + offset_y=$(( i * $tile_height )) + + magick "$OUTPUT" "$INPUT" -geometry "+${offset_x}+${offset_y}" -composite "$OUTPUT" + magick "$OUTPUT" "$INPUT" -geometry "+$(( $offset_x - $tile_width ))+${offset_y}" -composite "$OUTPUT" + echo "+${offset_x}+${offset_y}" +done + +# magick -size ${total_width}x${sprite_height} xc:none canvas.png + |