--- /dev/null
+physical
+{
+ body
+ {
+ mass 200;
+ moment_of_inertia 2160;
+ };
+ collider
+ {
+ type CIRCLE;
+ radius 3;
+ };
+};
+hittable
+{
+ damaging true;
+ hits
+ {
+ max_hits 3;
+ vulnerable_to 1;
+ };
+ damage
+ {
+ amount 10;
+ type 1;
+ };
+};
+mesh
+{
+ object_name "Asteroid 1.object";
+};
--- /dev/null
+field_of_view_y 0;
+size 80 45;
+near_clip -30;
+far_clip 30;
+sequence_name "space.seq";
--- /dev/null
+physical
+{
+ body
+ {
+ mass 1;
+ moment_of_inertia 0.8;
+ };
+ collider
+ {
+ type CIRCLE;
+ radius 0.8;
+ };
+};
+mesh
+{
+ object_name "Bass guitar.object";
+};
+speed 12;
+turn_rate 4.71;
--- /dev/null
+physical
+{
+ body
+ {
+ mass 0.05;
+ moment_of_inertia 0.04;
+ };
+ collider
+ {
+ type CIRCLE;
+ radius 0.2;
+ };
+};
+hittable
+{
+ damaging true;
+ hits
+ {
+ max_hits 1;
+ };
+ damage
+ {
+ amount 1;
+ type 0;
+ };
+};
+mesh
+{
+ object_name "Quaver.object";
+};
#include "gamecontroller.h"
#include "physics.h"
#include "playercontroller.h"
+#include "setups.h"
using namespace Msp;
+BassteroidsResources::BassteroidsResources()
+{
+ add_type<AsteroidSetup>().suffix(".roid.setup");
+ add_type<BulletSetup>().suffix(".bullet.setup");
+ add_type<ShipSetup>().suffix(".ship.setup");
+}
+
+
Bassteroids::Bassteroids(int, char **):
event_observer(director.get_event_bus()),
game_stage(director.create_stage()),
pf_setup({ .size={ 80, 45 }}),
playfield(game_stage.get_root(), pf_setup),
- cam_setup({ .field_of_view_y=Geometry::Angle<float>::zero(), .size={ 80, 45 }, .near_clip=-30, .far_clip=30, .sequence_name="space.seq" }),
cam_entity(game_stage.get_root(), Game::TransformValues()),
- camera(const_cast<const Game::Owned<Game::Entity> &>(cam_entity), cam_setup)
+ camera(cam_entity, resources.get<Game::CameraSetup>("main.camera.setup"))
{
game_stage.add_system<GameController>();
game_stage.add_system<Physics>();
class PlayerController;
class BassteroidsResources: public Msp::Game::ApplicationResources, public Msp::GameView::Resources
-{ };
+{
+public:
+ BassteroidsResources();
+};
class Bassteroids: public Msp::GameView::Application<Bassteroids, BassteroidsResources>
{
Msp::Game::Owned<Playfield> playfield;
PlayerController *player_controller = nullptr;
- Msp::Game::CameraSetup cam_setup;
Msp::Game::Owned<Msp::Game::Entity> cam_entity;
Msp::Game::Owned<Msp::Game::Camera> camera;
GameController::GameController(Game::Stage &s):
System(s),
- asteroid_setup{ .physical={ .body={ .mass=200, .moment_of_inertia=2160 }, .collider={ .type=ColliderType::CIRCLE, .radius=3.0f } },
- .hittable={ .damaging=true, .hits={ .max_hits=3, .vulnerable_to=1 }, .damage={ .amount=10, .type=1 }},
- .mesh={ .object_name="Asteroid 1.object" }}
+ asteroid_setup(stage.get_resources().get<AsteroidSetup>("asteroid1.roid.setup"))
{ }
void GameController::tick(Time::TimeDelta)
};
std::minstd_rand rng;
- AsteroidSetup asteroid_setup;
+ const AsteroidSetup &asteroid_setup;
State state = LEVEL_START;
unsigned level = 1;
std::vector<Msp::Game::Owned<Asteroid>> asteroids;
PlayerController::PlayerController(Game::Stage &s):
System(s),
- player_setup{ .physical={ .body={ .mass=1, .moment_of_inertia=0.8f }, .collider={ .type=ColliderType::CIRCLE, .radius=0.8f }},
- .mesh={ .object_name="Bass guitar.object" },
- .speed=12.0f, .turn_rate=4.71f },
- bullet_setup{ .physical={ .body={ .mass=0.05f, .moment_of_inertia=0.04f }, .collider={ .type=ColliderType::CIRCLE, .radius=0.2f }},
- .hittable={ .damaging=true, .hits={ .max_hits=1 }, .damage={ .amount=1, .type=0 }},
- .mesh={ .object_name="Quaver.object" }}
+ player_setup(stage.get_resources().get<ShipSetup>("player.ship.setup")),
+ bullet_setup(stage.get_resources().get<BulletSetup>("quaver.bullet.setup"))
{
declare_dependency<Game::Transform>(READ_OLD);
declare_dependency<RigidBody>(UPDATE);
{
private:
Controls *controls = nullptr;
- ShipSetup player_setup;
- BulletSetup bullet_setup;
+ const ShipSetup &player_setup;
+ const BulletSetup &bullet_setup;
Msp::Game::Owned<Ship> player_ship;
std::vector<Msp::Game::Owned<Bullet>> bullets;
#include <msp/fs/dir.h>
#include <msp/fs/stat.h>
#include "resources.h"
+#include "setups.h"
using namespace std;
namespace Msp::Game {
+Resources::Resources()
+{
+ add_type<CameraSetup>().suffix(".camera.setup");
+}
+
+
ApplicationResources::ApplicationResources()
{
FS::Path data_dir = FS::get_sys_data_dir()/"data";
class MSPGAME_API Resources: virtual public DataFile::Collection
{
public:
+ Resources();
};
class MSPGAME_API ApplicationResources: public Resources