#MonthOfCode day 25 - cursor
import pygame | |
DISP_WIDTH = 640 | |
DISP_HEIGHT = 480 | |
def refreshScreen(): | |
window.fill( pygame.Color('black') ) | |
pygame.display.flip() | |
# init. pygame libr; create the screen and diplays a help message in the console | |
pygame.init() | |
window = pygame.display.set_mode( (DISP_WIDTH, DISP_HEIGHT) ) | |
pygame.display.set_caption('Press any key to change the cursor type') | |
program_done = False | |
refreshScreen() | |
cursors = [ pygame.cursors.arrow, | |
pygame.cursors.diamond, | |
pygame.cursors.broken_x, | |
pygame.cursors.tri_left, | |
pygame.cursors.tri_right ] | |
ind_cursor_chosen = 0 | |
while not program_done: | |
for event in pygame.event.get(): | |
if event.type == pygame.QUIT: | |
program_done = True | |
break | |
if event.type is pygame.KEYDOWN: | |
ind_cursor_chosen+=1 | |
ind_cursor_chosen = ind_cursor_chosen % len(cursors) | |
pygame.mouse.set_cursor( *cursors[ind_cursor_chosen ]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment