GameController::GameController(Game::Stage &s):
System(s),
- asteroid_setup{ .physical = { .body = { .mass = 200 }, .collider = { .type = ColliderType::CIRCLE, .radius = 3.0f } },
- .mesh = { .object_name = "Asteroid 1.object" }}
+ asteroid_setup{ .physical={ .body={ .mass=200 }, .collider={ .type=ColliderType::CIRCLE, .radius=3.0f } },
+ .mesh={ .object_name="Asteroid 1.object" }}
{ }
void GameController::tick(Time::TimeDelta)
if(d_sq<r_sum*r_sum)
{
Collision &collision = get_collision(i, j);
- float d = sqrt(d_sq);
collision.normal = normalize(delta);
- collision.depth = r1+r2-d;
+ collision.depth = r1+r2-sqrt(d_sq);
collision.point = pos1-collision.normal*(r1-collision.depth/2);
if(collision.body1!=i)
collision.normal = -collision.normal;
private:
template<typename T>
- EventDispatcher<T> &get_emitter();
+ EventDispatcher<T> &get_dispatcher();
public:
template<typename T>
void add_observer(EventObserver &obs, std::function<void(const T &)> cb)
- { get_emitter<T>().add_observer(&obs, std::move(cb)); }
+ { get_dispatcher<T>().add_observer(&obs, std::move(cb)); }
void replace_observer(EventObserver &, EventObserver &);
void remove_observer(EventObserver &);
}
template<typename T>
-inline EventDispatcher<T> &EventBus::get_emitter()
+inline EventDispatcher<T> &EventBus::get_dispatcher()
{
unsigned id = get_event_id<T>();
if(dispatchers.size()<=id)
};
+template<typename... E>
+template<typename T>
+inline void EventSource<E...>::cancel_observation()
+{
+ for(const auto &h: static_cast<EventDispatcher<T> &>(*this).handlers)
+ h.observer->remove_source(*this);
+}
+
template<typename... E>
template<typename T, typename... Args>
inline void EventSource<E...>::emit(Args &&... args) const
bus.dispatch(event);
}
-template<typename... E>
-template<typename T>
-inline void EventSource<E...>::cancel_observation()
-{
- for(const auto &h: static_cast<EventDispatcher<T> &>(*this).handlers)
- h.observer->remove_source(*this);
-}
-
} // namespace Msp::Game
#endif