66 lines
2.4 KiB
C#
66 lines
2.4 KiB
C#
/*******************************************************************************************
|
|
*
|
|
* raylib [core] example - input mouse wheel
|
|
*
|
|
* Example complexity rating: [★☆☆☆] 1/4
|
|
*
|
|
* Example originally created with raylib 1.1, last time updated with raylib 1.3
|
|
*
|
|
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
* BSD-like license that allows static linking with closed source software
|
|
*
|
|
* Copyright (c) 2014-2025 Ramon Santamaria (@raysan5)
|
|
*
|
|
********************************************************************************************/
|
|
|
|
using static Raylib_cs.Raylib;
|
|
|
|
namespace Examples.Core;
|
|
|
|
public class InputMouseWheel
|
|
{
|
|
public static int Main()
|
|
{
|
|
// Initialization
|
|
//--------------------------------------------------------------------------------------
|
|
const int screenWidth = 800;
|
|
const int screenHeight = 450;
|
|
|
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - input mouse wheel");
|
|
|
|
int boxPositionY = screenHeight / 2 - 40;
|
|
int scrollSpeed = 4; // Scrolling speed in pixels
|
|
|
|
SetTargetFPS(60);
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
// Main game loop
|
|
while (!WindowShouldClose())
|
|
{
|
|
// Update
|
|
//----------------------------------------------------------------------------------
|
|
boxPositionY -= (int)(GetMouseWheelMove() * scrollSpeed);
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Draw
|
|
//----------------------------------------------------------------------------------
|
|
BeginDrawing();
|
|
ClearBackground(Color.RayWhite);
|
|
|
|
DrawRectangle(screenWidth / 2 - 40, boxPositionY, 80, 80, Color.Maroon);
|
|
|
|
DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, Color.Gray);
|
|
DrawText($"Box position Y: {boxPositionY}", 10, 40, 20, Color.LightGray);
|
|
|
|
EndDrawing();
|
|
//----------------------------------------------------------------------------------
|
|
}
|
|
|
|
// De-Initialization
|
|
//--------------------------------------------------------------------------------------
|
|
CloseWindow();
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
return 0;
|
|
}
|
|
}
|