| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- //
- // 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);
- bool in_bounds(math::dim2::point c) const;
- bool in_bounds(collidable * c) const;
- 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_;
- };
- }
|