2021-02-02 19:42:17 +00:00
|
|
|
rl.SetTraceLogLevel(rl.LOG_WARNING)
|
|
|
|
rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
|
|
|
|
rl.InitWindow(800, 450, "raylib [core] example - mouse input");
|
|
|
|
|
|
|
|
local ball_position = rl.new("Vector2", -100, -100)
|
|
|
|
local ball_color = rl.DARKBLUE
|
|
|
|
|
|
|
|
while not rl.WindowShouldClose() do
|
|
|
|
ball_position.x = rl.GetMouseX()
|
|
|
|
ball_position.y = rl.GetMouseY()
|
|
|
|
|
2021-10-02 17:03:57 +00:00
|
|
|
if rl.IsMouseButtonPressed(rl.MOUSE_BUTTON_LEFT) then
|
2021-02-02 19:42:17 +00:00
|
|
|
ball_color = rl.MAROON
|
2021-10-02 17:03:57 +00:00
|
|
|
elseif rl.IsMouseButtonPressed(rl.MOUSE_BUTTON_MIDDLE) then
|
2021-02-02 19:42:17 +00:00
|
|
|
ball_color = rl.LIME
|
2021-10-02 17:03:57 +00:00
|
|
|
elseif rl.IsMouseButtonPressed(rl.MOUSE_BUTTON_RIGHT) then
|
2021-02-02 19:42:17 +00:00
|
|
|
ball_color = rl.DARKBLUE
|
|
|
|
end
|
|
|
|
|
|
|
|
rl.BeginDrawing()
|
|
|
|
|
|
|
|
rl.ClearBackground(rl.RAYWHITE)
|
|
|
|
rl.DrawCircleV(ball_position, 40, ball_color)
|
|
|
|
rl.DrawText("move ball with mouse and click mouse button to change color",
|
|
|
|
10, 10, 20, rl.DARKGRAY)
|
|
|
|
|
|
|
|
rl.EndDrawing()
|
|
|
|
end
|
|
|
|
|
|
|
|
rl.CloseWindow()
|