#MonthOfCode day 25 - cursor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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