Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualK1NNY

Posted 12 October 2012 - 09:22 AM

<p>I&#39;m making a simulation game where you control a nation and watch as it progresses through the years and you can make decisions when certain things happen.<br />
<br />
I basically have a while loop to handle the main part of the game (which is normal, i think). But in my while loop i have it set to where when a variable reaches a certain point, it goes to another while loop handling a seperate part of the game that gives you two options (to help your nation out or not). This works perfectly except that in this second while loop, i&#39;m trying to make it where once the user chooses an option it will go back to the first while loop, making the changes the user selected and run the same way it did before.<br />
<br />
The problem i&#39;m having is that the program doesn&#39;t seem to even pick up the user hitting the key, it doesn&#39;t hang or close, it just sits there running the second while loop.<br />
<br />
Here is the two while loops (i can add the whole code if needed, but its pretty big and would take up a lot of space):<br />
<br />
[source lang=&quot;python&quot;]#################################Game loop##################################<br />elect_new = False<br /><br /><br />while game:<br /> x = random.randint(1, 10)<br /> y = random.randint(1, 3)<br /><br /> <br /> <br /> show_year = fontObj1.render(str(year), True, BLACK)<br /> show_pop = fontObj1.render(str(pop), True, BLACK)<br /> <br /><br /> DISPLAY.blit(gbg, (0, 0))<br /> DISPLAY.blit(controls_1, (225, 50))<br /> DISPLAY.blit(controls_2, (225, 66))<br /> DISPLAY.blit(controls_3, (225, 82))<br /> DISPLAY.blit(controls_4, (225, 100))<br /><br /> <br /> for event in pygame.event.get():<br /><br /> #the pplrty determiner<br /> if event.type == pygame.KEYDOWN:<br /> if event.key == pygame.K_RETURN:<br /> year += 1<br /><br /> DISPLAY.blit(show_year, (563, 400))<br /> DISPLAY.blit(show_pop, (400, 400))<br /> <br /> if x == 1:<br /> DISPLAY.blit(events_1, (45, 50))<br /> DISPLAY.blit(events_1_2, (45, 66))<br /> DISPLAY.blit(events_1_3, (45, 82))<br /> p += 2<br /> if x == 2:<br /> DISPLAY.blit(events_2, (45, 50))<br /> DISPLAY.blit(events_2_2, (45, 66))<br /> DISPLAY.blit(events_2_3, (45, 82))<br /> p -= 2<br /> if x == 3:<br /> DISPLAY.blit(events_3, (45, 50))<br /> DISPLAY.blit(events_3_2, (45, 66))<br /> DISPLAY.blit(events_3_3, (45, 82))<br /> p -= 3<br /> if x == 4:<br /> DISPLAY.blit(events_4, (45, 50))<br /> DISPLAY.blit(events_4_2, (45, 66))<br /> DISPLAY.blit(events_4_3, (45, 82))<br /> DISPLAY.blit(events_4_4, (45, 98))<br /> DISPLAY.blit(events_4_5, (45, 114))<br /> DISPLAY.blit(events_4_6, (45, 130))<br /> p -= 5<br /> if x == 5:<br /> DISPLAY.blit(events_5, (45, 50))<br /> DISPLAY.blit(events_5_2, (45, 66))<br /> p -= 5<br /> if x == 6:<br /> DISPLAY.blit(events_6, (45, 50))<br /> DISPLAY.blit(events_6_2, (45, 66))<br /> DISPLAY.blit(events_6_3, (45, 82))<br /> DISPLAY.blit(events_6_4, (45, 98))<br /> DISPLAY.blit(events_6_5, (45, 114))<br /> p -= 4<br /> if x == 7:<br /> DISPLAY.blit(events_7, (45, 50))<br /> DISPLAY.blit(events_7_2, (45, 66))<br /> DISPLAY.blit(events_7_3, (45, 82))<br /> DISPLAY.blit(events_7_4, (45, 98))<br /> p -= 4<br /> if x == 8:<br /> DISPLAY.blit(events_8, (45, 50))<br /> DISPLAY.blit(events_8_2, (45, 66))<br /> p -= 2<br /> if x == 9:<br /> DISPLAY.blit(events_9, (45, 50))<br /> DISPLAY.blit(events_9_2, (45, 66))<br /> DISPLAY.blit(events_9_3, (45, 82))<br /> DISPLAY.blit(events_9_4, (45, 98))<br /> p -= 6<br /> if x == 10:<br /> DISPLAY.blit(events_10, (45, 50))<br /> DISPLAY.blit(events_10_2, (45, 66))<br /> DISPLAY.blit(events_10_3, (45, 82))<br /> p += 0<br /> <br /> if p &gt;= 50 and p &lt; 60:<br /> DISPLAY.blit(pplrty_decent, (225, 400))<br /> elif p &gt;= 60 and p &lt; 85:<br /> DISPLAY.blit(pplrty_good, (230, 400))<br /> elif p &gt;= 85 and p &lt;= 100:<br /> DISPLAY.blit(pplrty_great, (230, 400))<br /> elif p &gt;= 25 and p &lt; 50:<br /> DISPLAY.blit(pplrty_bad, (225, 400))<br /> elif p &lt; 25:<br /> DISPLAY.blit(pplrty_awful, (225, 400))<br /> <br /> pygame.display.update()<br /> <br /> if event.type == QUIT:<br /> pygame.quit()<br /> sys.exit()<br />[/source]</p>
<p> </p>
<p>It wouldn&#39;t let me put i into one code segment so here it is continued:</p>
<pre>
[source lang=&quot;python&quot;] #this is where i handle whether the loop needs to break and move on #to the &quot;elect_new&quot; loop if p &lt;= 15 and y == 1: game = False elect_new = Truewhile elect_new: DISPLAY.blit(help_bg, (0, 0)) DISPLAY.blit(elect_1, (165, 75)) DISPLAY.blit(elect_2, (165, 93)) DISPLAY.blit(elect_3, (165, 111)) DISPLAY.blit(yes, (285, 350)) DISPLAY.blit(no, (335, 350)) DISPLAY.blit(under, (285, 350)) DISPLAY.blit(under, (335, 350)) pygame.display.update() for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_y: p += 30 elect_new = False game = True if event.type == QUIT: pygame.quit() sys.exit() pygame.display.update()[/source]</pre>

