[This is a really long code so im just going to put the traceback part in and where I think the problem is]

[def directions():
enter=0
nwscreen()
Font1 = pygame.font.SysFont('ActionIsShaded', 25)
d1 = basicFont.render('Directions',False,WHITE,BLACK)
d2 = Font1.render('Directions',False,WHITE,BLACK)
d3 = Font1.render('ALL ANSWERS MUST BE LOWERCASE',False,RED,BLACK)
d4 = Font1.render ('Press enter to continue...',False,GREEN,BLUE)
d1Rect = d1.get_rect()
d2Rect = d2.get_rect()
d3Rect = d3.get_rect()
d4Rect = d4.get_rect()
d1Rect.centerx = windowSurface.get_rect().centerx
d1Rect.centery = windowSurface.get_rect().centery-175
d2Rect.centerx = windowSurface.get_rect().centerx
d2Rect.centery = windowSurface.get_rect().centery-140
d3Rect.centerx = windowSurface.get_rect().centerx
d3Rect.centery = windowSurface.get_rect().centery-105
d4Rect.centerx = windowSurface.get_rect().centerx
d4Rect.centery = windowSurface.get_rect().centery-70
windowSurface.blit(d1,d1Rect)
windowSurface.blit(d2,d2Rect)
windowSurface.blit(d3,d3Rect)
windowSurface.blit(d4,d4Rect)
pygame.display.update()
while enter==0:
pygame.event.get()
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYDOWN:
if event.key == K_KP_ENTER:
enter=enter+1
if event.key == K_ESCAPE:
pygame.quit()
sys.exit()
]


[Traceback (most recent call last):
File "C:\Python31\pytest.py", line 250, in <module>
directions()
File "C:\Python31\pytest.py", line 63, in directions
if event.type == KEYDOWN:
KeyboardInterrupt]


[Can anyone help me]

Recommended Answers

All 2 Replies

code-tags, please.

(This is a really long code so im just going to put the traceback part in and where I think the problem is)

(Can anyone help me)

def directions():
    enter=0
    nwscreen()
    Font1 = pygame.font.SysFont('ActionIsShaded', 25)
    d1 = basicFont.render('Directions',False,WHITE,BLACK)
    d2 = Font1.render('Directions',False,WHITE,BLACK)
    d3 = Font1.render('ALL ANSWERS MUST BE LOWERCASE',False,RED,BLACK)
    d4 = Font1.render ('Press enter to continue...',False,GREEN,BLUE)
    d1Rect = d1.get_rect()
    d2Rect = d2.get_rect()
    d3Rect = d3.get_rect()
    d4Rect = d4.get_rect()
    d1Rect.centerx = windowSurface.get_rect().centerx
    d1Rect.centery = windowSurface.get_rect().centery-175
    d2Rect.centerx = windowSurface.get_rect().centerx
    d2Rect.centery = windowSurface.get_rect().centery-140
    d3Rect.centerx = windowSurface.get_rect().centerx
    d3Rect.centery = windowSurface.get_rect().centery-105
    d4Rect.centerx = windowSurface.get_rect().centerx
    d4Rect.centery = windowSurface.get_rect().centery-70
    windowSurface.blit(d1,d1Rect)
    windowSurface.blit(d2,d2Rect)
    windowSurface.blit(d3,d3Rect)
    windowSurface.blit(d4,d4Rect)
    pygame.display.update()
    while enter==0: 
        pygame.event.get() 
        if event.type == QUIT: 
            pygame.quit() 
            sys.exit() 
        if event.type == KEYDOWN: 
            if event.key == K_KP_ENTER: 
                enter=enter+1
            if event.key == K_ESCAPE: 
                pygame.quit() 
                sys.exit()

[Traceback (most recent call last):
  File "C:\Python31\pytest.py", line 250, in <module>
    directions()
  File "C:\Python31\pytest.py", line 63, in directions
    if event.type == KEYDOWN:
KeyboardInterrupt]

Maybe you need to put code in

try.. except KeyboardInterrupt:

block somehow.

From this post of vegaseat: http://www.daniweb.com/forums/post1275991.html#post1275991
though I see the event taken like this:

keepGoing = True
    while keepGoing:
        #clock.tick(30)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                keepGoing = False
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.