aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/example/game.cpp172
1 files changed, 105 insertions, 67 deletions
diff --git a/src/example/game.cpp b/src/example/game.cpp
index dfa1e7e..f2532ee 100644
--- a/src/example/game.cpp
+++ b/src/example/game.cpp
@@ -23,139 +23,177 @@ using namespace std;
class Background {
public:
Background(ComponentManager & mgr) {
- GameObject start_begin = mgr.new_object("start_begin", "background", vec2(0, 0));
+ this->start(mgr);
+
+ this->hallway(mgr);
+
+ this->forest(mgr);
+
+ this->aquarium(mgr);
+
+ this->forest(mgr);
+ }
+
+ void start(ComponentManager & mgr) {
+ GameObject start_begin = mgr.new_object("start_begin", "background", vec2(begin_x, 0));
Asset start_begin_asset{"asset/jetpack_joyride/background/start/titleFG_1_TVOS.png"};
start_begin.add_component<Sprite>(start_begin_asset, Sprite::Data{
- .sorting_in_layer = 0,
- .order_in_layer = 1,
+ .sorting_in_layer = 4,
+ .order_in_layer = 0,
.size = vec2(0, 800),
});
+ begin_x += 700;
- GameObject start_end = mgr.new_object("start_end", "background", vec2(700, 0));
+ GameObject start_end = mgr.new_object("start_end", "background", vec2(begin_x, 0));
Asset start_end_asset{"asset/jetpack_joyride/background/start/titleFG_2_TVOS.png"};
start_end.add_component<Sprite>(start_end_asset, Sprite::Data{
- .sorting_in_layer = 0,
- .order_in_layer = 2,
+ .sorting_in_layer = 4,
+ .order_in_layer = 1,
.size = vec2(0, 800),
});
+ begin_x += 100;
+ }
- GameObject hallway_begin = mgr.new_object("hallway_begin", "background", vec2(800, 0));
+ void hallway(ComponentManager & mgr) {
+ GameObject hallway_begin
+ = mgr.new_object("hallway_begin", "background", vec2(begin_x, 0));
Asset hallway_begin_asset{
"asset/jetpack_joyride/background/hallway/hallway1FG_1_TVOS.png"};
hallway_begin.add_component<Sprite>(hallway_begin_asset, Sprite::Data{
- .sorting_in_layer = 0,
- .order_in_layer = 1,
+ .sorting_in_layer = 4,
+ .order_in_layer = 0,
.size = vec2(0, 800),
});
+ begin_x += 600;
- GameObject hallway_middle
- = mgr.new_object("hallway_middle", "background", vec2(1400, 0));
+ GameObject hallway_middle_1
+ = mgr.new_object("hallway_middle", "background", vec2(begin_x, 0));
Asset hallway_middle_asset{
"asset/jetpack_joyride/background/hallway/hallway1FG_2_TVOS.png"};
- hallway_middle.add_component<Sprite>(hallway_middle_asset, Sprite::Data{
- .sorting_in_layer = 0,
- .order_in_layer = 2,
- .size = vec2(0, 800),
- });
+ hallway_middle_1.add_component<Sprite>(hallway_middle_asset, Sprite::Data{
+ .sorting_in_layer = 4,
+ .order_in_layer = 2,
+ .size = vec2(0, 800),
+ });
+ begin_x += 600;
- GameObject hallway_end = mgr.new_object("hallway_end", "background", vec2(2000, 0));
+ GameObject hallway_middle_2
+ = mgr.new_object("hallway_middle", "background", vec2(begin_x, 0));
+ Asset hallway_middle_asset_2{
+ "asset/jetpack_joyride/background/hallway/hallway1FG_2_TVOS.png"};
+ hallway_middle_2.add_component<Sprite>(hallway_middle_asset_2,
+ Sprite::Data{
+ .sorting_in_layer = 4,
+ .order_in_layer = 3,
+ .size = vec2(0, 800),
+ });
+ begin_x += 200;
+
+ GameObject hallway_middle_3
+ = mgr.new_object("hallway_middle", "background", vec2(begin_x, 0));
+ Asset hallway_middle_asset_3{
+ "asset/jetpack_joyride/background/hallway/hallway1FG_2_TVOS.png"};
+ hallway_middle_3.add_component<Sprite>(hallway_middle_asset_3,
+ Sprite::Data{
+ .sorting_in_layer = 4,
+ .order_in_layer = 4,
+ .size = vec2(0, 800),
+ });
+ begin_x += 400;
+
+ GameObject hallway_middle_4
+ = mgr.new_object("hallway_middle", "background", vec2(begin_x, 0));
+ Asset hallway_middle_asset_4{
+ "asset/jetpack_joyride/background/hallway/hallway1FG_2_TVOS.png"};
+ hallway_middle_4.add_component<Sprite>(hallway_middle_asset_4,
+ Sprite::Data{
+ .sorting_in_layer = 4,
+ .order_in_layer = 5,
+ .size = vec2(0, 800),
+ });
+ begin_x += 600;
+
+ GameObject hallway_end = mgr.new_object("hallway_end", "background", vec2(begin_x, 0));
Asset hallway_end_asset{
"asset/jetpack_joyride/background/hallway/hallway1FG_1_TVOS.png"};
hallway_end.add_component<Sprite>(hallway_end_asset, Sprite::Data{
- .sorting_in_layer = 0,
+ .sorting_in_layer = 4,
.order_in_layer = 1,
.size = vec2(0, 800),
});
+ begin_x += 600;
+ }
- GameObject forest_begin = mgr.new_object("forest_begin", "background", vec2(2600, 0));
+ void forest(ComponentManager & mgr) {
+ GameObject forest_begin
+ = mgr.new_object("forest_begin", "background", vec2(begin_x, 0));
Asset forest_begin_asset{
"asset/jetpack_joyride/background/forest/forestFG_1_TVOS.png"};
forest_begin.add_component<Sprite>(forest_begin_asset, Sprite::Data{
- .sorting_in_layer = 0,
- .order_in_layer = 2,
+ .sorting_in_layer = 4,
+ .order_in_layer = 0,
.size = vec2(0, 800),
});
+ begin_x += 800;
GameObject forest_middle
- = mgr.new_object("forest_middle", "background", vec2(3400, 0));
+ = mgr.new_object("forest_middle", "background", vec2(begin_x, 0));
Asset forest_middle_asset{
"asset/jetpack_joyride/background/forest/forestFG_3_TVOS.png"};
forest_middle.add_component<Sprite>(forest_middle_asset, Sprite::Data{
- .sorting_in_layer = 0,
+ .sorting_in_layer = 4,
.order_in_layer = 2,
.size = vec2(0, 800),
});
+ begin_x += 800;
- GameObject forest_end = mgr.new_object("forest_end", "background", vec2(4200, 0));
+ GameObject forest_end = mgr.new_object("forest_end", "background", vec2(begin_x, 0));
Asset forest_end_asset{"asset/jetpack_joyride/background/forest/forestFG_2_TVOS.png"};
forest_end.add_component<Sprite>(forest_end_asset, Sprite::Data{
- .sorting_in_layer = 0,
- .order_in_layer = 2,
+ .sorting_in_layer = 4,
+ .order_in_layer = 1,
.size = vec2(0, 800),
});
+ begin_x += 600;
+ }
- GameObject forest_background_1
- = mgr.new_object("forest_background", "background", vec2(2600, 0));
- Asset forest_background_1_asset{
- "asset/jetpack_joyride/background/forest/forestBG1_1_TVOS.png"};
- forest_background_1.add_component<Sprite>(forest_background_1_asset,
- Sprite::Data{
- .sorting_in_layer = 0,
- .order_in_layer = 0,
- .size = vec2(0, 800),
- });
-
- GameObject forest_background_2
- = mgr.new_object("forest_background", "background", vec2(3400, 0));
- Asset forest_background_2_asset{
- "asset/jetpack_joyride/background/forest/forestBG1_1_TVOS.png"};
- forest_background_2.add_component<Sprite>(forest_background_2_asset,
- Sprite::Data{
- .sorting_in_layer = 0,
- .order_in_layer = 0,
- .size = vec2(0, 800),
- });
-
- GameObject forest_background_3
- = mgr.new_object("forest_background", "background", vec2(4200, 0));
- Asset forest_background_3_asset{
- "asset/jetpack_joyride/background/forest/forestBG1_1_TVOS.png"};
- forest_background_3.add_component<Sprite>(forest_background_3_asset,
- Sprite::Data{
- .sorting_in_layer = 0,
- .order_in_layer = 0,
- .size = vec2(0, 800),
- });
-
+ void aquarium(ComponentManager & mgr) {
GameObject aquarium_begin
- = mgr.new_object("aquarium_begin", "background", vec2(4800, 0));
+ = mgr.new_object("aquarium_begin", "background", vec2(begin_x, 0));
Asset aquarium_begin_asset{
"asset/jetpack_joyride/background/aquarium/glassTubeFG_1_TVOS.png"};
aquarium_begin.add_component<Sprite>(aquarium_begin_asset, Sprite::Data{
- .sorting_in_layer = 0,
- .order_in_layer = 1,
+ .sorting_in_layer = 4,
+ .order_in_layer = 0,
.size = vec2(0, 800),
});
+ begin_x += 600;
GameObject aquarium_middle
- = mgr.new_object("aquarium_middle", "background", vec2(5400, 0));
+ = mgr.new_object("aquarium_middle", "background", vec2(begin_x, 0));
Asset aquarium_middle_asset{
"asset/jetpack_joyride/background/aquarium/glassTubeFG_3_TVOS.png"};
aquarium_middle.add_component<Sprite>(aquarium_middle_asset, Sprite::Data{
- .sorting_in_layer = 0,
- .order_in_layer = 1,
+ .sorting_in_layer = 4,
+ .order_in_layer = 2,
.size = vec2(0, 800),
});
+ begin_x += 600;
- GameObject aquarium_end = mgr.new_object("aquarium_end", "background", vec2(6000, 0));
+ GameObject aquarium_end
+ = mgr.new_object("aquarium_end", "background", vec2(begin_x, 0));
Asset aquarium_end_asset{
"asset/jetpack_joyride/background/aquarium/glassTubeFG_2_TVOS.png"};
aquarium_end.add_component<Sprite>(aquarium_end_asset, Sprite::Data{
- .sorting_in_layer = 0,
+ .sorting_in_layer = 4,
.order_in_layer = 1,
.size = vec2(0, 800),
});
+ begin_x += 600;
}
+
+private:
+ float begin_x = 0;
};
class MoveCameraScript : public Script {