You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.1 KiB

  1. /*******************************************************************************************
  2. *
  3. * raylib [core] examples - Mouse wheel
  4. *
  5. * This test has been created using raylib 1.1 (www.raylib.com)
  6. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  7. *
  8. * Copyright (c) 2014 Ramon Santamaria (@raysan5)
  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 [core] example - mouse wheel");
  19. int boxPositionY = screenHeight/2 - 40;
  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. boxPositionY -= (GetMouseWheelMove()*scrollSpeed);
  29. //----------------------------------------------------------------------------------
  30. // Draw
  31. //----------------------------------------------------------------------------------
  32. BeginDrawing();
  33. ClearBackground(RAYWHITE);
  34. DrawRectangle(screenWidth/2 - 40, boxPositionY, 80, 80, MAROON);
  35. DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, GRAY);
  36. DrawText(FormatText("Box position Y: %03i", boxPositionY), 10, 40, 20, LIGHTGRAY);
  37. EndDrawing();
  38. //----------------------------------------------------------------------------------
  39. }
  40. // De-Initialization
  41. //--------------------------------------------------------------------------------------
  42. CloseWindow(); // Close window and OpenGL context
  43. //--------------------------------------------------------------------------------------
  44. return 0;
  45. }