diff options
-rw-r--r-- | game/coins/CoinSubScene.cpp | 4 | ||||
-rw-r--r-- | game/coins/CoinSystemScript.cpp | 118 | ||||
-rw-r--r-- | game/coins/CoinSystemScript.h | 41 |
3 files changed, 154 insertions, 9 deletions
diff --git a/game/coins/CoinSubScene.cpp b/game/coins/CoinSubScene.cpp index 97f5877..0a1cd68 100644 --- a/game/coins/CoinSubScene.cpp +++ b/game/coins/CoinSubScene.cpp @@ -18,7 +18,9 @@ int CoinSubScene::create(Scene & scn){ cout << "new coin: "<< unique_name << endl; GameObject coin = scn.new_object(unique_name.c_str(),"coin",vec2{650,0},0,1); - coin.add_component<Rigidbody>(Rigidbody::Data{}); + coin.add_component<Rigidbody>(Rigidbody::Data{ + .body_type = Rigidbody::BodyType::KINEMATIC + }); coin.add_component<CircleCollider>(size.x / 2).active = false; crepe::OptionalRef<crepe::Sprite> coin_sprite = coin.add_component<Sprite>(Asset{"asset/coin/coin1_TVOS.png"}, Sprite::Data{ .sorting_in_layer = 100, diff --git a/game/coins/CoinSystemScript.cpp b/game/coins/CoinSystemScript.cpp index 6cab12d..b28dab1 100644 --- a/game/coins/CoinSystemScript.cpp +++ b/game/coins/CoinSystemScript.cpp @@ -12,9 +12,11 @@ std::vector<CoinData> CoinSystemScript::coin_locations; void CoinSystemScript::init() { float position = 1200; - position += this->preset_1({position,0}); - position += 100; - position += this->preset_2({position,0}); + // position += this->preset_1({position,0}); + // position += 100; + // position += this->preset_2({position,0}); + // position += 100; + position += this->preset_5({position,0}); } @@ -85,6 +87,116 @@ float CoinSystemScript::preset_2(const vec2 & begin_position){ return middle.x-begin_position.x; } +float CoinSystemScript::preset_3(const vec2 & begin_position){ + vec2 location = {begin_position.x, begin_position.y - (this->ROW_OFFSET_3)}; + + + // Add locations for the top row + for (int i = 0; i < COLUM_AMOUNT_3; ++i) { + add_location(location); + location.x += this->COLUM_OFFSET_3; + } + + // Add locations for the bottom row + location.y +=this->ROW_OFFSET_3; + location.x += this->COLUM_OFFSET_3; + for (int i = 0; i < COLUM_AMOUNT_3; ++i) { + add_location(location); + location.x += this->COLUM_OFFSET_3; + } + + // Add locations for the next set of the top row + location.y +=this->ROW_OFFSET_3; + location.x += this->COLUM_OFFSET_3; + for (int i = 0; i < COLUM_AMOUNT_3; ++i) { + add_location(location); + location.x += this->COLUM_OFFSET_3; + } + + return location.x-begin_position.x; +} + +float CoinSystemScript::preset_4(const vec2 & begin_position){ + vec2 location = {begin_position.x, begin_position.y + (this->ROW_OFFSET_4)}; + + + // Add locations for the top row + for (int i = 0; i < COLUM_AMOUNT_4; ++i) { + add_location(location); + location.x += this->COLUM_OFFSET_4; + } + + // Add locations for the bottom row + location.y -=this->ROW_OFFSET_4; + location.x += this->COLUM_OFFSET_4; + for (int i = 0; i < COLUM_AMOUNT_4; ++i) { + add_location(location); + location.x += this->COLUM_OFFSET_4; + } + + // Add locations for the next set of the top row + location.y -=this->ROW_OFFSET_4; + location.x += this->COLUM_OFFSET_4; + for (int i = 0; i < COLUM_AMOUNT_4; ++i) { + add_location(location); + location.x += this->COLUM_OFFSET_4; + } + + return location.x-begin_position.x; +} + +float CoinSystemScript::preset_5(const vec2 & begin_position){ + vec2 location = {begin_position.x, begin_position.y-ROW_OFFSET_5/2}; + float locationx = 0; + for (int i = 0; i < 2; ++i) { + // Add locations for the top row + location.y -= ROW_OFFSET_5*6; + for (int i = 0; i < COLUM_AMOUNT_5; ++i) { + add_location(location); + location.x += this->COLUM_OFFSET_5; + } + location.x = begin_position.x; + location.y += ROW_OFFSET_5; + for (int i = 0; i < COLUM_AMOUNT_5; ++i) { + add_location(location); + location.x += this->COLUM_OFFSET_5; + } + + + // Add locations for the middle row + location.x = begin_position.x + COLUM_OFFSET_5*COLUM_AMOUNT_5*2; + location.y += ROW_OFFSET_5*6; + for (int i = 0; i < COLUM_AMOUNT_5; ++i) { + add_location(location); + location.x += this->COLUM_OFFSET_5; + } + location.x = begin_position.x + COLUM_OFFSET_5*COLUM_AMOUNT_5*2; + location.y += ROW_OFFSET_5; + for (int i = 0; i < COLUM_AMOUNT_5; ++i) { + add_location(location); + location.x += this->COLUM_OFFSET_5; + } + locationx = location.x; + + // Add locations for the bottom row + location.x = begin_position.x; + location.y += ROW_OFFSET_5*6; + for (int i = 0; i < COLUM_AMOUNT_5; ++i) { + add_location(location); + location.x += this->COLUM_OFFSET_5; + } + location.x = begin_position.x; + location.y += ROW_OFFSET_5; + for (int i = 0; i < COLUM_AMOUNT_5; ++i) { + add_location(location); + location.x += this->COLUM_OFFSET_5; + } + location.x = locationx + COLUM_OFFSET_5; + } + return location.x-begin_position.x; +} + + void CoinSystemScript::frame_update(crepe::duration_t dt) { diff --git a/game/coins/CoinSystemScript.h b/game/coins/CoinSystemScript.h index f17c160..8dcd793 100644 --- a/game/coins/CoinSystemScript.h +++ b/game/coins/CoinSystemScript.h @@ -17,6 +17,9 @@ private: void spawn_coins(); float preset_1(const crepe::vec2 & begin_position); float preset_2(const crepe::vec2 & begin_position); + float preset_3(const crepe::vec2 & begin_position); + float preset_4(const crepe::vec2 & begin_position); + float preset_5(const crepe::vec2 & begin_position); private: static constexpr float SPAWN_DISTANCE = 400; static constexpr float DESPAWN_DISTANCE = 400; @@ -34,12 +37,40 @@ private: static constexpr int COLUM_AMOUNT_1 = 5; private: // preset two settings -// ***** ***** -// -// -// -// ***** ***** +// +// ******** +// ********** +// ******** +// static constexpr float ROW_OFFSET_2 = 25; static constexpr float COLUM_OFFSET_2 = 25; static constexpr int COLUM_AMOUNT_2 = 10; +// preset three settings +// *** +// +// *** +// +// *** + static constexpr float ROW_OFFSET_3 = 100; + static constexpr float COLUM_OFFSET_3 = 25; + static constexpr int COLUM_AMOUNT_3 = 3; +// preset four settings +// *** +// +// *** +// +// *** + static constexpr float ROW_OFFSET_4 = 100; + static constexpr float COLUM_OFFSET_4 = 25; + static constexpr int COLUM_AMOUNT_4 = 3; +// preset five settings +// ** ** +// ** ** +// ** +// ** +// ** ** +// ** ** + static constexpr float ROW_OFFSET_5 = 25; + static constexpr float COLUM_OFFSET_5 = 25; + static constexpr int COLUM_AMOUNT_5 = 2; }; |