4 Replies - 378 Views - Last Post: 24 October 2013 - 10:21 AM Rate Topic: -----

#1 infamouslyuseless  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 29-September 13

Asteroids Game Updating It Not Working

Posted 02 October 2013 - 11:31 AM

I'm working on updating the Asteroids game that I made. I'm using Python 3.3.2, and I'm using the pygame and livewires modules. I set the screen using livewires, and now I want to make it so that the game doesn't start straight away, instead, it displays a message on the screen "Hit '1' To Begin" and if you hit '1'(not literally hit...) then the game starts.
I have a few hundred lines of code in the whole program, so I'll only put in the important part, the main function, which starts the game, and the begin function, which has the message, then calling the begin function:

def main():
    games.mouse.is_visible = False
    asteroids = Game()
    asteroids.play()

def begin():
    bg = games.load_image("bg.jpg")
    games.screen.background = bg
    beginning = games.Message(value = "Hit '1' To Begin",
                            size = 50,
                            color = color.red,
                            x = games.screen.width/2,
                            y = games.screen.height/2,
                            lifetime = 100 * games.screen.fps,
                            is_collideable = False)
    games.screen.add(beginning)
    
    while True:
        if games.keyboard.is_pressed(games.K_1):
            main()
        elif games.keyboard.is_pressed(games.K_ESCAPE):
            sys.exit()
            
begin()


What happens is that when I run it, it loads the right background, but then it freezes, and then doesn't respond, and I'm really stuck

Is This A Good Question/Topic? 0
  • +

Replies To: Asteroids Game Updating It Not Working

#2 jakobt  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 7
  • Joined: 21-March 11

Re: Asteroids Game Updating It Not Working

Posted 22 October 2013 - 09:46 AM

It looks ok to me, maybe post your play() function and we can see if that is causing your freeze.
Was This Post Helpful? 0
  • +
  • -

#3 infamouslyuseless  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 29-September 13

Re: Asteroids Game Updating It Not Working

Posted 24 October 2013 - 05:24 AM

View Postjakobt, on 22 October 2013 - 09:46 AM, said:

It looks ok to me, maybe post your play() function and we can see if that is causing your freeze.

The function is main()not play()
Was This Post Helpful? 0
  • +
  • -

#4 infamouslyuseless  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 29-September 13

Re: Asteroids Game Updating It Not Working

Posted 24 October 2013 - 06:03 AM

View Postjakobt, on 22 October 2013 - 09:46 AM, said:

It looks ok to me, maybe post your play() function and we can see if that is causing your freeze.

Was This Post Helpful? 0
  • +
  • -

#5 infamouslyuseless  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 29-September 13

Re: Asteroids Game Updating It Not Working

Posted 24 October 2013 - 10:21 AM

View Postjakobt, on 22 October 2013 - 09:46 AM, said:

It looks ok to me, maybe post your play() function and we can see if that is causing your freeze.

sorry, ignore that reply, i found it:
          def play(self):
                """ Play the game. """
                # begin theme music
                games.music.load("theme.wav")
                games.music.play(-1)
        
                # load and set background
                bg = games.load_image("bg.jpg")
                games.screen.background = bg
        
                # advance to level 1
                self.advance()
        
                # start play
                games.screen.mainloop()


this is the play() function, which is part of a class called Game(), which, along with another lot of classes, is part of a big while loop. i can give you a link to the whole source code if you like?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1