Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Thumbs up Word Guessing Game

    Hi I am making a word guessing game. I made a menu with buttons and then added a custom cursor but when I added the cursor the menu went away and now the only thing that comes up is the cursor and a black screen. I don't know how to get the menu to come up.

    I added a .zip of the game with the menu images and everything, and I will include the code.
    import sys, os, pygame
    screenSize = (500, 500)
    def Mouse():
    	mouseLoop = True
    	cursorSize = (20, 20)
    	while mouseLoop:
    		screen = pygame.display.set_mode((screenSize), 0, 32)
    		cursor = pygame.mouse.set_visible(False)
    		cursor = pygame.image.load("cursor.png").convert_alpha()
    		cursor = pygame.transform.scale(cursor, (30, 30))#Resize Image.
    		cursor_x, cursor_y = pygame.mouse.get_pos()
    		cursor_x -= cursor.get_width()/2
    		cursor_y -= cursor.get_height()/2
    		screen.blit(cursor, (cursor_x, cursor_y))
    def startScreen():
    	s_color = (0, 0, 100)
    	loop = True
    	pygame.display.set_caption("Game Guess") #Set window Caption.
    	screen = pygame.display.set_mode((screenSize))
    	s_text = pygame.font.Font(None, 100)
    	text = s_text.render("Game Guess", True, (100,20, 50))
    	buttonStart = pygame.image.load("buttonStart.png")
    	buttonExit = pygame.image.load("buttonExit.png")
    	screen.blit(buttonStart, (100, 300))
    	screen.blit(buttonExit, (330, 300))
    	screen.blit(text, [40, 100])
    	#while loop:
    	#	for event in pygame.event.get():
    	#		if event.type == MOUSEBUTTONDOWN:
    	#			pygame.display.update()
    Attached Files Attached Files
    Last edited by awesomepilot; 03-25-2014 at 05:34 AM. Reason: mis type

  2. #2
    Just Joined! mrbruno's Avatar
    Join Date
    Jan 2013
    I don't know anything about the pygame package and haven't even done anything with threading in python but what strikes me is that you have the loop in Mouse() with a control variable (mouseLoop) which is never changed. You'll never get to the call to startScreen() until the loop finishes and it never finishes the way you have it.

    Also, what's StartScreen()? Is it a typo for startScreen()?? If so, why do you call that method twice?

    I suspect you want one call to startScreen() and you need to run the Mouse method in some kind of thread. Infinite loops inside of a thread are not unusual at all. Although you might want to consider sleeping or yielding the CPU inside the loop to give your other thread(s) a fair chance to run. Just my opinion!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts