[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] PyScribbles - Eraser



Here's an example using a square:

import pygame
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((640, 480))
background = "" 480))

pygame.mouse.set_visible (False)

square = pygame.Surface((30, 30))
square.fill((255, 255, 255))
squareRect = pygame.Rect((0, 0), (30, 30))

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            raise SystemExit
   
    screen.fill((0, 0, 0))
    mousePosition = pygame.mouse.get_pos()
    squareRect.center = mousePosition #move square to new mouse coordinates
    screen.blit(square, squareRect)
   
    pygame.display.flip()