Bomberman Multiplayer
Authoritative multiplayer networking layer for Bomberman.
Loading...
Searching...
No Matches
Scene.h
1#ifndef _BOMBERMAN_SCENES_SCENE_H_
2#define _BOMBERMAN_SCENES_SCENE_H_
3
4#include <SDL.h>
5#include <vector>
6
7#include "Entities/Object.h"
8
9namespace bomberman
10{
11 class Game;
16 class Scene
17 {
18 public:
24 Scene(Game* game);
29 virtual ~Scene();
35 void addObject(std::shared_ptr<Object> object);
42 void insertObject(std::shared_ptr<Object> object, int position);
48 void removeObject(std::shared_ptr<Object> object);
55 void setCamera(const int x, const int y);
60 virtual void onEnter();
65 virtual void onExit();
71 virtual void onEvent(const SDL_Event& event);
77 virtual void update(const unsigned int delta);
82 void draw() const;
83
87 [[nodiscard]]
88 SDL_Rect getCamera() const { return camera; }
89
93 [[nodiscard]]
94 virtual bool wantsNetworkInputPolling() const { return false; }
95
102 virtual void onNetInputQueued(uint32_t inputSeq, uint8_t buttons);
103
104 protected:
105 Game* game = nullptr; // pointer to game for use in all scenes
106
107 private:
108 std::vector<std::shared_ptr<Object>> objects; // objects to update and draw
109 SDL_Rect camera; // camera position
110 };
111} // namespace bomberman
112
113#endif // _BOMBERMAN_SCENES_SCENE_H_
Definition Game.h:23
Scene base class.
Definition Scene.h:17
virtual ~Scene()
Destroy the Scene object.
Definition Scene.cpp:14
void setCamera(const int x, const int y)
Set the Camera object to specific position.
Definition Scene.cpp:32
virtual void onEvent(const SDL_Event &event)
Trigger on SDL2 event if scene is active.
Definition Scene.cpp:42
virtual void onExit()
CAlled when scene become deactivated.
Definition Scene.cpp:40
SDL_Rect getCamera() const
Returns the current camera position.
Definition Scene.h:88
void insertObject(std::shared_ptr< Object > object, int position)
Add object to scene for drawing to specific position.
Definition Scene.cpp:21
virtual void onEnter()
Called when scene become activated.
Definition Scene.cpp:38
virtual void onNetInputQueued(uint32_t inputSeq, uint8_t buttons)
Called after Game samples and queues a local input for multiplayer scenes.
Definition Scene.cpp:52
void draw() const
Draw objects on the screen.
Definition Scene.cpp:54
void removeObject(std::shared_ptr< Object > object)
Remove object from scene.
Definition Scene.cpp:27
virtual bool wantsNetworkInputPolling() const
Returns true when this scene wants Game to poll and send multiplayer input every sim tick.
Definition Scene.h:94
virtual void update(const unsigned int delta)
Trigger on update if scene is active.
Definition Scene.cpp:44
void addObject(std::shared_ptr< Object > object)
Add object to scene for drawing.
Definition Scene.cpp:16