Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Maze_Test::OnUserUpdate(float fElapsedTime)
- {
- static int32_t old_mouse_x = 0,old_mouse_y = 0;
- static int32_t mouse_x = 0,mouse_y = 0;
- if (GetMouse(0).bPressed)
- {
- mouse_x = GetMouseX();
- mouse_y = GetMouseY();
- mouse_x += mouse_x / column_width;
- mouse_y += mouse_y / row_height;
- old_mouse_x = mouse_x;
- old_mouse_y = mouse_y;
- }
- if (GetMouse(0).bHeld)
- {
- mouse_x = GetMouseX();
- mouse_y = GetMouseY();
- if(mouse_x >= 0 && mouse_x < ScreenWidth())
- {
- mouse_x += mouse_x / column_width;
- mouse_y += mouse_y / row_height;
- if(maze_width > ScreenWidth())
- {
- pan_x += (mouse_x - old_mouse_x);
- if(pan_x > 0)
- pan_x = 0;
- if(pan_x < -maze_width + ScreenWidth())
- pan_x = -maze_width + ScreenWidth();
- }
- }
- if (mouse_y >= 0 && mouse_y < ScreenHeight())
- {
- if (maze_height > ScreenHeight())
- {
- pan_y += (mouse_y - old_mouse_y);
- if (pan_y > 0)
- pan_y = 0;
- if (pan_y < -maze_height + ScreenHeight())
- pan_y = -maze_height + ScreenHeight();
- }
- }
- Clear(olc::WHITE);
- DrawGrid();
- DrawSolvePath();
- DrawMaze();
- old_mouse_x = mouse_x;
- old_mouse_y = mouse_y;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment