-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
46 lines (35 loc) · 1.27 KB
/
test.py
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
# pg setup
import pygame as pg
pg.init()
screen = pg.display.set_mode([600, 400])
pg.display.set_caption("Example code for the cursors module")
# create a system cursor
system = pg.cursors.Cursor(pg.SYSTEM_CURSOR_SIZENWSE)
# create bitmap cursors
# pg.cursors.broken_x
bitmap_1 = pg.cursors.Cursor(*pg.cursors.tri_left)
# cursor = pg.cursors.compile(pg.cursors.textmarker_strings)
# pg.mouse.set_cursor((8, 16), (0, 0), *cursor)
# bitmap_2 = pg.cursors.compile(pg.cursors.sizer_x_strings)
# create a color cursor
surf = pg.Surface((40, 40)) # you could also load an image
surf.fill((120, 50, 50)) # and use that as your surface
color = pg.cursors.Cursor((20, 20), surf)
cursors = [system, bitmap_1, bitmap_2, color]
cursor_index = 0
pg.mouse.set_cursor(system)
clock = pg.time.Clock()
going = True
while going:
clock.tick(60)
screen.fill((0, 75, 30))
pg.display.flip()
for event in pg.event.get():
if event.type == pg.QUIT or (event.type == pg.KEYDOWN and event.key == pg.K_ESCAPE):
going = False
# if the mouse is clicked it will switch to a new cursor
if event.type == pg.MOUSEBUTTONDOWN:
cursor_index += 1
cursor_index %= len(cursors)
pg.mouse.set_cursor(cursors[cursor_index])
pg.quit()