-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcore_input_mouse.bas
More file actions
74 lines (60 loc) · 2.82 KB
/
core_input_mouse.bas
File metadata and controls
74 lines (60 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
'*******************************************************************************************
'*
'* raylib [core] example - Mouse input
'*
'* Example originally created with raylib 1.0, last time updated with raylib 4.0
'*
'* 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-2022 Ramon Santamaria (@raysan5)
'*
'* Converted to SmallBASIC by Joerg Siebenmorgen, 2022
'* https://github.com/smallbasic/smallbasic.plugins/blob/master/raylib/samples
'*
'********************************************************************************************/
import raylib as rl
import raylibc as c
' Initialization
'--------------------------------------------------------------------------------------
const screenWidth = 800
const screenHeight = 450
ballPosition = { x: -100, y: -100 }
ballColor = c.DARKBLUE
rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input")
rl.SetTargetFPS(60) ' Set our game to run at 60 frames-per-second
'--------------------------------------------------------------------------------------
' Main game loop
while (!rl.WindowShouldClose()) ' Detect window close button or ESC key
' Update
'----------------------------------------------------------------------------------
ballPosition = rl.GetMousePosition()
if (rl.IsMouseButtonPressed(c.MOUSE_BUTTON_LEFT)) then
ballColor = c.MAROON
else if (rl.IsMouseButtonPressed(c.MOUSE_BUTTON_MIDDLE)) then
ballColor = c.LIME
else if (rl.IsMouseButtonPressed(c.MOUSE_BUTTON_RIGHT)) then
ballColor = c.DARKBLUE
else if (rl.IsMouseButtonPressed(c.MOUSE_BUTTON_SIDE)) then
ballColor = c.PURPLE
else if (rl.IsMouseButtonPressed(c.MOUSE_BUTTON_EXTRA)) then
ballColor = c.YELLOW
else if (rl.IsMouseButtonPressed(c.MOUSE_BUTTON_FORWARD)) then
ballColor = c.ORANGE
else if (rl.IsMouseButtonPressed(c.MOUSE_BUTTON_BACK)) then
ballColor = c.BEIGE
endif
'----------------------------------------------------------------------------------
' Draw
'----------------------------------------------------------------------------------
rl.BeginDrawing()
rl.ClearBackground(c.RAYWHITE)
rl.DrawCircleV(ballPosition, 40, ballColor)
rl.DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, c.DARKGRAY)
rl.EndDrawing()
'----------------------------------------------------------------------------------
wend
' De-Initialization
'--------------------------------------------------------------------------------------
rl.CloseWindow() ' Close window and OpenGL context
'--------------------------------------------------------------------------------------