aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-12-17 14:34:18 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-12-17 14:34:18 +0100
commitf2a95686ec6d33d15f38fef4420700cefc875e89 (patch)
tree7d4795de7abfce70dd58ee8e9e8c019112dbbe83 /src
parentf7b8062d6a33195bfc43af0f2a7b6c16a388b588 (diff)
Made wall fragments for start
Diffstat (limited to 'src')
-rw-r--r--src/example/GameScene.cpp11
-rw-r--r--src/example/Start.cpp246
-rw-r--r--src/example/Start.h1
3 files changed, 258 insertions, 0 deletions
diff --git a/src/example/GameScene.cpp b/src/example/GameScene.cpp
index 343f26c..5ab4be0 100644
--- a/src/example/GameScene.cpp
+++ b/src/example/GameScene.cpp
@@ -56,6 +56,17 @@ public:
Sprite & hole_sprite = this->get_components_by_name<Sprite>("start_hole").front();
hole_sprite.active = true;
+ RefVector<Rigidbody> frags_rg
+ = this->get_components_by_tag<Rigidbody>("wall_fragment");
+ RefVector<Sprite> frags_sprite
+ = this->get_components_by_tag<Sprite>("wall_fragment");
+ for (Rigidbody & frag_rg : frags_rg) {
+ frag_rg.active = true;
+ }
+ for (Sprite & frag_sprite : frags_sprite) {
+ frag_sprite.active = true;
+ }
+
this->created_hole = true;
}
diff --git a/src/example/Start.cpp b/src/example/Start.cpp
index 846c34f..f710a3a 100644
--- a/src/example/Start.cpp
+++ b/src/example/Start.cpp
@@ -1,5 +1,7 @@
#include "Start.h"
#include "api/Asset.h"
+#include "api/CircleCollider.h"
+#include "api/Rigidbody.h"
#include "types.h"
#include <crepe/api/Animator.h>
@@ -11,6 +13,8 @@ using namespace crepe;
using namespace std;
float Start::create(Scene & scn, float begin_x) {
+ this->create_wall_fragments(scn, begin_x - 300);
+
GameObject begin = scn.new_object("start_begin", "background", vec2(begin_x, 0));
Asset begin_asset{"asset/jetpack_joyride/background/start/titleFG_1_TVOS.png"};
begin.add_component<Sprite>(begin_asset, Sprite::Data{
@@ -140,3 +144,245 @@ void Start::add_jetpack_stand(crepe::GameObject & obj, crepe::vec2 offset) {
.position_offset = offset + vec2(-75, -25),
});
}
+
+void Start::create_wall_fragments(crepe::Scene & scn, float begin_x) {
+ GameObject frag_1 = scn.new_object("frag_1", "wall_fragment", vec2(begin_x, 200));
+ Asset frag_1_asset{"asset/jetpack_joyride/background/start/StartWall_frag1.png"};
+ Sprite & frag_1_sprite
+ = frag_1.add_component<Sprite>(frag_1_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 5,
+ .size = vec2(0, 50),
+ });
+ frag_1_sprite.active = false;
+ Rigidbody & frag_1_rb = frag_1.add_component<Rigidbody>(Rigidbody::Data{
+ .gravity_scale = 10,
+ .linear_velocity = vec2(400, 400),
+ .linear_velocity_coefficient = vec2(0.5, 0.6),
+ .angular_velocity = 500,
+ .angular_velocity_coefficient = 0.55,
+ .elastisity_coefficient = 0.5,
+ });
+ frag_1_rb.active = false;
+ frag_1.add_component<CircleCollider>(25);
+
+ GameObject frag_2 = scn.new_object("frag_2", "wall_fragment", vec2(begin_x, 180));
+ Asset frag_2_asset{"asset/jetpack_joyride/background/start/StartWall_frag2.png"};
+ Sprite & frag_2_sprite
+ = frag_2.add_component<Sprite>(frag_2_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 5,
+ .size = vec2(0, 50),
+ });
+ frag_2_sprite.active = false;
+ Rigidbody & frag_2_rb = frag_2.add_component<Rigidbody>(Rigidbody::Data{
+ .gravity_scale = 20,
+ .linear_velocity = vec2(400, 400),
+ .linear_velocity_coefficient = vec2(0.35, 0.4),
+ .angular_velocity = 400,
+ .angular_velocity_coefficient = 0.55,
+ .elastisity_coefficient = 0.5,
+ });
+ frag_2_rb.active = false;
+ frag_2.add_component<CircleCollider>(55);
+
+ GameObject frag_3 = scn.new_object("frag_3", "wall_fragment", vec2(begin_x, 170));
+ Asset frag_3_asset{"asset/jetpack_joyride/background/start/StartWall_frag3.png"};
+ Sprite & frag_3_sprite
+ = frag_3.add_component<Sprite>(frag_3_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 5,
+ .size = vec2(0, 50),
+ });
+ frag_3_sprite.active = false;
+ Rigidbody & frag_3_rb = frag_3.add_component<Rigidbody>(Rigidbody::Data{
+ .gravity_scale = 30,
+ .linear_velocity = vec2(400, 400),
+ .linear_velocity_coefficient = vec2(0.3, 0.3),
+ .angular_velocity = 300,
+ .angular_velocity_coefficient = 0.55,
+ .elastisity_coefficient = 0.5,
+ });
+ frag_3_rb.active = false;
+ frag_3.add_component<CircleCollider>(35);
+
+ GameObject frag_4 = scn.new_object("frag_4", "wall_fragment", vec2(begin_x, 160));
+ Asset frag_4_asset{"asset/jetpack_joyride/background/start/StartWall_frag4.png"};
+ Sprite & frag_4_sprite
+ = frag_4.add_component<Sprite>(frag_4_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 5,
+ .size = vec2(0, 50),
+ });
+ frag_4_sprite.active = false;
+ Rigidbody & frag_4_rb = frag_4.add_component<Rigidbody>(Rigidbody::Data{
+ .gravity_scale = 40,
+ .linear_velocity = vec2(700, 400),
+ .linear_velocity_coefficient = vec2(0.2, 0.2),
+ .angular_velocity = 200,
+ .angular_velocity_coefficient = 0.55,
+ .elastisity_coefficient = 0.5,
+ });
+ frag_4_rb.active = false;
+ frag_4.add_component<CircleCollider>(60);
+
+ GameObject frag_5 = scn.new_object("frag_5", "wall_fragment", vec2(begin_x, 150));
+ Asset frag_5_asset{"asset/jetpack_joyride/background/start/StartWall_frag5.png"};
+ Sprite & frag_5_sprite
+ = frag_5.add_component<Sprite>(frag_5_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 5,
+ .size = vec2(0, 50),
+ });
+ frag_5_sprite.active = false;
+ Rigidbody & frag_5_rb = frag_5.add_component<Rigidbody>(Rigidbody::Data{
+ .gravity_scale = 50,
+ .linear_velocity = vec2(600, 800),
+ .linear_velocity_coefficient = vec2(0.25, 0.15),
+ .angular_velocity = 100,
+ .angular_velocity_coefficient = 0.55,
+ .elastisity_coefficient = 0.5,
+ });
+ frag_5_rb.active = false;
+ frag_5.add_component<CircleCollider>(5);
+
+ GameObject frag_6 = scn.new_object("frag_6", "wall_fragment", vec2(begin_x, 140));
+ Asset frag_6_asset{"asset/jetpack_joyride/background/start/StartWall_frag6.png"};
+ Sprite & frag_6_sprite
+ = frag_6.add_component<Sprite>(frag_6_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 5,
+ .size = vec2(0, 50),
+ });
+ frag_6_sprite.active = false;
+ Rigidbody & frag_6_rb = frag_6.add_component<Rigidbody>(Rigidbody::Data{
+ .gravity_scale = 30,
+ .linear_velocity = vec2(300, 800),
+ .linear_velocity_coefficient = vec2(0.35, 0.25),
+ .angular_velocity = 100,
+ .angular_velocity_coefficient = 0.55,
+ .elastisity_coefficient = 0.5,
+ });
+ frag_6_rb.active = false;
+ frag_6.add_component<CircleCollider>(30);
+
+ GameObject frag_7 = scn.new_object("frag_7", "wall_fragment", vec2(begin_x, 130));
+ Asset frag_7_asset{"asset/jetpack_joyride/background/start/StartWall_frag7.png"};
+ Sprite & frag_7_sprite
+ = frag_7.add_component<Sprite>(frag_7_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 5,
+ .size = vec2(0, 50),
+ });
+ frag_7_sprite.active = false;
+ Rigidbody & frag_7_rb = frag_7.add_component<Rigidbody>(Rigidbody::Data{
+ .gravity_scale = 20,
+ .linear_velocity = vec2(400, 500),
+ .linear_velocity_coefficient = vec2(0.45, 0.6),
+ .angular_velocity = 800,
+ .angular_velocity_coefficient = 0.55,
+ .elastisity_coefficient = 0.5,
+ });
+ frag_7_rb.active = false;
+ frag_7.add_component<CircleCollider>(45);
+
+ GameObject frag_8 = scn.new_object("frag_8", "wall_fragment", vec2(begin_x, 120));
+ Asset frag_8_asset{"asset/jetpack_joyride/background/start/StartWall_frag8.png"};
+ Sprite & frag_8_sprite
+ = frag_8.add_component<Sprite>(frag_8_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 5,
+ .size = vec2(0, 50),
+ });
+ frag_8_sprite.active = false;
+ Rigidbody & frag_8_rb = frag_8.add_component<Rigidbody>(Rigidbody::Data{
+ .gravity_scale = 30,
+ .linear_velocity = vec2(400, 400),
+ .linear_velocity_coefficient = vec2(0.5, 0.6),
+ .angular_velocity = 500,
+ .angular_velocity_coefficient = 0.55,
+ .elastisity_coefficient = 0.5,
+ });
+ frag_8_rb.active = false;
+ frag_8.add_component<CircleCollider>(25);
+
+ GameObject frag_9 = scn.new_object("frag_9", "wall_fragment", vec2(begin_x, 110));
+ Asset frag_9_asset{"asset/jetpack_joyride/background/start/StartWall_frag9.png"};
+ Sprite & frag_9_sprite
+ = frag_9.add_component<Sprite>(frag_9_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 5,
+ .size = vec2(0, 50),
+ });
+ frag_9_sprite.active = false;
+ Rigidbody & frag_9_rb = frag_9.add_component<Rigidbody>(Rigidbody::Data{
+ .gravity_scale = 40,
+ .linear_velocity = vec2(200, 400),
+ .linear_velocity_coefficient = vec2(0.5, 0.25),
+ .angular_velocity = 500,
+ .angular_velocity_coefficient = 0.55,
+ .elastisity_coefficient = 0.5,
+ });
+ frag_9_rb.active = false;
+ frag_9.add_component<CircleCollider>(15);
+
+ GameObject frag_10 = scn.new_object("frag_10", "wall_fragment", vec2(begin_x, 100));
+ Asset frag_10_asset{"asset/jetpack_joyride/background/start/StartWall_frag10.png"};
+ Sprite & frag_10_sprite
+ = frag_10.add_component<Sprite>(frag_10_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 5,
+ .size = vec2(0, 50),
+ });
+ frag_10_sprite.active = false;
+ Rigidbody & frag_10_rb = frag_10.add_component<Rigidbody>(Rigidbody::Data{
+ .gravity_scale = 50,
+ .linear_velocity = vec2(400, 900),
+ .linear_velocity_coefficient = vec2(0.35, 0.4),
+ .angular_velocity = 300,
+ .angular_velocity_coefficient = 0.55,
+ .elastisity_coefficient = 0.5,
+ });
+ frag_10_rb.active = false;
+ frag_10.add_component<CircleCollider>(60);
+
+ GameObject frag_11 = scn.new_object("frag_11", "wall_fragment", vec2(begin_x, 90));
+ Asset frag_11_asset{"asset/jetpack_joyride/background/start/StartWall_frag11.png"};
+ Sprite & frag_11_sprite
+ = frag_11.add_component<Sprite>(frag_11_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 5,
+ .size = vec2(0, 50),
+ });
+ frag_11_sprite.active = false;
+ Rigidbody & frag_11_rb = frag_11.add_component<Rigidbody>(Rigidbody::Data{
+ .gravity_scale = 60,
+ .linear_velocity = vec2(600, 800),
+ .linear_velocity_coefficient = vec2(0.3, 0.3),
+ .angular_velocity = 200,
+ .angular_velocity_coefficient = 0.55,
+ .elastisity_coefficient = 0.5,
+ });
+ frag_11_rb.active = false;
+ frag_11.add_component<CircleCollider>(5);
+
+ GameObject frag_12 = scn.new_object("frag_12", "wall_fragment", vec2(begin_x, 80));
+ Asset frag_12_asset{"asset/jetpack_joyride/background/start/StartWall_frag12.png"};
+ Sprite & frag_12_sprite
+ = frag_12.add_component<Sprite>(frag_12_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 5,
+ .size = vec2(0, 50),
+ });
+ frag_12_sprite.active = false;
+ Rigidbody & frag_12_rb = frag_12.add_component<Rigidbody>(Rigidbody::Data{
+ .gravity_scale = 70,
+ .linear_velocity = vec2(500, 800),
+ .linear_velocity_coefficient = vec2(0.25, 0.15),
+ .angular_velocity = 100,
+ .angular_velocity_coefficient = 0.55,
+ .elastisity_coefficient = 0.5,
+ });
+ frag_12_rb.active = false;
+ frag_12.add_component<CircleCollider>(50);
+}
diff --git a/src/example/Start.h b/src/example/Start.h
index 94a34bb..24e0dbf 100644
--- a/src/example/Start.h
+++ b/src/example/Start.h
@@ -16,4 +16,5 @@ private:
void add_table(crepe::GameObject & obj, crepe::vec2 offset);
void add_light(crepe::GameObject & obj, crepe::vec2 offset);
void add_jetpack_stand(crepe::GameObject & obj, crepe::vec2 offset);
+ void create_wall_fragments(crepe::Scene & scn, float begin_x);
};