MCPcopy Create free account
hub / github.com/AbyssEngine/AbyssEngineOld / processEvent

Method processEvent

src/OD2/Scenes/MapTest/MapTest.cpp:93–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93void MapTest::processEvent(const SDL_Event &event) {
94 switch (event.type) {
95 case SDL_MOUSEBUTTONDOWN:
96 switch (event.button.button) {
97 case SDL_BUTTON_RIGHT:
98 _isMouseDragging = true;
99 int mx;
100 int my;
101 Abyss::AbyssEngine::getInstance().getMouseState().getPosition(mx, my);
102 _mousePressedPosition.x = mx;
103 _mousePressedPosition.y = my;
104 _mapEngine->getCameraPosition(_startCameraPosition.x, _startCameraPosition.y);
105 SDL_CaptureMouse(SDL_TRUE);
106 break;
107 }
108 break;
109 case SDL_MOUSEBUTTONUP:
110 switch (event.button.button) {
111 case SDL_BUTTON_RIGHT:
112 SDL_CaptureMouse(SDL_FALSE);
113 _isMouseDragging = false;
114 break;
115 }
116 break;
117 case SDL_MOUSEMOTION:
118 if (_isMouseDragging) {
119 // Drag but take scale into account
120 int mx;
121 int my;
122 Abyss::AbyssEngine::getInstance().getMouseState().getPosition(mx, my);
123 _mapEngine->setCameraPosition(_startCameraPosition.x + (_mousePressedPosition.x - mx),
124 _startCameraPosition.y + (_mousePressedPosition.y - my));
125 }
126 break;
127 }
128}
129
130void MapTest::loadTile(const std::string &altName) {
131 Abyss::Common::Log::debug("Loading level alt: {}", altName);

Callers

nothing calls this directly

Calls 3

getPositionMethod · 0.80
getCameraPositionMethod · 0.80
setCameraPositionMethod · 0.80

Tested by

no test coverage detected