I am still quite a newbie with python so my code Is quite sloppy. Whenever I run it I get an error reading "Surfaces must not be locked during blit" but in my code I did not purposely lock the surface please help thank you.
Here is my code:
import pygame, sys, random
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((1000, 1000))
pygame.display.set_caption("The Starship by Christopher")
loop_numx = 999
loop_numy = 999
#pre-animation begin
#music set up
pygame.mixer.music.load('main.mp3')
pygame.mixer.music.play(0, 0.0)
#star assignment loop
while loop_numx > 0 and loop_numy > 0:
pixelarray = pygame.PixelArray(screen)
pixelarray[random.randrange(1,1000)][random.randrange(1, 1000)] = (255, 255, 255)
loop_numx-=1
loop_numy-=1
print loop_numx
print loop_numy
pygame.display.update()
#pre-animation ends
#gui begins
word = [
'exit game ',
'start game',
'contact_us']
word_num = 1
font = pygame.font.Font(None, 48)
m_toll = 1
while True:
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == ord('s') and m_toll == 1:
pygame.mixer.music.stop()
m_toll = 0
elif event.key == ord('s') and m_toll == 0:
m_toll = 1
pygame.mixer.music.play(0, 0.0)
elif event.key == K_DOWN and word_num > 0:
word_num-=1
print word[word_num]
elif event.key == K_UP and word_num !=2 :
word_num+=1
print word[word_num]
main_text = font.render(word[word_num], True, (255, 255, 0), (0, 0, 255))
main_text_rect = main_text.get_rect()
main_text_rect.centerx = screen.get_rect().centerx
main_text_rect.centery = screen.get_rect().centery
screen.blit(main_text, main_text_rect)
pygame.display.update()