1 | /******************************************************************************************* |
2 | * |
3 | * raylib [core] examples - Mouse wheel input |
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 | |
12 | #include "raylib.h" |
13 | |
14 | int main(void) |
15 | { |
16 | // Initialization |
17 | //-------------------------------------------------------------------------------------- |
18 | const int screenWidth = 800; |
19 | const int screenHeight = 450; |
20 | |
21 | InitWindow(screenWidth, screenHeight, "raylib [core] example - input mouse wheel" ); |
22 | |
23 | int boxPositionY = screenHeight/2 - 40; |
24 | int scrollSpeed = 4; // Scrolling speed in pixels |
25 | |
26 | SetTargetFPS(60); // Set our game to run at 60 frames-per-second |
27 | //-------------------------------------------------------------------------------------- |
28 | |
29 | // Main game loop |
30 | while (!WindowShouldClose()) // Detect window close button or ESC key |
31 | { |
32 | // Update |
33 | //---------------------------------------------------------------------------------- |
34 | boxPositionY -= (GetMouseWheelMove()*scrollSpeed); |
35 | //---------------------------------------------------------------------------------- |
36 | |
37 | // Draw |
38 | //---------------------------------------------------------------------------------- |
39 | BeginDrawing(); |
40 | |
41 | ClearBackground(RAYWHITE); |
42 | |
43 | DrawRectangle(screenWidth/2 - 40, boxPositionY, 80, 80, MAROON); |
44 | |
45 | DrawText("Use mouse wheel to move the cube up and down!" , 10, 10, 20, GRAY); |
46 | DrawText(FormatText("Box position Y: %03i" , boxPositionY), 10, 40, 20, LIGHTGRAY); |
47 | |
48 | EndDrawing(); |
49 | //---------------------------------------------------------------------------------- |
50 | } |
51 | |
52 | // De-Initialization |
53 | //-------------------------------------------------------------------------------------- |
54 | CloseWindow(); // Close window and OpenGL context |
55 | //-------------------------------------------------------------------------------------- |
56 | |
57 | return 0; |
58 | } |