#include <msp/game/entity.h>
#include <msp/game/meshsource.h>
#include "hittable.h"
-
-struct AsteroidSetup
-{
- PhysicalSetup physical;
- HittableSetup hittable;
- Msp::Game::MeshSourceSetup mesh;
-};
+#include "setups.h"
class Asteroid: public Hittable
{
#include <msp/game/meshsource.h>
#include "hittable.h"
-
-struct BulletSetup
-{
- PhysicalSetup physical;
- HittableSetup hittable;
- Msp::Game::MeshSourceSetup mesh;
-};
+#include "setups.h"
class Bullet: public Hittable
{
#include <msp/game/component.h>
#include <msp/linal/vector.h>
-
-enum class ColliderType
-{
- CIRCLE,
- BOX
-};
-
-struct ColliderSetup
-{
- ColliderType type = ColliderType::CIRCLE;
- union
- {
- float radius = 1.0f;
- Msp::LinAl::Vector<float, 2> size;
- };
-};
-
+#include "setups.h"
class Collider: public Msp::Game::Component
{
#define DAMAGESOURCE_H_
#include <msp/game/component.h>
-
-struct DamageSourceSetup
-{
- unsigned amount = 1;
- unsigned type = 0;
-};
+#include "setups.h"
class DamageSource: public Msp::Game::Component
{
#define HITPOINTS_H_
#include <msp/game/component.h>
-
-struct HitPointsSetup
-{
- /*class Loader: public Msp::DataFile::ObjectLoader<HitPointsSetup>
- {
- };*/
-
- unsigned max_hits = 1;
- unsigned vulnerable_to = ~0U;
-};
+#include "setups.h"
struct HitPointsData
{
#include "damagesource.h"
#include "hitpoints.h"
#include "physicalentity.h"
-
-struct HittableSetup
-{
- bool immortal = false;
- bool damaging = false;
- HitPointsSetup hits;
- DamageSourceSetup damage;
-};
+#include "setups.h"
class Hittable: public PhysicalEntity
{
#include <msp/game/entity.h>
#include <msp/game/transform.h>
-#include "rigidbody.h"
#include "collider.h"
-
-struct PhysicalSetup
-{
- bool fixture = false;
- RigidBodySetup body;
- ColliderSetup collider;
-};
+#include "rigidbody.h"
+#include "setups.h"
class PhysicalEntity: public Msp::Game::Entity
{
#include <msp/game/entity.h>
#include "physicalentity.h"
-
-struct PlayfieldSetup
-{
- Msp::LinAl::Vector<float, 2> size;
-};
+#include "setups.h"
class Playfield: public Msp::Game::Entity
{
#include <msp/game/component.h>
#include <msp/geometry/angle.h>
#include <msp/linal/vector.h>
-
-struct RigidBodySetup
-{
- float mass = 1.0f;
- float moment_of_inertia = 0.5f;
-};
+#include "setups.h"
struct RigidBodyData
{
--- /dev/null
+import "msp/game/setups";
+
+enum ColliderType
+{
+ value CIRCLE;
+ value BOX;
+};
+
+component Collider
+{
+ field type ColliderType { default "CIRCLE"; };
+ field radius float { default "1.0f"; };
+ field size vector2 { default "1.0f, 1.0f"; };
+};
+
+component RigidBody
+{
+ field mass float { default "1.0f"; };
+ field moment_of_inertia float { default "0.5f"; };
+};
+
+entity Physical
+{
+ field fixture bool { default "false"; };
+ field body RigidBody;
+ field collider Collider;
+};
+
+component HitPoints
+{
+ field max_hits uint { default "1"; };
+ field vulnerable_to uint { default "~0U"; };
+};
+
+component DamageSource
+{
+ field amount uint { default "1"; };
+ field type uint { default "0"; };
+};
+
+entity Hittable
+{
+ field immortal bool { default "false"; };
+ field damaging bool { default "false"; };
+ field hits HitPoints;
+ field damage DamageSource;
+};
+
+entity Playfield
+{
+ field size vector2;
+};
+
+entity Ship
+{
+ field physical Physical;
+ field mesh MeshSource;
+ field speed float;
+ field turn_rate float;
+};
+
+entity Bullet
+{
+ field physical Physical;
+ field hittable Hittable;
+ field mesh MeshSource;
+};
+
+entity Asteroid
+{
+ field physical Physical;
+ field hittable Hittable;
+ field mesh MeshSource;
+};
#include <msp/game/meshsource.h>
#include "physicalentity.h"
-
-struct ShipSetup
-{
- PhysicalSetup physical;
- Msp::Game::MeshSourceSetup mesh;
- float speed;
- float turn_rate;
-};
+#include "setups.h"
class Ship: public PhysicalEntity
{
#include <msp/linal/vector.h>
#include "component.h"
#include "mspgame_api.h"
+#include "setups.h"
namespace Msp::Game {
-enum class CameraScaling
-{
- ORIGINAL_SIZE,
- SCALE_TO_FIT,
- SCALE_TO_COVER,
- STRETCH_TO_FIT
-};
-
-struct CameraSetup
-{
- Geometry::Angle<float> field_of_view_y = Geometry::Angle<float>::from_degrees(60);
- LinAl::Vector<float, 2> size = { 16.0f/9.0f, 1.0f };
- float near_clip = 0.1f;
- float far_clip = 100.0f;
- CameraScaling scaling = CameraScaling::SCALE_TO_FIT;
- std::string sequence_name;
-};
-
struct CameraData
{
Geometry::Angle<float> fov_y;
namespace Msp::Game {
-DataFile::Loader::ActionMap MeshSourceSetup::Loader::shared_actions;
-
-MeshSourceSetup::Loader::Loader(MeshSourceSetup &s):
- ObjectLoader<MeshSourceSetup>(s)
-{
- set_actions(shared_actions);
-}
-
-void MeshSourceSetup::Loader::init_actions()
-{
- add("object", &MeshSourceSetup::object_name);
-}
-
} // namespace Msp::Game
#define MSP_GAME_MESHSOURCE_H_
#include <msp/datafile/objectloader.h>
+#include <msp/game/setups.h>
#include "component.h"
#include "mspgame_api.h"
namespace Msp::Game {
-struct MeshSourceSetup
-{
- class Loader: public DataFile::ObjectLoader<MeshSourceSetup>
- {
- private:
- static Loader::ActionMap shared_actions;
-
- public:
- Loader(MeshSourceSetup &);
-
- protected:
- void init_actions() override;
- };
-
- std::string object_name;
-};
-
class MSPGAME_API MeshSource: public Component
{
public:
--- /dev/null
+namespace "Msp::Game";
+api "MSPGAME_API" "msp/game/mspgame_api.h";
+
+enum CameraScaling
+{
+ value ORIGINAL_SIZE;
+ value SCALE_TO_FIT;
+ value SCALE_TO_COVER;
+ value STRETCH_TO_FIT;
+};
+
+component Camera
+{
+ field field_of_view_y angle { default "60"; };
+ field size vector2 { default "16.0f/9.0f, 1.0f"; };
+ field near_clip float { default "0.1f"; };
+ field far_clip float { default "100.0f"; };
+ field scaling CameraScaling { default "SCALE_TO_FIT"; };
+ field sequence_name string;
+};
+
+component MeshSource
+{
+ field object_name string;
+};