#7K1NNY

Posted 12 October 2012 - 09:04 AM

<p>I&#39;m making a simulation game where you control a nation and watch as it progresses through the years and you can make decisions when certain things happen.<br />
<br />
I basically have a while loop to handle the main part of the game (which is normal, i think). But in my while loop i have it set to where when a variable reaches a certain point, it goes to another while loop handling a seperate part of the game that gives you two options (to help your nation out or not). This works perfectly except that in this second while loop, i&#39;m trying to make it where once the user chooses an option it will go back to the first while loop, making the changes the user selected and run the same way it did before.<br />
<br />
The problem i&#39;m having is that the program doesn&#39;t seem to even pick up the user hitting the key, it doesn&#39;t hang or close, it just sits there running the second while loop.<br />
<br />
Here is the two while loops (i can add the whole code if needed, but its pretty big and would take up a lot of space):<br />
<br />
[source lang=&quot;python&quot;]#################################Game loop##################################<br />elect_new = False<br /><br /><br />while game:<br />    x = random.randint(1, 10)<br />    y = random.randint(1, 3)<br /><br />    <br />    <br />    show_year = fontObj1.render(str(year), True, BLACK)<br />    show_pop = fontObj1.render(str(pop), True, BLACK)<br />    <br /><br />    DISPLAY.blit(gbg, (0, 0))<br />    DISPLAY.blit(controls_1, (225, 50))<br />    DISPLAY.blit(controls_2, (225, 66))<br />    DISPLAY.blit(controls_3, (225, 82))<br />    DISPLAY.blit(controls_4, (225, 100))<br /><br />    <br />    for event in pygame.event.get():<br /><br />        #the pplrty determiner<br />        if event.type == pygame.KEYDOWN:<br />            if event.key == pygame.K_RETURN:<br />                year += 1<br /><br />                DISPLAY.blit(show_year, (563, 400))<br />                DISPLAY.blit(show_pop, (400, 400))<br />                <br />                if x == 1:<br />                    DISPLAY.blit(events_1, (45, 50))<br />                    DISPLAY.blit(events_1_2, (45, 66))<br />                    DISPLAY.blit(events_1_3, (45, 82))<br />                    p += 2<br />                if x == 2:<br />                    DISPLAY.blit(events_2, (45, 50))<br />                    DISPLAY.blit(events_2_2, (45, 66))<br />                    DISPLAY.blit(events_2_3, (45, 82))<br />                    p -= 2<br />                if x == 3:<br />                    DISPLAY.blit(events_3, (45, 50))<br />                    DISPLAY.blit(events_3_2, (45, 66))<br />                    DISPLAY.blit(events_3_3, (45, 82))<br />                    p -= 3<br />                if x == 4:<br />                    DISPLAY.blit(events_4, (45, 50))<br />                    DISPLAY.blit(events_4_2, (45, 66))<br />                    DISPLAY.blit(events_4_3, (45, 82))<br />                    DISPLAY.blit(events_4_4, (45, 98))<br />                    DISPLAY.blit(events_4_5, (45, 114))<br />                    DISPLAY.blit(events_4_6, (45, 130))<br />                    p -= 5<br />                if x == 5:<br />                    DISPLAY.blit(events_5, (45, 50))<br />                    DISPLAY.blit(events_5_2, (45, 66))<br />                    p -= 5<br />                if x == 6:<br />                    DISPLAY.blit(events_6, (45, 50))<br />                    DISPLAY.blit(events_6_2, (45, 66))<br />                    DISPLAY.blit(events_6_3, (45, 82))<br />                    DISPLAY.blit(events_6_4, (45, 98))<br />                    DISPLAY.blit(events_6_5, (45, 114))<br />                    p -= 4<br />                if x == 7:<br />                    DISPLAY.blit(events_7, (45, 50))<br />                    DISPLAY.blit(events_7_2, (45, 66))<br />                    DISPLAY.blit(events_7_3, (45, 82))<br />                    DISPLAY.blit(events_7_4, (45, 98))<br />                    p -= 4<br />                if x == 8:<br />                    DISPLAY.blit(events_8, (45, 50))<br />                    DISPLAY.blit(events_8_2, (45, 66))<br />                    p -= 2<br />                if x == 9:<br />                    DISPLAY.blit(events_9, (45, 50))<br />                    DISPLAY.blit(events_9_2, (45, 66))<br />                    DISPLAY.blit(events_9_3, (45, 82))<br />                    DISPLAY.blit(events_9_4, (45, 98))<br />                    p -= 6<br />                if x == 10:<br />                    DISPLAY.blit(events_10, (45, 50))<br />                    DISPLAY.blit(events_10_2, (45, 66))<br />                    DISPLAY.blit(events_10_3, (45, 82))<br />                    p += 0<br />    <br />                if p &gt;= 50 and p &lt; 60:<br />                    DISPLAY.blit(pplrty_decent, (225, 400))<br />                elif p &gt;= 60 and p &lt; 85:<br />                    DISPLAY.blit(pplrty_good, (230, 400))<br />                elif p &gt;= 85 and p &lt;= 100:<br />                    DISPLAY.blit(pplrty_great, (230, 400))<br />                elif p &gt;= 25 and p &lt; 50:<br />                    DISPLAY.blit(pplrty_bad, (225, 400))<br />                elif p &lt; 25:<br />                    DISPLAY.blit(pplrty_awful, (225, 400))<br />                <br />                pygame.display.update()<br />          <br />        if event.type == QUIT:<br />                pygame.quit()<br />                sys.exit()<br />[/source]</p>
<p> </p>
<p>It wouldn&#39;t let me put i into one code segment so here it is continued:</p>
<pre>
[source lang=&quot;python&quot;] #this is where i handle whether the loop needs to break and move on #to the &quot;elect_new&quot; loop if p &lt;= 15 and y == 1:  game = False  elect_new = True elif p &lt;= 15 and y == 2:  game = False  lower_int = True elif p &lt;= 15 and y == 3:  game = False  cut_taxes = Truewhile elect_new: DISPLAY.blit(help_bg, (0, 0)) DISPLAY.blit(elect_1, (165, 75)) DISPLAY.blit(elect_2, (165, 93)) DISPLAY.blit(elect_3, (165, 111)) DISPLAY.blit(yes, (285, 350)) DISPLAY.blit(no, (335, 350)) DISPLAY.blit(under, (285, 350)) DISPLAY.blit(under, (335, 350)) pygame.display.update() for event in pygame.event.get():  if event.type == pygame.KEYDOWN:   if event.key == pygame.K_y:    p += 30    elect_new = False    game = True      if event.type == QUIT:   pygame.quit()   sys.exit() pygame.display.update()[/source]</pre>

