<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Music Playing; But Screen Is Blank. Pygame Help!!!' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Music Playing; But Screen Is Blank. Pygame Help!!!' posted on the 'Python' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Thu, 20 Jun 2013 04:47:54 -0700</pubDate>
    <lastBuildDate>Thu, 20 Jun 2013 04:47:54 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Music Playing; But Screen Is Blank. Pygame Help!!!</title>
      <link>http://www.programmersheaven.com/mb/python/430979/430979/music-playing-but-screen-is-blank-pygame-help/</link>
      <description>I'm a new programmer working on a memory game for my computer science summative. I'm basically done but I really want to get the game to play music while the user is playing. I finally got the music to play, but unfortunately now the screen is just blank and I have no idea why.&lt;br /&gt;
&lt;br /&gt;
Any help would be appreciated. Thanks:)[code&lt;br /&gt;
&lt;br /&gt;
]import pygame , sys&lt;br /&gt;
import random&lt;br /&gt;
import time&lt;br /&gt;
size=[500,500]&lt;br /&gt;
pygame.init()&lt;br /&gt;
screen=pygame.display.set_mode(size)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
               # MUSIC&lt;br /&gt;
pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)&lt;br /&gt;
print "Mixer settings", pygame.mixer.get_init()&lt;br /&gt;
print "Mixer channels", pygame.mixer.get_num_channels()&lt;br /&gt;
pygame.mixer.music.set_volume(1.0)&lt;br /&gt;
pygame.mixer.music.load("Wings.wav")&lt;br /&gt;
pygame.mixer.music.play()&lt;br /&gt;
&lt;br /&gt;
clock = pygame.time.Clock()&lt;br /&gt;
while pygame.mixer.music.get_busy():&lt;br /&gt;
   # check if playback has finished&lt;br /&gt;
   clock.tick(30)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Colours&lt;br /&gt;
LIME = (0,255,0) &lt;br /&gt;
RED = (255, 0, 0)&lt;br /&gt;
BLACK = (0,0,0)&lt;br /&gt;
PINK = (255,102,178)&lt;br /&gt;
SALMON = (255,192,203)&lt;br /&gt;
WHITE = (255,255,255)&lt;br /&gt;
LIGHT_PINK = (255, 181, 197)&lt;br /&gt;
SKY_BLUE = (176, 226, 255)&lt;br /&gt;
PURPLE = (104, 34, 139)&lt;br /&gt;
screen.fill(BLACK)&lt;br /&gt;
&lt;br /&gt;
# Width and Height of game box&lt;br /&gt;
width=50&lt;br /&gt;
height=50&lt;br /&gt;
&lt;br /&gt;
# Margin between each cell&lt;br /&gt;
margin = 5&lt;br /&gt;
&lt;br /&gt;
#Loop until the user clicks the close button.&lt;br /&gt;
done=False&lt;br /&gt;
&lt;br /&gt;
# Used to manage how fast the screen updates&lt;br /&gt;
clock=pygame.time.Clock()&lt;br /&gt;
&lt;br /&gt;
                   # INSTRUCTIONS!!!!!!!!!&lt;br /&gt;
# This is a font we use to draw text on the screen (size 36)&lt;br /&gt;
font = pygame.font.Font(None, 36)&lt;br /&gt;
&lt;br /&gt;
display_instructions = True&lt;br /&gt;
instruction_page = 1&lt;br /&gt;
&lt;br /&gt;
# -------- Instruction Page Loop -----------&lt;br /&gt;
while done==False and display_instructions:&lt;br /&gt;
    for event in pygame.event.get(): # User did something&lt;br /&gt;
        if event.type == pygame.QUIT: # If user clicked close&lt;br /&gt;
            done=True # Flag that we are done so we exit this loop&lt;br /&gt;
        if event.type == pygame.MOUSEBUTTONDOWN:&lt;br /&gt;
            instruction_page += 1&lt;br /&gt;
            if instruction_page == 3:&lt;br /&gt;
                display_instructions = False&lt;br /&gt;
&lt;br /&gt;
    # Set the screen background&lt;br /&gt;
    screen.fill(BLACK)&lt;br /&gt;
&lt;br /&gt;
   if instruction_page == 1:&lt;br /&gt;
        # Draw instructions, page 1&lt;br /&gt;
        # This could also load an image created in another program.&lt;br /&gt;
        # That could be both easier and more flexible.&lt;br /&gt;
