1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#include "api/CircleCollider.h"
#include "api/Scene.h"
#include "manager/ComponentManager.h"
#include "manager/Mediator.h"
#include "types.h"
#include <crepe/api/Asset.h>
#include <crepe/api/BoxCollider.h>
#include <crepe/api/Camera.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/Script.h>
#include <crepe/api/Sprite.h>
#include <crepe/api/Transform.h>
#include <crepe/api/Vector2.h>
using namespace crepe;
using namespace std;
class Scene1 : public Scene {
public:
void load_scene() {
Mediator & m = this->mediator;
ComponentManager & mgr = m.component_manager;
GameObject start_begin = mgr.new_object("start_begin", "background", vec2(0, 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,
.size = vec2(0, 800),
});
GameObject start_end = mgr.new_object("start_end", "background", vec2(700, 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,
.size = vec2(0, 800),
});
GameObject hallway_begin = mgr.new_object("hallway_begin", "background", vec2(800, 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,
.size = vec2(0, 800),
});
GameObject hallway_middle
= mgr.new_object("hallway_middle", "background", vec2(1400, 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),
});
GameObject hallway_end = mgr.new_object("hallway_end", "background", vec2(2000, 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,
.order_in_layer = 1,
.size = vec2(0, 800),
});
GameObject forest_begin = mgr.new_object("forest_begin", "background", vec2(2600, 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,
.size = vec2(0, 800),
});
GameObject forest_middle
= mgr.new_object("forest_middle", "background", vec2(3400, 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,
.order_in_layer = 2,
.size = vec2(0, 800),
});
GameObject forest_end = mgr.new_object("forest_end", "background", vec2(4200, 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,
.size = vec2(0, 800),
});
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),
});
GameObject camera = mgr.new_object("camera", "camera", vec2(600, 0));
camera.add_component<Camera>(ivec2(1700, 720), vec2(2000, 800),
Camera::Data{
.bg_color = Color::RED,
});
camera.add_component<Rigidbody>(Rigidbody::Data{
.linear_velocity = vec2(1.5, 0),
});
}
string get_name() const { return "scene1"; }
};
int main(int argc, char * argv[]) {
LoopManager gameloop;
gameloop.add_scene<Scene1>();
gameloop.start();
return 0;
}
|