#6K1NNY

Posted 12 October 2012 - 09:02 AM

I'm making a simulation game where you control a nation and watch as it progresses through the years and you can make decisions when certain things happen.

I basically have a while loop to handle the main part of the game (which is normal, i think). But in my while loop i have it set to where when a variable reaches a certain point, it goes to another while loop handling a seperate part of the game that gives you two options (to help your nation out or not). This works perfectly except that in this second while loop, i'm trying to make it where once the user chooses an option it will go back to the first while loop, making the changes the user selected and run the same way it did before.

The problem i'm having is that the program doesn't seem to even pick up the user hitting the key, it doesn't hang or close, it just sits there running the second while loop.

Here is the two while loops (i can add the whole code if needed, but its pretty big and would take up a lot of space):

[source lang="python"]#################################Game loop##################################elect_new = Falsewhile game: x = random.randint(1, 10) y = random.randint(1, 3) show_year = fontObj1.render(str(year), True, BLACK) show_pop = fontObj1.render(str(pop), True, BLACK) DISPLAY.blit(gbg, (0, 0)) DISPLAY.blit(controls_1, (225, 50)) DISPLAY.blit(controls_2, (225, 66)) DISPLAY.blit(controls_3, (225, 82)) DISPLAY.blit(controls_4, (225, 100)) for event in pygame.event.get(): #the pplrty determiner if event.type == pygame.KEYDOWN: if event.key == pygame.K_RETURN: year += 1 DISPLAY.blit(show_year, (563, 400)) DISPLAY.blit(show_pop, (400, 400)) if x == 1: DISPLAY.blit(events_1, (45, 50)) DISPLAY.blit(events_1_2, (45, 66)) DISPLAY.blit(events_1_3, (45, 82)) p += 2 if x == 2: DISPLAY.blit(events_2, (45, 50)) DISPLAY.blit(events_2_2, (45, 66)) DISPLAY.blit(events_2_3, (45, 82)) p -= 2 if x == 3: DISPLAY.blit(events_3, (45, 50)) DISPLAY.blit(events_3_2, (45, 66)) DISPLAY.blit(events_3_3, (45, 82)) p -= 3 if x == 4: DISPLAY.blit(events_4, (45, 50)) DISPLAY.blit(events_4_2, (45, 66)) DISPLAY.blit(events_4_3, (45, 82)) DISPLAY.blit(events_4_4, (45, 98)) DISPLAY.blit(events_4_5, (45, 114)) DISPLAY.blit(events_4_6, (45, 130)) p -= 5 if x == 5: DISPLAY.blit(events_5, (45, 50)) DISPLAY.blit(events_5_2, (45, 66)) p -= 5 if x == 6: DISPLAY.blit(events_6, (45, 50)) DISPLAY.blit(events_6_2, (45, 66)) DISPLAY.blit(events_6_3, (45, 82)) DISPLAY.blit(events_6_4, (45, 98)) DISPLAY.blit(events_6_5, (45, 114)) p -= 4 if x == 7: DISPLAY.blit(events_7, (45, 50)) DISPLAY.blit(events_7_2, (45, 66)) DISPLAY.blit(events_7_3, (45, 82)) DISPLAY.blit(events_7_4, (45, 98)) p -= 4 if x == 8: DISPLAY.blit(events_8, (45, 50)) DISPLAY.blit(events_8_2, (45, 66)) p -= 2 if x == 9: DISPLAY.blit(events_9, (45, 50)) DISPLAY.blit(events_9_2, (45, 66)) DISPLAY.blit(events_9_3, (45, 82)) DISPLAY.blit(events_9_4, (45, 98)) p -= 6 if x == 10: DISPLAY.blit(events_10, (45, 50)) DISPLAY.blit(events_10_2, (45, 66)) DISPLAY.blit(events_10_3, (45, 82)) p += 0 if p >= 50 and p < 60: DISPLAY.blit(pplrty_decent, (225, 400)) elif p >= 60 and p < 85: DISPLAY.blit(pplrty_good, (230, 400)) elif p >= 85 and p <= 100: DISPLAY.blit(pplrty_great, (230, 400)) elif p >= 25 and p < 50: DISPLAY.blit(pplrty_bad, (225, 400)) elif p < 25: DISPLAY.blit(pplrty_awful, (225, 400)) pygame.display.update() if event.type == QUIT: pygame.quit() sys.exit()[/source]

