Advertisement
Guest User

gif code

a guest
Jan 17th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. #include "SGL_Engine.h"
  2. /*
  3. TRY TO GET_
  4. if the button is the window, allow clickable.
  5. when allowed clickable, get postion.
  6.  
  7. */
  8. #define ESC_KEY 256
  9. using namespace sgl;
  10. int main() {
  11. sgl::RenderWindow window(1000, 1000, "sgl window");
  12. window.forceDraw();
  13. sgl::initRender(window.getSizeX(), window.getSizeY());
  14. sgl::Keyboard key(window.getWindow , sgl::keyCheck);
  15. int PointSize = 20;
  16. float Pointvertex[] = { window.getSizeX() / 2 , window.getSizeY() / 2 };
  17. /* game loop */
  18. sgl::MouseInput ms;
  19. ms.isEntered(window.getWindow , sgl::getCursorEntered);
  20. ms.getPosition(window.getWindow, sgl::getPositionButton);
  21. ms.getButtonPressed(window.getWindow, sgl::getButtonPressed);
  22.  
  23. while (!window.shouldclose(window.getWindow)) {
  24.  
  25. window.clear();
  26.  
  27. if (sgl::IsCursorEntered) {
  28. ms.hideCursor(window.getWindow);
  29. if (sgl::isButtonPressedLEFT) {
  30. cout << "LEFT===========================================" << endl;
  31.  
  32. cout << sgl::getCursorX << "," << sgl::getCursorY << endl;
  33. cout << "END===========================================" << endl;
  34.  
  35. }
  36. if (sgl::isButtonPressedRIGHT) {
  37. cout << "RIGHT==========================================" << endl;
  38. cout << sgl::getCursorX << "," << sgl::getCursorY << endl;
  39. cout << "END===========================================" << endl;
  40.  
  41.  
  42. }
  43. if (sgl::isButtonPressedMiddle) {
  44.  
  45. cout << "MIDDLE==========================================" << endl;
  46. cout << sgl::getCursorX << "," << sgl::getCursorY << endl;
  47. cout << "END===========================================" << endl;
  48.  
  49.  
  50. }
  51.  
  52. }
  53. else {
  54. ms.CursorShow(window.getWindow);
  55. }
  56. // function goes here.
  57. if (sgl::SGL_KEY == ESC_KEY) {
  58. window.close();
  59. // closes window
  60.  
  61. }
  62.  
  63. if (sgl::SGL_KEY == 73) {
  64.  
  65. PointSize++;
  66. }
  67. if (sgl::SGL_KEY == 70) {
  68.  
  69. PointSize--;
  70. }
  71.  
  72. // drawing should go here.
  73. sgl::drawPoint dp(2, 0, Pointvertex, 0, 1, PointSize);
  74.  
  75.  
  76. window.swap();
  77.  
  78. window.pollevents();
  79.  
  80.  
  81.  
  82. }
  83.  
  84. window.close();
  85.  
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement