twelchPTM
Posts: 30
Joined: Mon Jun 09, 2014 7:59 pm

getting stuck in fullscreen

Thu Jun 12, 2014 6:42 pm

silly little program draws circles based on mouse position, program stops if you press any key but stays in fullscreen.....

Code: Select all

import pygame
from pygame.locals import *

width, height = 640, 640
radius = 0
mouseX, mouseY = 0,0
running = True

pygame.init()
#window = pygame.display.set_mode((width, height))
screen = pygame.display.set_mode((0,0), pygame.FULLSCREEN)
screen.fill(pygame.Color(255, 255, 255))

fps = pygame.time.Clock()

while running:
    for event in pygame.event.get():
        if event.type == MOUSEMOTION:
            mouseX, mouseY = event.pos
        if event.type == MOUSEBUTTONDOWN:
            screen.fill(pygame.Color(255, 255, 255))
        if event.type == KEYDOWN:
            running = False            
    radius = (abs(width/2 - mouseX)+abs(height/2 - mouseY))/2 + 1
    pygame.draw.circle(screen,
                       pygame.Color(255, 0, 0),
                       (mouseX, mouseY),
                       radius, 1)
    pygame.display.update()
    fps.tick(30)
pygame.quit
added note... just found out it runs fine from the command line just not in the idle enviroment.

User avatar
elParaguayo
Posts: 1943
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: getting stuck in fullscreen

Thu Jun 12, 2014 7:38 pm

Try changing your last line to:

Code: Select all

pygame.quit()
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

Return to “Python”