| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- //
- // scene.hpp
- // engine
- //
- // Created by Sam Jaffe on 9/2/16.
- //
- #pragma once
- #include <memory>
- #include <unordered_map>
- #include <vector>
- #include "game/graphics/graphics_fwd.h"
- #include "game/math/math_fwd.hpp"
- #include "game/util/identity.hpp"
- #include "vector/vector.hpp"
- #include "engine_fwd.hpp"
- namespace engine {
- class scene : public identity<scene, std::string> {
- public:
- scene(std::string const &, std::shared_ptr<game_dispatch>);
- virtual ~scene();
- virtual void update(float delta) = 0;
- virtual void render(graphics::renderer & renderer) = 0;
- virtual void handle_key_event(event::key_event evt);
- virtual void handle_mouse_event(event::mouse_event evt);
- math::vec2 size() const;
- key_binding const & keys() const;
- protected:
- graphics::manager const & graphics_manager() const;
- void change_scene(std::string const & scene_id);
- void check_collisions();
- static void check_collisions(std::vector<collidable *> const & from,
- std::vector<collidable *> const & to);
- protected:
- std::vector<entity> entities;
- // Map from entity::collides_with -> [entity*]
- std::unordered_map<collision_t, std::vector<collidable *>> colliders;
- // Map from entity::collides_as -> [entity*]
- std::unordered_map<collision_t, std::vector<collidable *>> collidables;
- private:
- math::vec2 local_scene_dimension_;
- key_binding keys_;
- std::weak_ptr<game_dispatch> dispatch_;
- };
- }
|