maspeir

Untitled

May 21st, 2025
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. bool Maze_Test::OnUserUpdate(float fElapsedTime)
  2. {
  3. static int32_t old_mouse_x = 0,old_mouse_y = 0;
  4. static int32_t mouse_x = 0,mouse_y = 0;
  5.  
  6. if (GetMouse(0).bPressed)
  7. {
  8. mouse_x = GetMouseX();
  9. mouse_y = GetMouseY();
  10. mouse_x += mouse_x / column_width;
  11. mouse_y += mouse_y / row_height;
  12. old_mouse_x = mouse_x;
  13. old_mouse_y = mouse_y;
  14. }
  15.  
  16. if (GetMouse(0).bHeld)
  17. {
  18. mouse_x = GetMouseX();
  19. mouse_y = GetMouseY();
  20.  
  21. if(mouse_x >= 0 && mouse_x < ScreenWidth())
  22. {
  23. mouse_x += mouse_x / column_width;
  24. mouse_y += mouse_y / row_height;
  25.  
  26. if(maze_width > ScreenWidth())
  27. {
  28. pan_x += (mouse_x - old_mouse_x);
  29. if(pan_x > 0)
  30. pan_x = 0;
  31. if(pan_x < -maze_width + ScreenWidth())
  32. pan_x = -maze_width + ScreenWidth();
  33. }
  34. }
  35.  
  36. if (mouse_y >= 0 && mouse_y < ScreenHeight())
  37. {
  38. if (maze_height > ScreenHeight())
  39. {
  40. pan_y += (mouse_y - old_mouse_y);
  41. if (pan_y > 0)
  42. pan_y = 0;
  43. if (pan_y < -maze_height + ScreenHeight())
  44. pan_y = -maze_height + ScreenHeight();
  45. }
  46. }
  47.  
  48. Clear(olc::WHITE);
  49.  
  50. DrawGrid();
  51. DrawSolvePath();
  52. DrawMaze();
  53.  
  54. old_mouse_x = mouse_x;
  55. old_mouse_y = mouse_y;
  56. }
  57.  
  58. return true;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment