|
|
@@ -15,31 +15,41 @@
|
|
|
|
|
|
using namespace engine;
|
|
|
|
|
|
+scene::scene(std::string const & str) : identity<scene, std::string>(str) {}
|
|
|
+
|
|
|
scene::~scene() {}
|
|
|
|
|
|
-void scene::update(float delta) {
|
|
|
- for (auto & ent : entities) {
|
|
|
- ent.update(delta);
|
|
|
- }
|
|
|
- for (auto & pair : colliders) {
|
|
|
- auto & collidable = collidables[pair.first];
|
|
|
- for (auto & ent : pair.second) {
|
|
|
- for (auto & hit : collidable) {
|
|
|
- if (math::intersects(ent->render_info().points,
|
|
|
- hit->render_info().points)) {
|
|
|
- ent->collide(*hit);
|
|
|
- }
|
|
|
+void scene::check_collisions(std::vector<entity *> const & from,
|
|
|
+ std::vector<entity *> const & to) {
|
|
|
+ for (auto & ent : from) {
|
|
|
+ for (auto & hit : to) {
|
|
|
+ if (math::intersects(ent->render_info().points,
|
|
|
+ hit->render_info().points)) {
|
|
|
+ ent->collide(*hit);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void scene::render(graphics::renderer & renderer) {
|
|
|
- for (auto & ent : entities) {
|
|
|
- renderer.draw(ent.render_info());
|
|
|
+void scene::check_collisions() {
|
|
|
+ for (auto & pair : colliders) {
|
|
|
+ check_collisions(pair.second, collidables[pair.first]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// void scene::update(float delta) {
|
|
|
+// for (auto & ent : entities) {
|
|
|
+// ent.update(delta);
|
|
|
+// }
|
|
|
+// check_collisions();
|
|
|
+//}
|
|
|
+//
|
|
|
+// void scene::render(graphics::renderer & renderer) {
|
|
|
+// for (auto & ent : entities) {
|
|
|
+// renderer.draw(ent.render_info());
|
|
|
+// }
|
|
|
+//}
|
|
|
+
|
|
|
void scene::handle_key_event(event::key_event evt) {
|
|
|
if (evt.type & event::PRESSED_MASK && evt.key == keys::QUIT) {
|
|
|
dispatch_.lock()->quit();
|