The code works if I don't define the event loops, but when I DO define events, the screen isn't even generated.
I initialized the pygame module before the loop.
I initialized the pygame module before the loop.
Code:
#-------------------------------------------------------------------------------
# Name: module3
# Purpose:
#
# Author: office
#
# Created: 02/03/2012
# Copyright: (c) office 2012
# Licence: <your licence>
#-------------------------------------------------------------------------------
#!/usr/bin/env python
import pygame
from pygame.locals import *
from sys import exit #load pygame module
pygame.init()
w = 640 #set width of screen
h = 480 #set height
x = 50
y = 50
rectW = 100
rectH = 100
while 1:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
pressed_mouse = pygame.mouse.get_pressed()
if pressed_mouse[0]:
newX, newY = pygame.mouse.get_pos()
x = newX
y = newY
display.update()
screen = pygame.display.set_mode((w, h)) #make screen
pygame.draw.rect(screen, (0, 255, 0), (x, y, rectW, rectH), 1)
pygame.display.flip()
Comment