using namespace Msp;
-Bullet::Bullet(Game::Handle<Game::Entity> p, const Setup &s):
- PhysicalEntity(p, s.physical),
+Bullet::Bullet(Game::Handle<Game::Entity> p, const Setup &s, const Game::TransformValues &tv):
+ PhysicalEntity(p, s.physical, tv),
mesh(*this, s.mesh)
{ }
public:
using Setup = BulletSetup;
- Bullet(Msp::Game::Handle<Msp::Game::Entity>, const Setup &);
+ Bullet(Msp::Game::Handle<Msp::Game::Entity>, const Setup &, const Msp::Game::TransformValues & = Msp::Game::TransformValues());
};
#endif
Game::Handle<Game::Transform> player_tf = player_ship->get_transform();
Game::Handle<RigidBody> player_body = player_ship->get_body();
- bullets.emplace_back(stage.get_root(), bullet_setup);
+ Game::TransformValues tv;
+ tv.position = (player_tf->get_world_matrix()*LinAl::Vector<float, 4>(2.0f, 0.0f, 0.0f, 1.0f)).slice<3>(0);
+ tv.rotation = player_tf->get_rotation()*Geometry::Quaternion<float>::rotation(Geometry::Angle<float>::from_degrees(10), LinAl::Vector<float, 3>(0.0f, 0.0f, 1.0f));
+ bullets.emplace_back(stage.get_root(), bullet_setup, tv);
Game::Handle<Bullet> bullet = bullets.back();
- Game::Handle<Game::Transform> bullet_tf = bullet->get_transform();
- bullet_tf->set_position((player_tf->get_world_matrix()*LinAl::Vector<float, 4>(2.0f, 0.0f, 0.0f, 1.0f)).slice<3>(0));
- bullet_tf->set_rotation(player_tf->get_rotation()*Geometry::Quaternion<float>::rotation(Geometry::Angle<float>::from_degrees(10), LinAl::Vector<float, 3>(0.0f, 0.0f, 1.0f)));
Game::Handle<RigidBody> bullet_body = bullet->get_body();
bullet_body->set_velocity(player_body->get_velocity()+(player_tf->get_world_matrix()*LinAl::Vector<float, 4>(20.0f, 0.0f, 0.0f, 0.0f)).slice<2>(0));
}