&lt;br /&gt;
        text=font.render("Welcome to Spatial Recall: ", True, PURPLE)&lt;br /&gt;
        screen.blit(text, [10, 10])&lt;br /&gt;
        text=font.render("The game that tests your memory!!!", True, WHITE)&lt;br /&gt;
        screen.blit(text, [10, 40])&lt;br /&gt;
&lt;br /&gt;
        text=font.render("Click for instructions", True, RED)&lt;br /&gt;
        screen.blit(text, [110, 100])&lt;br /&gt;
&lt;br /&gt;
 if instruction_page == 2:&lt;br /&gt;
    # Draw instructions, page 2&lt;br /&gt;
    text=font.render("This is how the game goes: The", True, WHITE)&lt;br /&gt;
    screen.blit(text, [10, 10])&lt;br /&gt;
&lt;br /&gt;
    text=font.render("computer is going to flash some green", True, WHITE)&lt;br /&gt;
    screen.blit(text, [10, 40])    &lt;br /&gt;
&lt;br /&gt;
    text=font.render("boxes at random positions. It's", True, WHITE)&lt;br /&gt;
    screen.blit(text, [10, 70])       &lt;br /&gt;
&lt;br /&gt;
    text=font.render("up to you to decide where you", True, WHITE)&lt;br /&gt;
    screen.blit(text, [10, 100]) &lt;br /&gt;
&lt;br /&gt;
    text=font.render("think they are hidden.", True, WHITE)&lt;br /&gt;
    screen.blit(text, [10, 130])  &lt;br /&gt;
&lt;br /&gt;
    text=font.render("Good Luck!!.", True, PURPLE)&lt;br /&gt;
    screen.blit(text, [20, 160])          &lt;br /&gt;
&lt;br /&gt;
    text=font.render("Play game", True, RED)&lt;br /&gt;
    screen.blit(text, [320, 310])&lt;br /&gt;
# Limit to 20 frames per second&lt;br /&gt;
clock.tick(20)&lt;br /&gt;
&lt;br /&gt;
# Go ahead and update the screen with what we've drawn.&lt;br /&gt;
pygame.display.flip()&lt;br /&gt;
&lt;br /&gt;
width=50&lt;br /&gt;
height=50&lt;br /&gt;
&lt;br /&gt;
# Margin between each cell&lt;br /&gt;
margin = 5&lt;br /&gt;
&lt;br /&gt;
coord=[]&lt;br /&gt;
&lt;br /&gt;
# Create a 2 dimensional array. A two dimesional&lt;br /&gt;
# array is simply a list of lists.&lt;br /&gt;
grid=[]&lt;br /&gt;
for row in range(20):&lt;br /&gt;
    # Add an empty array that will hold each cell&lt;br /&gt;
    # in this row&lt;br /&gt;
    grid.append([])&lt;br /&gt;
    for column in range(20):&lt;br /&gt;
        grid[row].append(0) # Append a cell&lt;br /&gt;
&lt;br /&gt;
# Set row 1, cell 5 to one. (Remember rows and&lt;br /&gt;
# column numbers start at zero.)&lt;br /&gt;
grid[1][5] = 0 &lt;br /&gt;
&lt;br /&gt;
# Set title of screen&lt;br /&gt;
pygame.display.set_caption("Spatial Recall")&lt;br /&gt;
&lt;br /&gt;
#Loop until the user clicks the close button.&lt;br /&gt;
done=False&lt;br /&gt;
&lt;br /&gt;
# Used to manage how fast the screen updates&lt;br /&gt;
clock=pygame.time.Clock()&lt;br /&gt;
&lt;br /&gt;
#draw the grid all pink&lt;br /&gt;
for row in range(20):&lt;br /&gt;
    for column in range(20):&lt;br /&gt;
        color = LIGHT_PINK&lt;br /&gt;
        pygame.draw.rect(screen,color,[(margin+width)*colu
mn + margin,           &lt;br /&gt;
(margin+height)*row+margin,width,height])&lt;br /&gt;
        pygame.display.flip()    &lt;br /&gt;
    '''&lt;br /&gt;
        #create list of random coodinates&lt;br /&gt;
    x = random.randint(0, 10)&lt;br /&gt;
    y = random.randint(0, 10) '''       &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #cover pink squares with green squares at the list of coodinates&lt;br /&gt;
    #loop through the list, for every coordinate in list, turn green&lt;br /&gt;
