test_mouse_wheel.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*******************************************************************************************
  2. *
  3. * raylib test - Testing GetMouseWheelMove()
  4. *
  5. * This example has been created using raylib 1.0 (www.raylib.com)
  6. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  7. *
  8. * Copyright (c) 2013 Ramon Santamaria (Ray San - [email protected])
  9. *
  10. ********************************************************************************************/
  11. #include "raylib.h"
  12. int main()
  13. {
  14. // Initialization
  15. //--------------------------------------------------------------------------------------
  16. int screenWidth = 800;
  17. int screenHeight = 450;
  18. InitWindow(screenWidth, screenHeight, "raylib test - Mouse wheel");
  19. int positionY = 0;
  20. int scrollSpeed = 4; // Scrolling speed in pixels
  21. SetTargetFPS(60);
  22. //--------------------------------------------------------------------------------------
  23. // Main game loop
  24. while (!WindowShouldClose()) // Detect window close button or ESC key
  25. {
  26. // Update
  27. //----------------------------------------------------------------------------------
  28. positionY -= (GetMouseWheelMove()*scrollSpeed);
  29. //----------------------------------------------------------------------------------
  30. // Draw
  31. //----------------------------------------------------------------------------------
  32. BeginDrawing();
  33. ClearBackground(RAYWHITE);
  34. DrawRectangle(200, positionY, 80, 80, MAROON);
  35. DrawText(FormatText("%i", positionY), 10, 10, 20, GRAY);
  36. EndDrawing();
  37. //----------------------------------------------------------------------------------
  38. }
  39. // De-Initialization
  40. //--------------------------------------------------------------------------------------
  41. CloseWindow(); // Close window and OpenGL context
  42. //--------------------------------------------------------------------------------------
  43. return 0;
  44. }