@@ -1622,7 +1622,7 @@ def updateMonsters():
16221622 # Clear the current message so the screen looks a little less cluttered
16231623 curMsg = ""
16241624 drawGame ()
1625- # Free all the memory we can and print some game info
1625+
16261626
16271627 thumby .display .fill (0 )
16281628 thumby .display .drawText ("You died!" , 0 , 0 , 1 )
@@ -1632,38 +1632,30 @@ def updateMonsters():
16321632 thumby .display .drawText ("floor " + str (floorNo ), 0 , 32 , 1 )
16331633 thumby .display .update ()
16341634
1635- currentRoom .tiles .clear ()
1636- gc_collect ()
1637-
1638- while (getcharinputNew () == ' ' ):
1635+ while (not thumby .actionPressed ()):
16391636 pass
16401637
1641- while (swBstate == 1 ):
1642- getcharinputNew ()
1643-
1644- selpos = 0
1645- while (swBstate != 1 ):
1638+ select = 0
16461639 thumby .display .fill (0 )
16471640 thumby .display .drawText ("Restart?" , 0 , 8 , 1 )
1648- if (selpos == 0 ):
1649- thumby .display .drawFilledRectangle (0 , 16 , 24 , 8 , 1 )
1650- thumby .display .drawText ("yes" , 0 , 16 , 0 )
1651- thumby .display .drawText ("no" , 40 , 16 , 1 )
1652- else :
1653- thumby .display .drawText ("yes" , 0 , 16 , 1 )
1654- thumby .display .drawFilledRectangle (40 , 16 , 16 , 8 , 1 )
1655- thumby .display .drawText ("no" , 40 , 16 , 0 )
1641+ thumby .actionJustPressed () # Debounce
1642+ while (not thumby .actionJustPressed ()):
1643+ thumby .display .drawFilledRectangle (0 , 16 , 24 , 8 , 1 - select )
1644+ thumby .display .drawText ("yes" , 0 , 16 , select )
1645+ thumby .display .drawFilledRectangle (40 , 16 , 16 , 8 , select )
1646+ thumby .display .drawText ("no" , 40 , 16 , 1 - select )
16561647 thumby .display .update ()
1657- getcharinputNew ()
16581648 if (thumby .buttonL .pressed ()):
1659- selpos = 0
1649+ select = 0
16601650 if (thumby .buttonR .pressed ()):
1661- selpos = 1
1651+ select = 1
16621652
1663- if ( selpos == 0 ):
1653+ # Free memory
16641654 del currentRoom
16651655 del player
16661656 curMsg = ""
16671657 gc_collect ()
1668- else :
1658+
1659+ if (select == 1 ):
16691660 thumby .reset () # Exit game to main menu
1661+ # Else: Restart game loop
0 commit comments