| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- //
- // scene.hpp
- // engine
- //
- // Created by Sam Jaffe on 9/2/16.
- //
- #pragma once
- #include <memory>
- #include <unordered_map>
- #include <vector>
- #include "game/math/math_fwd.hpp"
- #include "game/util/identity.hpp"
- #include "vector/vector.hpp"
- #include "engine_fwd.hpp"
- namespace graphics {
- class renderer;
- }
- namespace engine {
- class entity;
- class scene : public identity<scene, std::string> {
- public:
- using identity<scene, std::string>::identity;
- virtual ~scene();
- virtual void update(float delta);
- virtual void render();
- 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:
- void change_scene(std::string const & scene_id);
- protected:
- graphics::renderer * renderer;
- std::vector<entity> entities;
- // Map from entity::collides_with -> [entity*]
- std::unordered_map<collision_t, std::vector<entity *>> colliders;
- // Map from entity::collides_as -> [entity*]
- std::unordered_map<collision_t, std::vector<entity *>> collidables;
- private:
- math::vec2 local_scene_dimension_;
- key_binding keys_;
- std::weak_ptr<game_dispatch> dispatch_;
- };
- }
|