Skip to content

Instantly share code, notes, and snippets.

@wkta
Created March 31, 2014 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wkta/9896894 to your computer and use it in GitHub Desktop.
Save wkta/9896894 to your computer and use it in GitHub Desktop.
#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