&lt;br /&gt;
for i in range(random.randint(2,10)):&lt;br /&gt;
    x = random.randint(2, 10)&lt;br /&gt;
    y = random.randint(2, 10)                &lt;br /&gt;
    color = LIME    &lt;br /&gt;
    pygame.draw.rect(screen,color,[(margin+width)*y + margin,    &lt;br /&gt;
(margin+height)*x+margin,width,height])&lt;br /&gt;
    coord.append((x,y))    &lt;br /&gt;
    pygame.display.flip() &lt;br /&gt;
    time.sleep(2)&lt;br /&gt;
&lt;br /&gt;
   for row in range(20):&lt;br /&gt;
    for column in range(20):&lt;br /&gt;
        color = LIGHT_PINK&lt;br /&gt;
        pygame.draw.rect(screen,color,[(margin+width)*colu
mn + margin,   &lt;br /&gt;
(margin+height)*row+margin,width,height])&lt;br /&gt;
        pygame.display.flip() &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
clock.tick(100)  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
            # -------- Main Program Loop -----------&lt;br /&gt;
while done==False:    &lt;br /&gt;
    for event in pygame.event.get(): # User did something&lt;br /&gt;
        if event.type == pygame.QUIT: # If user clicked close&lt;br /&gt;
            done=True # Flag that we are done so we exit this loop&lt;br /&gt;
        elif event.type == pygame.MOUSEBUTTONDOWN:&lt;br /&gt;
            # User clicks the mouse. Get the position&lt;br /&gt;
            pos = pygame.mouse.get_pos()&lt;br /&gt;
            # Change the x/y screen coordinates to grid coordinates&lt;br /&gt;
            column=pos[0] // (width+margin)&lt;br /&gt;
            row=pos[1] // (height+margin)&lt;br /&gt;
            print coord&lt;br /&gt;
            print [row,column]&lt;br /&gt;
            if (row,column) in coord:&lt;br /&gt;
                color = LIME&lt;br /&gt;
                pygame.draw.rect(screen,color,[(margin+width)*colu
mn + margin,   &lt;br /&gt;
(margin+height)*row+margin,width,height])&lt;br /&gt;
            else:&lt;br /&gt;
                color = RED&lt;br /&gt;
                pygame.draw.rect(screen,color,[(margin+width)*colu
mn + margin,&lt;br /&gt;
 ( margin+height)*row+margin,width,height])&lt;br /&gt;
        pygame.display.flip()              &lt;br /&gt;
&lt;br /&gt;
    #x = random.randint(0, 10)&lt;br /&gt;
    #y = random.randint(0, 10) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
pygame.quit ()[/code]&lt;br /&gt;
&lt;br&gt;&lt;br&gt;&lt;strong&gt;Attachment:&lt;/strong&gt; &lt;a href="http://www.programmersheaven.com/mb/DownloadAttachment.aspx?AttachmentID=2515"&gt;testing.py&lt;/a&gt; (6712 bytes | downloaded 52 times)</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/430979/430979/music-playing-but-screen-is-blank-pygame-help/</guid>
      <pubDate>Sat, 19 Jan 2013 04:09:28 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Music Playing; But Screen Is Blank. Pygame Help!!!</title>
      <link>http://www.programmersheaven.com/mb/python/430979/430993/re-music-playing-but-screen-is-blank-pygame-help/#430993</link>
      <description>I noticed that the rectangles only appeared after I closed the program/broke the loop. I realised that you misindented your code &lt;br /&gt;
i.e &lt;pre class="sourcecode"&gt;# -------- Instruction Page Loop -----------
while done==False and display_instructions:
   
   for event in pygame.event.get(): # User did something
      
      if event.type == pygame.QUIT: # If user clicked close
         done=True # Flag that we are done so we exit this loop
         
      if event.type == pygame.MOUSEBUTTONDOWN:
            
         instruction_page += 1

         
      #instruction pages set    

&lt;hr /&gt;  
      if instruction_page == 3:
            display_instructions = False
            
            # Set the screen background
            screen.fill(BLACK)
            
      elif instruction_page == 1:
         # Draw instructions, page 1
         # This could also load an image created in another program.
         # That could be both easier and more flexible.
               
         text=font.render("Welcome to Spatial Recall: ", True, PURPLE)
         screen.blit(text, [10, 10])
         text=font.render("The game that tests your memory!!!", True, WHITE)
         screen.blit(text, [10, 50])
         
         text=mmfont.render("Click for instructions", True, RED)
         screen.blit(text, [40, 150])

         &lt;span style="color: Red;"&gt;pygame.display.update()
         screen.fill(BLACK)&lt;/span&gt;
      
      elif instruction_page == 2:
         # Draw instructions, page 2
         text=font.render("This is how the game goes: The", True, WHITE)
         screen.blit(text, [10, 10])
         
         text=font.render("computer is going to flash some green", True, WHITE)
         screen.blit(text, [10, 40])    
         
         text=font.render("boxes at random positions. It's", True, WHITE)
         screen.blit(text, [10, 70])       
         
         text=font.render("up to you to decide where you", True, WHITE)
         screen.blit(text, [10, 100]) 
         
         text=font.render("think they are hidden.", True, WHITE)
         screen.blit(text, [10, 130])  
         
         text=font.render("Good Luck!!.", True, PURPLE)
         screen.blit(text, [20, 180])          
         
         text=mmfont.render("PLAY GAME", True, RED)
         screen.blit(text, [120, 330])
         # Limit to 20 frames per second
         clock.tick(20)
         
         # Go ahead and update the screen with what we've drawn.
         pygame.display.flip()

