From 26d66b7a73ac8d172d342be03bd75bd5bea221e1 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Sat, 28 Dec 2024 16:22:58 +0100 Subject: coin system --- game/coins/CoinSubScene.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 game/coins/CoinSubScene.cpp (limited to 'game/coins/CoinSubScene.cpp') diff --git a/game/coins/CoinSubScene.cpp b/game/coins/CoinSubScene.cpp new file mode 100644 index 0000000..12ddb7a --- /dev/null +++ b/game/coins/CoinSubScene.cpp @@ -0,0 +1,35 @@ +#include "CoinSubScene.h" +#include "api/Animator.h" +#include "api/CircleCollider.h" +#include "api/Rigidbody.h" +#include "api/Scene.h" +#include "api/AudioSource.h" +#include + +using namespace crepe; +using namespace std; + +int CoinSubScene::create(Scene & scn){ + vec2 size = {20, 20}; + + static int coin_counter = 0; + std::string unique_name = "coin_" + std::to_string(coin_counter++); + + + GameObject coin = scn.new_object(unique_name.c_str(),"coin",vec2{0,0},0,1); + coin.add_component(Rigidbody::Data{}); + coin.add_component(size.x / 2).active = false; + crepe::OptionalRef coin_sprite = coin.add_component(Asset{"asset/coin/coin1_TVOS.png"}, Sprite::Data{ + .sorting_in_layer = 100, + .order_in_layer = 100, + .size = size, + }); + // coin_sprite->active = false; + coin.add_component(coin_sprite, ivec2{32, 32}, uvec2{8, 1}, + Animator::Data{ + .fps = 15, + .looping = true, + }); + coin.add_component(Asset{"asset/sfx/coin_pickup_1.ogg"}); + return coin_counter; +} -- cgit v1.2.3