aboutsummaryrefslogtreecommitdiff
path: root/src/example
diff options
context:
space:
mode:
Diffstat (limited to 'src/example')
-rw-r--r--src/example/asset_manager.cpp13
-rw-r--r--src/example/audio_internal.cpp3
-rw-r--r--src/example/components_internal.cpp8
-rw-r--r--src/example/ecs.cpp13
-rw-r--r--src/example/particles.cpp3
-rw-r--r--src/example/rendering.cpp10
-rw-r--r--src/example/scene_manager.cpp4
7 files changed, 21 insertions, 33 deletions
diff --git a/src/example/asset_manager.cpp b/src/example/asset_manager.cpp
index cf64f89..917b547 100644
--- a/src/example/asset_manager.cpp
+++ b/src/example/asset_manager.cpp
@@ -6,18 +6,17 @@ using namespace crepe;
int main() {
- // this needs to be called before the asset manager otherwise the destructor
- // of sdl is not in the right order
+ // this needs to be called before the asset manager otherwise the destructor of sdl is not in
+ // the right order
{ Texture test("../asset/texture/img.png"); }
- // FIXME: make it so the issue described by the above comment is not possible
- // (i.e. the order in which internal classes are instantiated should not
- // impact the way the engine works).
+ // FIXME: make it so the issue described by the above comment is not possible (i.e. the order
+ // in which internal classes are instantiated should not impact the way the engine works).
auto & mgr = AssetManager::get_instance();
{
- // TODO: [design] the Sound class can't be directly included by the user as
- // it includes SoLoud headers.
+ // TODO: [design] the Sound class can't be directly included by the user as it includes
+ // SoLoud headers.
auto bgm = mgr.cache<Sound>("../mwe/audio/bgm.ogg");
auto sfx1 = mgr.cache<Sound>("../mwe/audio/sfx1.wav");
auto sfx2 = mgr.cache<Sound>("../mwe/audio/sfx2.wav");
diff --git a/src/example/audio_internal.cpp b/src/example/audio_internal.cpp
index ff55a59..661161a 100644
--- a/src/example/audio_internal.cpp
+++ b/src/example/audio_internal.cpp
@@ -34,8 +34,7 @@ int main() {
// Start the background track
bgm.play();
- // Play each sample sequentially while pausing and resuming the background
- // track
+ // Play each sample sequentially while pausing and resuming the background track
this_thread::sleep_for(500ms);
sfx1.play();
this_thread::sleep_for(500ms);
diff --git a/src/example/components_internal.cpp b/src/example/components_internal.cpp
index eeecdc0..2a232a9 100644
--- a/src/example/components_internal.cpp
+++ b/src/example/components_internal.cpp
@@ -27,8 +27,6 @@ int main() {
auto start_adding = chrono::high_resolution_clock::now();
- GameObject * game_object[OBJ_COUNT];
-
for (int i = 0; i < OBJ_COUNT; ++i) {
GameObject obj = mgr.new_object("Name", "Tag");
obj.add_component<Sprite>("test");
@@ -44,10 +42,8 @@ int main() {
auto stop_looping = chrono::high_resolution_clock::now();
- auto add_time = chrono::duration_cast<chrono::microseconds>(stop_adding
- - start_adding);
- auto loop_time = chrono::duration_cast<chrono::microseconds>(stop_looping
- - stop_adding);
+ auto add_time = chrono::duration_cast<chrono::microseconds>(stop_adding - start_adding);
+ auto loop_time = chrono::duration_cast<chrono::microseconds>(stop_looping - stop_adding);
printf("add time: %ldus\n", add_time.count());
printf("loop time: %ldus\n", loop_time.count());
diff --git a/src/example/ecs.cpp b/src/example/ecs.cpp
index 5f83da1..711bde6 100644
--- a/src/example/ecs.cpp
+++ b/src/example/ecs.cpp
@@ -36,24 +36,21 @@ int main() {
}
// Get the Metadata and Transform components of each GameObject
- vector<reference_wrapper<Metadata>> metadata
- = mgr.get_components_by_type<Metadata>();
- vector<reference_wrapper<Transform>> transform
- = mgr.get_components_by_type<Transform>();
+ vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_type<Metadata>();
+ vector<reference_wrapper<Transform>> transform = mgr.get_components_by_type<Transform>();
// Print the Metadata and Transform components
for (auto & m : metadata) {
cout << "Id: " << m.get().game_object_id << " Name: " << m.get().name
- << " Tag: " << m.get().tag << " Parent: " << m.get().parent
- << " Children: ";
+ << " Tag: " << m.get().tag << " Parent: " << m.get().parent << " Children: ";
for (auto & c : m.get().children) {
cout << c << " ";
}
cout << endl;
}
for (auto & t : transform) {
- cout << "Id: " << t.get().game_object_id << " Position: ["
- << t.get().position.x << ", " << t.get().position.y << "]" << endl;
+ cout << "Id: " << t.get().game_object_id << " Position: [" << t.get().position.x
+ << ", " << t.get().position.y << "]" << endl;
}
return 0;
diff --git a/src/example/particles.cpp b/src/example/particles.cpp
index 35faab0..3d5f676 100644
--- a/src/example/particles.cpp
+++ b/src/example/particles.cpp
@@ -18,8 +18,7 @@ int main(int argc, char * argv[]) {
GameObject game_object = mgr.new_object("", "", Vector2{0, 0}, 0, 0);
Color color(0, 0, 0, 0);
Sprite test_sprite = game_object.add_component<Sprite>(
- make_shared<Texture>("../asset/texture/img.png"), color,
- FlipSettings{true, true});
+ make_shared<Texture>("../asset/texture/img.png"), color, FlipSettings{true, true});
game_object.add_component<ParticleEmitter>(ParticleEmitter::Data{
.position = {0, 0},
.max_particles = 100,
diff --git a/src/example/rendering.cpp b/src/example/rendering.cpp
index abd11b1..c9e62f1 100644
--- a/src/example/rendering.cpp
+++ b/src/example/rendering.cpp
@@ -30,16 +30,14 @@ int main() {
// Normal adding components
{
Color color(0, 0, 0, 0);
- obj.add_component<Sprite>(
- make_shared<Texture>("../asset/texture/img.png"), color,
- FlipSettings{false, false});
+ obj.add_component<Sprite>(make_shared<Texture>("../asset/texture/img.png"), color,
+ FlipSettings{false, false});
obj.add_component<Camera>(Color::get_red());
}
{
Color color(0, 0, 0, 0);
- obj1.add_component<Sprite>(
- make_shared<Texture>("../asset/texture/second.png"), color,
- FlipSettings{true, true});
+ obj1.add_component<Sprite>(make_shared<Texture>("../asset/texture/second.png"), color,
+ FlipSettings{true, true});
}
/*
diff --git a/src/example/scene_manager.cpp b/src/example/scene_manager.cpp
index 24ab72e..62720eb 100644
--- a/src/example/scene_manager.cpp
+++ b/src/example/scene_manager.cpp
@@ -50,8 +50,8 @@ int main() {
scene_mgr.add_scene<ConcreteScene1>("scene1");
scene_mgr.add_scene<ConcreteScene2>("scene2");
- // There is no need to call set_next_scene() at the beginning because the
- // first scene will be automatically set as the next scene
+ // There is no need to call set_next_scene() at the beginnen, because the first scene will be
+ // automatically set as the next scene
// Load scene1 (the first scene added)
scene_mgr.load_next_scene();