aboutsummaryrefslogtreecommitdiff
path: root/src/example/Start.cpp
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-12-17 08:53:03 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-12-17 08:53:03 +0100
commit72f04cc18113785b8f57d95254d28e7d64d584aa (patch)
tree47b08f2f781d05679f76406df4838bf8697f7dc2 /src/example/Start.cpp
parent00f3ee853d94b607646e311d6bc9aca1736ab259 (diff)
Placed every class into seperate file
Diffstat (limited to 'src/example/Start.cpp')
-rw-r--r--src/example/Start.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/example/Start.cpp b/src/example/Start.cpp
new file mode 100644
index 0000000..a8d86ec
--- /dev/null
+++ b/src/example/Start.cpp
@@ -0,0 +1,69 @@
+#include "Start.h"
+
+#include <crepe/api/Animator.h>
+#include <crepe/api/Asset.h>
+#include <crepe/api/BehaviorScript.h>
+#include <crepe/api/BoxCollider.h>
+#include <crepe/api/Camera.h>
+#include <crepe/api/CircleCollider.h>
+#include <crepe/api/Color.h>
+#include <crepe/api/Event.h>
+#include <crepe/api/GameObject.h>
+#include <crepe/api/LoopManager.h>
+#include <crepe/api/Rigidbody.h>
+#include <crepe/api/Scene.h>
+#include <crepe/api/Script.h>
+#include <crepe/api/Sprite.h>
+#include <crepe/api/Transform.h>
+#include <crepe/api/Vector2.h>
+#include <iostream>
+
+using namespace crepe;
+using namespace std;
+
+float Start::create(Scene & scn, float begin_x) {
+ 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{
+ .sorting_in_layer = 4,
+ .order_in_layer = 0,
+ .size = vec2(0, 800),
+ });
+ begin_x += 700;
+
+ GameObject end = scn.new_object("start_end", "background", vec2(begin_x, 0));
+ Asset end_asset{"asset/jetpack_joyride/background/start/titleFG_2_TVOS.png"};
+ end.add_component<Sprite>(end_asset, Sprite::Data{
+ .sorting_in_layer = 4,
+ .order_in_layer = 1,
+ .size = vec2(0, 800),
+ });
+ begin_x += 100;
+
+ this->add_lamp(end, vec2(-350, -95));
+
+ return begin_x;
+}
+
+void Start::add_lamp(GameObject & obj, vec2 offset, unsigned int fps) {
+ Asset lamp_asset{"asset/jetpack_joyride/background/start/alarmLight_TVOS.png"};
+ obj.add_component<Sprite>(lamp_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 0,
+ .size = vec2(0, 100),
+ .position_offset = offset,
+ });
+ Asset lamp_glow_asset{"asset/jetpack_joyride/background/start/alarmGlow_TVOS.png"};
+ Sprite & lamp_glow_sprite = obj.add_component<Sprite>(
+ lamp_glow_asset, Sprite::Data{
+ .sorting_in_layer = 5,
+ .order_in_layer = 1,
+ .size = vec2(0, 300),
+ .position_offset = offset - vec2(65, -55),
+ });
+ obj.add_component<Animator>(lamp_glow_sprite, ivec2(422, 384), uvec2(6, 1),
+ Animator::Data{
+ .fps = fps,
+ .looping = true,
+ });
+}