#5K1NNY

Posted 12 October 2012 - 09:02 AM

I'm making a simulation game where you control a nation and watch as it progresses through the years and you can make decisions when certain things happen.

I basically have a while loop to handle the main part of the game (which is normal, i think). But in my while loop i have it set to where when a variable reaches a certain point, it goes to another while loop handling a seperate part of the game that gives you two options (to help your nation out or not). This works perfectly except that in this second while loop, i'm trying to make it where once the user chooses an option it will go back to the first while loop, making the changes the user selected and run the same way it did before.

The problem i'm having is that the program doesn't seem to even pick up the user hitting the key, it doesn't hang or close, it just sits there running the second while loop.

Here is the two while loops (i can add the whole code if needed, but its pretty big and would take up a lot of space):

[source lang="python"]#################################Game loop##################################elect_new = Falsewhile game: x = random.randint(1, 10) y = random.randint(1, 3) show_year = fontObj1.render(str(year), True, BLACK) show_pop = fontObj1.render(str(pop), True, BLACK) DISPLAY.blit(gbg, (0, 0)) DISPLAY.blit(controls_1, (225, 50)) DISPLAY.blit(controls_2, (225, 66)) DISPLAY.blit(controls_3, (225, 82)) DISPLAY.blit(controls_4, (225, 100)) for event in pygame.event.get(): #the pplrty determiner if event.type == pygame.KEYDOWN: if event.key == pygame.K_RETURN: year += 1 DISPLAY.blit(show_year, (563, 400)) DISPLAY.blit(show_pop, (400, 400)) if x == 1: DISPLAY.blit(events_1, (45, 50)) DISPLAY.blit(events_1_2, (45, 66)) DISPLAY.blit(events_1_3, (45, 82)) p += 2 if x == 2: DISPLAY.blit(events_2, (45, 50)) DISPLAY.blit(events_2_2, (45, 66)) DISPLAY.blit(events_2_3, (45, 82)) p -= 2 if x == 3: DISPLAY.blit(events_3, (45, 50)) DISPLAY.blit(events_3_2, (45, 66)) DISPLAY.blit(events_3_3, (45, 82)) p -= 3 if x == 4: DISPLAY.blit(events_4, (45, 50)) DISPLAY.blit(events_4_2, (45, 66)) DISPLAY.blit(events_4_3, (45, 82)) DISPLAY.blit(events_4_4, (45, 98)) DISPLAY.blit(events_4_5, (45, 114)) DISPLAY.blit(events_4_6, (45, 130)) p -= 5 if x == 5: DISPLAY.blit(events_5, (45, 50)) DISPLAY.blit(events_5_2, (45, 66)) p -= 5 if x == 6: DISPLAY.blit(events_6, (45, 50)) DISPLAY.blit(events_6_2, (45, 66)) DISPLAY.blit(events_6_3, (45, 82)) DISPLAY.blit(events_6_4, (45, 98)) DISPLAY.blit(events_6_5, (45, 114)) p -= 4 if x == 7: DISPLAY.blit(events_7, (45, 50)) DISPLAY.blit(events_7_2, (45, 66)) DISPLAY.blit(events_7_3, (45, 82)) DISPLAY.blit(events_7_4, (45, 98)) p -= 4 if x == 8: DISPLAY.blit(events_8, (45, 50)) DISPLAY.blit(events_8_2, (45, 66)) p -= 2 if x == 9: DISPLAY.blit(events_9, (45, 50)) DISPLAY.blit(events_9_2, (45, 66)) DISPLAY.blit(events_9_3, (45, 82)) DISPLAY.blit(events_9_4, (45, 98)) p -= 6 if x == 10: DISPLAY.blit(events_10, (45, 50)) DISPLAY.blit(events_10_2, (45, 66)) DISPLAY.blit(events_10_3, (45, 82)) p += 0 if p >= 50 and p < 60: DISPLAY.blit(pplrty_decent, (225, 400)) elif p >= 60 and p < 85: DISPLAY.blit(pplrty_good, (230, 400)) elif p >= 85 and p <= 100: DISPLAY.blit(pplrty_great, (230, 400)) elif p >= 25 and p < 50: DISPLAY.blit(pplrty_bad, (225, 400)) elif p < 25: DISPLAY.blit(pplrty_awful, (225, 400)) pygame.display.update() if event.type == QUIT: pygame.quit() sys.exit()[/source]

