Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] ROLL function
#1
I am making a dice game, here is my roll function.
What I want to happen is for the loop to repeat 9 times(or 10 I can't tell) and each time pick a different dice side to blit to mimic rolling the die. Instead, whats happening is it generates a random side on both die like it should and then only blits it the last time.
def ROLL():
        rolltime = 1                      #rolltime is a variable that goes up by one each time it loops
        while True:
            if rolltime <= 10:      
                DiceRoller1 = random.choice(Dice)    #Dice is a list of 6 images, one of each side
                DiceRoller2 = random.choice(Dice)    # in the game there are two dice you roll
                screen.blit(DiceRoller1,(0,0))             #this and the next line are whats giving me issues
                screen.blit(DiceRoller2,(75,0))
                rolltime += 1
                clock.tick(10)
                for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                        pygame.quit()
                        quit()
            else:                           #if rolltime is over ten the loop breaks
                break
Reply


Messages In This Thread
ROLL function - by Zman350x - Jul-31-2017, 08:14 PM
RE: ROLL function - by metulburr - Jul-31-2017, 10:43 PM
RE: ROLL function - by Zman350x - Aug-01-2017, 11:40 AM
RE: ROLL function - by metulburr - Aug-01-2017, 12:27 PM
RE: ROLL function - by Zman350x - Aug-03-2017, 02:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] another dice roll! mzmingle 3 4,632 Nov-28-2017, 04:47 PM
Last Post: Windspar
  [PyGame] dice roll? mzmingle 1 7,290 Nov-27-2017, 11:58 AM
Last Post: Mekire

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020