diff options
Diffstat (limited to 'src/example')
| -rw-r--r-- | src/example/ecs.cpp | 12 | ||||
| -rw-r--r-- | src/example/particle.cpp | 4 | ||||
| -rw-r--r-- | src/example/physics.cpp | 23 | ||||
| -rw-r--r-- | src/example/rendering.cpp | 8 | ||||
| -rw-r--r-- | src/example/scene_manager.cpp | 16 | ||||
| -rw-r--r-- | src/example/script.cpp | 2 | 
6 files changed, 31 insertions, 34 deletions
| diff --git a/src/example/ecs.cpp b/src/example/ecs.cpp index 0c64373..e61c398 100644 --- a/src/example/ecs.cpp +++ b/src/example/ecs.cpp @@ -11,11 +11,11 @@ using namespace std;  int main() {  	// Create a few GameObjects  	try { -		GameObject body(0, "body", "person", Point{0, 0}, 0, 1); -		GameObject right_leg(1, "rightLeg", "person", Point{1, 1}, 0, 1); -		GameObject left_leg(2, "leftLeg", "person", Point{1, 1}, 0, 1); -		GameObject right_foot(3, "rightFoot", "person", Point{2, 2}, 0, 1); -		GameObject left_foot(4, "leftFoot", "person", Point{2, 2}, 0, 1); +		GameObject body(0, "body", "person", Vector2{0, 0}, 0, 1); +		GameObject right_leg(1, "rightLeg", "person", Vector2{1, 1}, 0, 1); +		GameObject left_leg(2, "leftLeg", "person", Vector2{1, 1}, 0, 1); +		GameObject right_foot(3, "rightFoot", "person", Vector2{2, 2}, 0, 1); +		GameObject left_foot(4, "leftFoot", "person", Vector2{2, 2}, 0, 1);  		// Set the parent of each GameObject  		right_foot.set_parent(right_leg); @@ -24,7 +24,7 @@ int main() {  		left_leg.set_parent(body);  		// Adding a second Transform component is not allowed and will invoke an exception -		body.add_component<Transform>(Point{10, 10}, 0, 1); +		body.add_component<Transform>(Vector2{10, 10}, 0, 1);  	} catch (const exception & e) {  		cerr << e.what() << endl;  	} diff --git a/src/example/particle.cpp b/src/example/particle.cpp index 607530d..0ab5632 100644 --- a/src/example/particle.cpp +++ b/src/example/particle.cpp @@ -7,7 +7,7 @@  #include <crepe/Particle.h>  #include <crepe/api/GameObject.h>  #include <crepe/api/ParticleEmitter.h> -#include <crepe/api/Point.h> +#include <crepe/api/Vector2.h>  #include <crepe/facade/SDLApp.h>  #include <crepe/system/ParticleSystem.h> @@ -26,7 +26,7 @@ int main(int argc, char * argv[]) {  	}  	GameObject * game_object[1]; -	game_object[0] = new GameObject(0, "Name", "Tag", Point{0, 0}, 0, 1); +	game_object[0] = new GameObject(0, "Name", "Tag", Vector2{0, 0}, 0, 1);  	// FIXME: all systems are singletons, so this shouldn't even compile.  	ParticleSystem particle_system; diff --git a/src/example/physics.cpp b/src/example/physics.cpp index c7db6ac..fd15c79 100644 --- a/src/example/physics.cpp +++ b/src/example/physics.cpp @@ -1,10 +1,5 @@ -#include <chrono> -#include <iostream> -#include <thread> -  #include <crepe/Component.h>  #include <crepe/ComponentManager.h> -#include <crepe/api/Force.h>  #include <crepe/api/GameObject.h>  #include <crepe/api/Rigidbody.h>  #include <crepe/api/Transform.h> @@ -14,13 +9,15 @@ using namespace crepe;  using namespace std;  int main(int argc, char * argv[]) { -	PhysicsSystem physics_system; -	GameObject * game_object[2]; -	// not found not used -	game_object[1] = new GameObject(2, "Name", "Tag", Point{0, 0}, 0, 0); -	game_object[0] = new GameObject(5, "Name", "Tag", Point{0, 0}, 0, 0); -	game_object[0]->add_component<Rigidbody>(1, 1, BodyType::DYNAMIC); -	game_object[0]->add_component<Force>(1, 0); -	physics_system.update(); +	GameObject *game_object; +	game_object = new GameObject(0, "Name", "Tag", Vector2{0,0},0,0); +	game_object->add_component<Rigidbody>(Rigidbody::RigidbodyData{ +		.mass = 1, +		.gravity_scale = 1, +		.body_type = Rigidbody::BodyType::DYNAMIC, +		.constraints = {0,0,0}, +		.use_gravity = true, +		.bounce = false, +		});  	return 0;  } diff --git a/src/example/rendering.cpp b/src/example/rendering.cpp index 3fe43d6..e1ff9da 100644 --- a/src/example/rendering.cpp +++ b/src/example/rendering.cpp @@ -5,7 +5,7 @@  #include <crepe/api/AssetManager.h>  #include <crepe/api/Color.h> -#include <crepe/api/Point.h> +#include <crepe/api/Vector2.h>  #include <crepe/api/Sprite.h>  #include <crepe/api/Texture.h>  #include <crepe/api/Transform.h> @@ -19,9 +19,9 @@ using namespace crepe;  int main() {  	dbg_trace(); -	auto obj = GameObject(0, "name", "tag", Point{0, 0}, 1, 1); -	auto obj1 = GameObject(1, "name", "tag", Point{500, 0}, 1, 0.1); -	auto obj2 = GameObject(2, "name", "tag", Point{800, 0}, 1, 0.1); +	auto obj = GameObject(0, "name", "tag", Vector2{0, 0}, 1, 1); +	auto obj1 = GameObject(1, "name", "tag", Vector2{500, 0}, 1, 0.1); +	auto obj2 = GameObject(2, "name", "tag", Vector2{800, 0}, 1, 0.1);  	auto & mgr = AssetManager::get_instance();  	// Normal adding components diff --git a/src/example/scene_manager.cpp b/src/example/scene_manager.cpp index efbf2c2..1780c81 100644 --- a/src/example/scene_manager.cpp +++ b/src/example/scene_manager.cpp @@ -3,7 +3,7 @@  #include <crepe/ComponentManager.h>  #include <crepe/api/GameObject.h>  #include <crepe/api/Metadata.h> -#include <crepe/api/Point.h> +#include <crepe/api/Vector2.h>  #include <crepe/api/Scene.h>  #include <crepe/api/SceneManager.h> @@ -15,9 +15,9 @@ public:  	ConcreteScene1(string name) : Scene(name) {}  	void load_scene() { -		GameObject object1(0, "scene_1", "tag_scene_1", Point{0, 0}, 0, 1); -		GameObject object2(1, "scene_1", "tag_scene_1", Point{1, 0}, 0, 1); -		GameObject object3(2, "scene_1", "tag_scene_1", Point{2, 0}, 0, 1); +		GameObject object1(0, "scene_1", "tag_scene_1", Vector2{0, 0}, 0, 1); +		GameObject object2(1, "scene_1", "tag_scene_1", Vector2{1, 0}, 0, 1); +		GameObject object3(2, "scene_1", "tag_scene_1", Vector2{2, 0}, 0, 1);  	}  }; @@ -26,10 +26,10 @@ public:  	ConcreteScene2(string name) : Scene(name) {}  	void load_scene() { -		GameObject object1(0, "scene_2", "tag_scene_2", Point{0, 0}, 0, 1); -		GameObject object2(1, "scene_2", "tag_scene_2", Point{0, 1}, 0, 1); -		GameObject object3(2, "scene_2", "tag_scene_2", Point{0, 2}, 0, 1); -		GameObject object4(3, "scene_2", "tag_scene_2", Point{0, 3}, 0, 1); +		GameObject object1(0, "scene_2", "tag_scene_2", Vector2{0, 0}, 0, 1); +		GameObject object2(1, "scene_2", "tag_scene_2", Vector2{0, 1}, 0, 1); +		GameObject object3(2, "scene_2", "tag_scene_2", Vector2{0, 2}, 0, 1); +		GameObject object4(3, "scene_2", "tag_scene_2", Vector2{0, 3}, 0, 1);  	}  }; diff --git a/src/example/script.cpp b/src/example/script.cpp index 8ca4ceb..9e8b147 100644 --- a/src/example/script.cpp +++ b/src/example/script.cpp @@ -36,7 +36,7 @@ class MyScript : public Script {  int main() {  	// Create game object with Transform and BehaviorScript components -	auto obj = GameObject(0, "name", "tag", Point{1.2, 3.4}, 0, 1); +	auto obj = GameObject(0, "name", "tag", Vector2{1.2, 3.4}, 0, 1);  	obj.add_component<BehaviorScript>().set_script<MyScript>();  	// Get ScriptSystem singleton instance (this would normally be done from the |