#4K1NNY

Posted 12 October 2012 - 09:01 AM

I'm making a simulation game where you control a nation and watch as it progresses through the years and you can make decisions when certain things happen.

I basically have a while loop to handle the main part of the game (which is normal, i think). But in my while loop i have it set to where when a variable reaches a certain point, it goes to another while loop handling a seperate part of the game that gives you two options (to help your nation out or not). This works perfectly except that in this second while loop, i'm trying to make it where once the user chooses an option it will go back to the first while loop, making the changes the user selected and run the same way it did before.

The problem i'm having is that the program doesn't seem to even pick up the user hitting the key, it doesn't hang or close, it just sits there running the second while loop.

Here is the two while loops (i can add the whole code if needed, but its pretty big and would take up a lot of space):

[source lang="python"]#################################Game loop##################################elect_new = Falsewhile game: x = random.randint(1, 10) y = random.randint(1, 3) show_year = fontObj1.render(str(year), True, BLACK) show_pop = fontObj1.render(str(pop), True, BLACK) DISPLAY.blit(gbg, (0, 0)) DISPLAY.blit(controls_1, (225, 50)) DISPLAY.blit(controls_2, (225, 66)) DISPLAY.blit(controls_3, (225, 82)) DISPLAY.blit(controls_4, (225, 100)) for event in pygame.event.get(): #the pplrty determiner if event.type == pygame.KEYDOWN: if event.key == pygame.K_RETURN: year += 1 DISPLAY.blit(show_year, (563, 400)) DISPLAY.blit(show_pop, (400, 400)) if x == 1: DISPLAY.blit(events_1, (45, 50)) DISPLAY.blit(events_1_2, (45, 66)) DISPLAY.blit(events_1_3, (45, 82)) p += 2 if x == 2: DISPLAY.blit(events_2, (45, 50)) DISPLAY.blit(events_2_2, (45, 66)) DISPLAY.blit(events_2_3, (45, 82)) p -= 2 if x == 3: DISPLAY.blit(events_3, (45, 50)) DISPLAY.blit(events_3_2, (45, 66)) DISPLAY.blit(events_3_3, (45, 82)) p -= 3 if x == 4: DISPLAY.blit(events_4, (45, 50)) DISPLAY.blit(events_4_2, (45, 66)) DISPLAY.blit(events_4_3, (45, 82)) DISPLAY.blit(events_4_4, (45, 98)) DISPLAY.blit(events_4_5, (45, 114)) DISPLAY.blit(events_4_6, (45, 130)) p -= 5 if x == 5: DISPLAY.blit(events_5, (45, 50)) DISPLAY.blit(events_5_2, (45, 66)) p -= 5 if x == 6: DISPLAY.blit(events_6, (45, 50)) DISPLAY.blit(events_6_2, (45, 66)) DISPLAY.blit(events_6_3, (45, 82)) DISPLAY.blit(events_6_4, (45, 98)) DISPLAY.blit(events_6_5, (45, 114)) p -= 4 if x == 7: DISPLAY.blit(events_7, (45, 50)) DISPLAY.blit(events_7_2, (45, 66)) DISPLAY.blit(events_7_3, (45, 82)) DISPLAY.blit(events_7_4, (45, 98)) p -= 4 if x == 8: DISPLAY.blit(events_8, (45, 50)) DISPLAY.blit(events_8_2, (45, 66)) p -= 2 if x == 9: DISPLAY.blit(events_9, (45, 50)) DISPLAY.blit(events_9_2, (45, 66)) DISPLAY.blit(events_9_3, (45, 82)) DISPLAY.blit(events_9_4, (45, 98)) p -= 6 if x == 10: DISPLAY.blit(events_10, (45, 50)) DISPLAY.blit(events_10_2, (45, 66)) DISPLAY.blit(events_10_3, (45, 82)) p += 0 if p >= 50 and p < 60: DISPLAY.blit(pplrty_decent, (225, 400)) elif p >= 60 and p < 85: DISPLAY.blit(pplrty_good, (230, 400)) elif p >= 85 and p <= 100: DISPLAY.blit(pplrty_great, (230, 400)) elif p >= 25 and p < 50: DISPLAY.blit(pplrty_bad, (225, 400)) elif p < 25: DISPLAY.blit(pplrty_awful, (225, 400)) pygame.display.update() if event.type == QUIT: pygame.quit() sys.exit()[/source]

