pygame - Python Blitting not working? -


i'm writing game in python , pygame , trying create main menu, label wont show up????, im getting error: line 22, in x,y = pygame.mouse.get_pos() error: video system not initialized???? don't understand happening here because new python heres code:

bif="menubg.jpg" load_check_x = "null" load_check_y = "null" import pygame, sys pygame.locals import * x = 0 y = 0   pygame.init() screen=pygame.display.set_mode((640,360),0,32) background=pygame.image.load(bif).convert() pygame.display.set_caption("some random title") pygame.display.flip() #screen.fill((0,0,0))  while true:     evc = pygame.event.get()     event in evc:         if event.type == pygame.quit:             pygame.quit()        x,y = pygame.mouse.get_pos() #setup mouse pos!!! if x >= 340 , x <= 465:     load_check_x = "true" if x < 340 or x > 465:     load_check_x = "false"  if y >= 425 , y <= 445:     load_check_y = "true" if y < 425 or y > 445:     load_check_y = "false"  if load_check_x == "true" , load_check_y == "true":    event in evc:        if event.type ==pygame.mousebuttonup:            clear() labelfont = pygame.font.sysfont("comic sans ms", 12) new_text = labelfont.render('play!!!!', 1, (255, 255, 255)) screen.blit(new_text, (340, 425)) 

someone me!!!

it seems indentation wrong. how python interpreter know when if statement body ends? looks @ amount of tabs or spaces see if code after belongs body, or not.

if @ code, see have code initialization, while loop loop processes events. after have code checks mouse etc.

as can see, of code after event loop, not belong while loop, , should. apart this, can replace if conditions creating new rect , checking if point have clicked lies inside rectangle.

my_rect = pygame.rect((340,425),(125,20)) while true:     evc = pygame.event.get()     event in evc:         if event.type == pygame.quit:             pygame.quit()            x,y = pygame.mouse.get_pos()     #setup mouse pos!!!     if my_rect.collidepoint(x,y):        event in evc:            if event.type ==pygame.mousebuttonup:                clear()     labelfont = pygame.font.sysfont("comic sans ms", 12)     new_text = labelfont.render('play!!!!', 1, (255, 255, 255))     screen.blit(new_text, (340, 425)) 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -