diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-12-12 14:49:58 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-12-12 14:49:58 +0100 |
commit | 4c64dbc5c4ac44ef7dfe8a950ee67f96e6f99991 (patch) | |
tree | cc646733d78e4adf4fea2bf0ef3153409789982d /src | |
parent | 91aa03ded258c13cf3bc31640778df61e233906d (diff) |
fixed game
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/api/Config.h | 2 | ||||
-rw-r--r-- | src/example/game.cpp | 44 |
2 files changed, 24 insertions, 22 deletions
diff --git a/src/crepe/api/Config.h b/src/crepe/api/Config.h index cd27343..ca2d3f1 100644 --- a/src/crepe/api/Config.h +++ b/src/crepe/api/Config.h @@ -53,7 +53,7 @@ struct Config final { * * Gravity value of game. */ - float gravity = 1; + float gravity = 10; } physics; //! default window settings diff --git a/src/example/game.cpp b/src/example/game.cpp index 4239c15..5c8d749 100644 --- a/src/example/game.cpp +++ b/src/example/game.cpp @@ -2,6 +2,7 @@ #include "api/Scene.h" #include "manager/ComponentManager.h" #include "manager/Mediator.h" +#include "types.h" #include <crepe/api/BoxCollider.h> #include <crepe/api/Camera.h> #include <crepe/api/Color.h> @@ -11,7 +12,6 @@ #include <crepe/api/Rigidbody.h> #include <crepe/api/Script.h> #include <crepe/api/Sprite.h> -#include <crepe/api/Texture.h> #include <crepe/api/Transform.h> #include <crepe/api/Vector2.h> @@ -183,16 +183,16 @@ public: vec2{world_collider, world_collider}); // Left world.add_component<BoxCollider>(vec2{screen_size_width / 2 + world_collider / 2, 0}, vec2{world_collider, world_collider}); // right - world.add_component<Camera>( - Color::WHITE, - ivec2{static_cast<int>(screen_size_width), static_cast<int>(screen_size_height)}, - vec2{screen_size_width, screen_size_height}, 1.0f); + world.add_component<Camera>(ivec2{static_cast<int>(screen_size_width),static_cast<int>(screen_size_height)},vec2{screen_size_width,screen_size_height},Camera::Data{ + .bg_color = Color::WHITE, + .zoom = 1, + }); GameObject game_object1 = mgr.new_object( "Name", "Tag", vec2{screen_size_width / 2, screen_size_height / 2}, 0, 1); game_object1.add_component<Rigidbody>(Rigidbody::Data{ .mass = 1, - .gravity_scale = 0, + .gravity_scale = 1, .body_type = Rigidbody::BodyType::DYNAMIC, .linear_velocity = {0, 0}, .constraints = {0, 0, 0}, @@ -203,17 +203,19 @@ public: // add box with boxcollider game_object1.add_component<BoxCollider>(vec2{0, 0}, vec2{20, 20}); game_object1.add_component<BehaviorScript>().set_script<MyScript1>(); - auto img1 = Texture("asset/texture/square.png"); - game_object1.add_component<Sprite>(img1, color, Sprite::FlipSettings{false, false}, 1, - 1, 20); + + Asset img1{"asset/texture/square.png"}; + game_object1.add_component<Sprite>(img1,Sprite::Data{ + .size = {20,20}, + }); //add circle with cirlcecollider deactiveated game_object1.add_component<CircleCollider>(vec2{0, 0}, 10).active = false; - auto img2 = Texture("asset/texture/circle.png"); + Asset img2{"asset/texture/circle.png"}; game_object1 - .add_component<Sprite>(img2, color, Sprite::FlipSettings{false, false}, 1, 1, 20) - .active - = false; + .add_component<Sprite>(img2,Sprite::Data{ + .size = {20,20}, + }).active = false; GameObject game_object2 = mgr.new_object( "Name", "Tag", vec2{screen_size_width / 2, screen_size_height / 2}, 0, 1); @@ -230,17 +232,17 @@ public: // add box with boxcollider game_object2.add_component<BoxCollider>(vec2{0, 0}, vec2{20, 20}); game_object2.add_component<BehaviorScript>().set_script<MyScript2>(); - auto img3 = Texture("asset/texture/square.png"); - game_object2.add_component<Sprite>(img3, color, Sprite::FlipSettings{false, false}, 1, - 1, 20); + + game_object2.add_component<Sprite>(img1,Sprite::Data{ + .size = {20,20}, + }); //add circle with cirlcecollider deactiveated game_object2.add_component<CircleCollider>(vec2{0, 0}, 10).active = false; - auto img4 = Texture("asset/texture/circle.png"); - game_object2 - .add_component<Sprite>(img4, color, Sprite::FlipSettings{false, false}, 1, 1, 20) - .active - = false; + + game_object2.add_component<Sprite>(img2,Sprite::Data{ + .size = {20,20}, + }).active = false; } string get_name() const { return "scene1"; } |