&lt;/pre&gt; &lt;br /&gt;
&lt;br /&gt;
This is properly indented.&lt;br /&gt;
&lt;br /&gt;
Note: You can't do anything for the first 10 seconds or so&lt;br /&gt;
Also the text needs a update function i.e beneath the "Click for instructions" code(It's red). Plus according to my Python Shell pygame can't load wave files. &lt;br /&gt;
&lt;br /&gt;
Otherwise the code is fine apart from maybe needing a win animation&lt;br /&gt;
&lt;br /&gt;
P.S : Why were you doing this at 2am in the morning?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Edit: Strange, for some reason I posted 3 times.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br&gt;&lt;br&gt;&lt;strong&gt;Attachment:&lt;/strong&gt; &lt;a href="http://www.programmersheaven.com/mb/DownloadAttachment.aspx?AttachmentID=2517"&gt;testing.py&lt;/a&gt; (6379 bytes | downloaded 50 times)</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/430979/430993/re-music-playing-but-screen-is-blank-pygame-help/#430993</guid>
      <pubDate>Sat, 19 Jan 2013 17:13:08 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Music Playing; But Screen Is Blank. Pygame Help!!!</title>
      <link>http://www.programmersheaven.com/mb/python/430979/430994/re-music-playing-but-screen-is-blank-pygame-help/#430994</link>
      <description>I noticed that the rectangles only appeared after I closed the program/broke the loop. I realised that you misindented your code &lt;br /&gt;
i.e &lt;pre class="sourcecode"&gt;# -------- Instruction Page Loop -----------
while done==False and display_instructions:
   
   for event in pygame.event.get(): # User did something
      
      if event.type == pygame.QUIT: # If user clicked close
         done=True # Flag that we are done so we exit this loop
         
      if event.type == pygame.MOUSEBUTTONDOWN:
            
         instruction_page += 1

         
      #instruction pages set    

&lt;hr /&gt;  
      if instruction_page == 3:
            display_instructions = False
            
            # Set the screen background
            screen.fill(BLACK)
            
      elif instruction_page == 1:
         # Draw instructions, page 1
         # This could also load an image created in another program.
         # That could be both easier and more flexible.
               
         text=font.render("Welcome to Spatial Recall: ", True, PURPLE)
         screen.blit(text, [10, 10])
         text=font.render("The game that tests your memory!!!", True, WHITE)
         screen.blit(text, [10, 50])
         
         text=mmfont.render("Click for instructions", True, RED)
         screen.blit(text, [40, 150])

         &lt;span style="color: Red;"&gt;pygame.display.update()
         screen.fill(BLACK)&lt;/span&gt;
      
      elif instruction_page == 2:
         # Draw instructions, page 2
         text=font.render("This is how the game goes: The", True, WHITE)
         screen.blit(text, [10, 10])
         
         text=font.render("computer is going to flash some green", True, WHITE)
         screen.blit(text, [10, 40])    
         
         text=font.render("boxes at random positions. It's", True, WHITE)
         screen.blit(text, [10, 70])       
         
         text=font.render("up to you to decide where you", True, WHITE)
         screen.blit(text, [10, 100]) 
         
         text=font.render("think they are hidden.", True, WHITE)
         screen.blit(text, [10, 130])  
         
         text=font.render("Good Luck!!.", True, PURPLE)
         screen.blit(text, [20, 180])          
         
         text=mmfont.render("PLAY GAME", True, RED)
         screen.blit(text, [120, 330])
         # Limit to 20 frames per second
         clock.tick(20)
         
         # Go ahead and update the screen with what we've drawn.
         pygame.display.flip()

&lt;/pre&gt; &lt;br /&gt;
&lt;br /&gt;
This is properly indented.&lt;br /&gt;
&lt;br /&gt;
Note: You can't do anything for the first 10 seconds or so&lt;br /&gt;
Also the text needs a update function i.e beneath the "Click for instructions" code(It's red). Plus according to my Python Shell pygame can't load wave files. &lt;br /&gt;
&lt;br /&gt;
Otherwise the code is fine apart from maybe needing a win animation&lt;br /&gt;
&lt;br /&gt;
P.S : Why were you doing this at 2am in the morning?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br&gt;&lt;br&gt;&lt;strong&gt;Attachment:&lt;/strong&gt; &lt;a href="http://www.programmersheaven.com/mb/DownloadAttachment.aspx?AttachmentID=2517"&gt;testing.py&lt;/a&gt; (6379 bytes | downloaded 50 times)</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/430979/430994/re-music-playing-but-screen-is-blank-pygame-help/#430994</guid>
      <pubDate>Sat, 19 Jan 2013 17:15:32 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Music Playing; But Screen Is Blank. Pygame Help!!!</title>
      <link>http://www.programmersheaven.com/mb/python/430979/430995/re-music-playing-but-screen-is-blank-pygame-help/#430995</link>
      <description>I noticed that the rectangles only appeared after I closed the program/broke the loop. I realised that you misindented your code &lt;br /&gt;
i.e &lt;pre class="sourcecode"&gt;# -------- Instruction Page Loop -----------
while done==False and display_instructions:
   
   for event in pygame.event.get(): # User did something
      
      if event.type == pygame.QUIT: # If user clicked close
         done=True # Flag that we are done so we exit this loop
         
      if event.type == pygame.MOUSEBUTTONDOWN:
            
         instruction_page += 1

         
      #instruction pages set    

&lt;hr /&gt;  
      if instruction_page == 3:
            display_instructions = False
            
            # Set the screen background
            screen.fill(BLACK)
            
      elif instruction_page == 1:
         # Draw instructions, page 1
         # This could also load an image created in another program.
         # That could be both easier and more flexible.
               
         text=font.render("Welcome to Spatial Recall: ", True, PURPLE)
         screen.blit(text, [10, 10])
         text=font.render("The game that tests your memory!!!", True, WHITE)
         screen.blit(text, [10, 50])
         
         text=mmfont.render("Click for instructions", True, RED)
         screen.blit(text, [40, 150])

         &lt;span style="color: Red;"&gt;pygame.display.update()
         screen.fill(BLACK)&lt;/span&gt;
      
      elif instruction_page == 2:
         # Draw instructions, page 2
         text=font.render("This is how the game goes: The", True, WHITE)
         screen.blit(text, [10, 10])
         
         text=font.render("computer is going to flash some green", True, WHITE)
         screen.blit(text, [10, 40])    
         
         text=font.render("boxes at random positions. It's", True, WHITE)
         screen.blit(text, [10, 70])       
         
         text=font.render("up to you to decide where you", True, WHITE)
         screen.blit(text, [10, 100]) 
         
         text=font.render("think they are hidden.", True, WHITE)
         screen.blit(text, [10, 130])  
         
         text=font.render("Good Luck!!.", True, PURPLE)
         screen.blit(text, [20, 180])          
         
         text=mmfont.render("PLAY GAME", True, RED)
         screen.blit(text, [120, 330])
         # Limit to 20 frames per second
         clock.tick(20)
         
         # Go ahead and update the screen with what we've drawn.
         pygame.display.flip()

&lt;/pre&gt; &lt;br /&gt;
&lt;br /&gt;
This is properly indented.&lt;br /&gt;
&lt;br /&gt;
Note: You can't do anything for the first 10 seconds or so&lt;br /&gt;
Also the text needs a update function i.e beneath the "Click for instructions" code(It's red). Plus according to my Python Shell pygame can't load wave files. &lt;br /&gt;
&lt;br /&gt;
Otherwise the code is fine apart from maybe needing a win animation&lt;br /&gt;
&lt;br /&gt;
P.S : Why were you doing this at 2am in the morning?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br&gt;&lt;br&gt;&lt;strong&gt;Attachment:&lt;/strong&gt; &lt;a href="http://www.programmersheaven.com/mb/DownloadAttachment.aspx?AttachmentID=2518"&gt;testing.py&lt;/a&gt; (6379 bytes | downloaded 31 times)</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/430979/430995/re-music-playing-but-screen-is-blank-pygame-help/#430995</guid>
      <pubDate>Sat, 19 Jan 2013 17:18:52 -0700</pubDate>
      <category>Python</category>
    </item>
  </channel>
</rss>