#3K1NNY

Posted 12 October 2012 - 09:00 AM

I'm making a simulation game where you control a nation and watch as it progresses through the years and you can make decisions when certain things happen.

I basically have a while loop to handle the main part of the game (which is normal, i think). But in my while loop i have it set to where when a variable reaches a certain point, it goes to another while loop handling a seperate part of the game that gives you two options (to help your nation out or not). This works perfectly except that in this second while loop, i'm trying to make it where once the user chooses an option it will go back to the first while loop, making the changes the user selected and run the same way it did before.

The problem i'm having is that the program doesn't seem to even pick up the user hitting the key, it doesn't hang or close, it just sits there running the second while loop.

Here is the two while loops (i can add the whole code if needed, but its pretty big and would take up a lot of space):

[source lang="python"]#################################Game loop##################################elect_new = Falsewhile game: x = random.randint(1, 10) y = random.randint(1, 3) show_year = fontObj1.render(str(year), True, BLACK) show_pop = fontObj1.render(str(pop), True, BLACK) DISPLAY.blit(gbg, (0, 0)) DISPLAY.blit(controls_1, (225, 50)) DISPLAY.blit(controls_2, (225, 66)) DISPLAY.blit(controls_3, (225, 82)) DISPLAY.blit(controls_4, (225, 100)) for event in pygame.event.get(): #the pplrty determiner if event.type == pygame.KEYDOWN: if event.key == pygame.K_RETURN: year += 1 DISPLAY.blit(show_year, (563, 400)) DISPLAY.blit(show_pop, (400, 400)) if x == 1: DISPLAY.blit(events_1, (45, 50)) DISPLAY.blit(events_1_2, (45, 66)) DISPLAY.blit(events_1_3, (45, 82)) p += 2 if x == 2: DISPLAY.blit(events_2, (45, 50)) DISPLAY.blit(events_2_2, (45, 66)) DISPLAY.blit(events_2_3, (45, 82)) p -= 2 if x == 3: DISPLAY.blit(events_3, (45, 50)) DISPLAY.blit(events_3_2, (45, 66)) DISPLAY.blit(events_3_3, (45, 82)) p -= 3 if x == 4: DISPLAY.blit(events_4, (45, 50)) DISPLAY.blit(events_4_2, (45, 66)) DISPLAY.blit(events_4_3, (45, 82)) DISPLAY.blit(events_4_4, (45, 98)) DISPLAY.blit(events_4_5, (45, 114)) DISPLAY.blit(events_4_6, (45, 130)) p -= 5 if x == 5: DISPLAY.blit(events_5, (45, 50)) DISPLAY.blit(events_5_2, (45, 66)) p -= 5 if x == 6: DISPLAY.blit(events_6, (45, 50)) DISPLAY.blit(events_6_2, (45, 66)) DISPLAY.blit(events_6_3, (45, 82)) DISPLAY.blit(events_6_4, (45, 98)) DISPLAY.blit(events_6_5, (45, 114)) p -= 4 if x == 7: DISPLAY.blit(events_7, (45, 50)) DISPLAY.blit(events_7_2, (45, 66)) DISPLAY.blit(events_7_3, (45, 82)) DISPLAY.blit(events_7_4, (45, 98)) p -= 4 if x == 8: DISPLAY.blit(events_8, (45, 50)) DISPLAY.blit(events_8_2, (45, 66)) p -= 2 if x == 9: DISPLAY.blit(events_9, (45, 50)) DISPLAY.blit(events_9_2, (45, 66)) DISPLAY.blit(events_9_3, (45, 82)) DISPLAY.blit(events_9_4, (45, 98)) p -= 6 if x == 10: DISPLAY.blit(events_10, (45, 50)) DISPLAY.blit(events_10_2, (45, 66)) DISPLAY.blit(events_10_3, (45, 82)) p += 0 if p >= 50 and p < 60: DISPLAY.blit(pplrty_decent, (225, 400)) elif p >= 60 and p < 85: DISPLAY.blit(pplrty_good, (230, 400)) elif p >= 85 and p <= 100: DISPLAY.blit(pplrty_great, (230, 400)) elif p >= 25 and p < 50: DISPLAY.blit(pplrty_bad, (225, 400)) elif p < 25: DISPLAY.blit(pplrty_awful, (225, 400)) pygame.display.update() if event.type == QUIT: pygame.quit() sys.exit() #this is where i handle whether the loop needs to break and move on #to the "elect_new" loop if p <= 15 and y == 1: game = False elect_new = True elif p <= 15 and y == 2: game = False lower_int = True elif p <= 15 and y == 3: game = False cut_taxes = Truewhile elect_new: DISPLAY.blit(help_bg, (0, 0)) DISPLAY.blit(elect_1, (165, 75)) DISPLAY.blit(elect_2, (165, 93)) DISPLAY.blit(elect_3, (165, 111)) DISPLAY.blit(yes, (285, 350)) DISPLAY.blit(no, (335, 350)) DISPLAY.blit(under, (285, 350)) DISPLAY.blit(under, (335, 350)) pygame.display.update() for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_y: p += 30 elect_new = False game = True if event.type == QUIT: pygame.quit() sys.exit() pygame.display.update()[/source]

PARTNERS