Python

Moderators: None (Apply to moderate this forum)
Number of threads: 474
Number of posts: 1166

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Re: Music Playing; But Screen Is Blank. Pygame Help!!! Posted by me0wcat on 19 Jan 2013 at 5:13 PM
I noticed that the rectangles only appeared after I closed the program/broke the loop. I realised that you misindented your code
i.e
# -------- 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    


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]) pygame.display.update() screen.fill(BLACK) 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()


This is properly indented.

Note: You can't do anything for the first 10 seconds or so
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.

Otherwise the code is fine apart from maybe needing a win animation

P.S : Why were you doing this at 2am in the morning?


Edit: Strange, for some reason I posted 3 times.


Attachment: testing.py (6379 Bytes | downloaded 50 times)



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.