init
This commit is contained in:
commit
38355d2442
9083 changed files with 1225834 additions and 0 deletions
105
.venv/lib/python3.8/site-packages/pygame/examples/cursors.py
Normal file
105
.venv/lib/python3.8/site-packages/pygame/examples/cursors.py
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
#!/usr/bin/env python
|
||||
""" pygame.examples.cursors
|
||||
|
||||
Click a mouse button (if you have one!) and the cursor changes.
|
||||
|
||||
"""
|
||||
import pygame as pg
|
||||
|
||||
|
||||
arrow = (
|
||||
"xX ",
|
||||
"X.X ",
|
||||
"X..X ",
|
||||
"X...X ",
|
||||
"X....X ",
|
||||
"X.....X ",
|
||||
"X......X ",
|
||||
"X.......X ",
|
||||
"X........X ",
|
||||
"X.........X ",
|
||||
"X......XXXXX ",
|
||||
"X...X..X ",
|
||||
"X..XX..X ",
|
||||
"X.X XX..X ",
|
||||
"XX X..X ",
|
||||
"X X..X ",
|
||||
" X..X ",
|
||||
" X..X ",
|
||||
" X..X ",
|
||||
" XX ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
)
|
||||
|
||||
|
||||
no = (
|
||||
" ",
|
||||
" ",
|
||||
" XXXXXX ",
|
||||
" XX......XX ",
|
||||
" X..........X ",
|
||||
" X....XXXX....X ",
|
||||
" X...XX XX...X ",
|
||||
" X.....X X...X ",
|
||||
" X..X...X X..X ",
|
||||
" X...XX...X X...X ",
|
||||
" X..X X...X X..X ",
|
||||
" X..X X...X X..X ",
|
||||
" X..X X.,.X X..X ",
|
||||
" X..X X...X X..X ",
|
||||
" X...X X...XX...X ",
|
||||
" X..X X...X..X ",
|
||||
" X...X X.....X ",
|
||||
" X...XX X...X ",
|
||||
" X....XXXXX...X ",
|
||||
" X..........X ",
|
||||
" XX......XX ",
|
||||
" XXXXXX ",
|
||||
" ",
|
||||
" ",
|
||||
)
|
||||
|
||||
|
||||
def TestCursor(arrow):
|
||||
hotspot = None
|
||||
for y, line in enumerate(arrow):
|
||||
for x, char in enumerate(line):
|
||||
if char in ["x", ",", "O"]:
|
||||
hotspot = x, y
|
||||
break
|
||||
if hotspot is not None:
|
||||
break
|
||||
if hotspot is None:
|
||||
raise Exception("No hotspot specified for cursor '%s'!" % arrow)
|
||||
s2 = []
|
||||
for line in arrow:
|
||||
s2.append(line.replace("x", "X").replace(",", ".").replace("O", "o"))
|
||||
cursor, mask = pg.cursors.compile(s2, "X", ".", "o")
|
||||
size = len(arrow[0]), len(arrow)
|
||||
pg.mouse.set_cursor(size, hotspot, cursor, mask)
|
||||
|
||||
|
||||
def main():
|
||||
pg.init()
|
||||
pg.font.init()
|
||||
font = pg.font.Font(None, 24)
|
||||
bg = pg.display.set_mode((800, 600), 0, 24)
|
||||
bg.fill((255, 255, 255))
|
||||
bg.blit(font.render("Click to advance", 1, (0, 0, 0)), (0, 0))
|
||||
pg.display.update()
|
||||
for cursor in [no, arrow]:
|
||||
TestCursor(cursor)
|
||||
going = True
|
||||
while going:
|
||||
pg.event.pump()
|
||||
for e in pg.event.get():
|
||||
if e.type == pg.MOUSEBUTTONDOWN:
|
||||
going = False
|
||||
pg.quit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue