I am currently working on a board game. I am having a bit of trouble when it comes to coding the dice. For some reason, the while loop keeps returning the same random integer after every run instead of a new one.
this is how far I have got:
def dice():
turtle.addshape("bull.gif")
player1 = turtle.Turtle()
player1.shape("bull.gif")
player1.penup()
player1.goto(-240, -260)
turtle.addshape("cow.gif")
player2 = turtle.Turtle()
player2.shape("cow.gif")
player2.penup()
player2.goto(-240, -220)
dice1 = random.randint(1, 6)
p1_list = ([-240, -260], [-120, -260], [0, -260], [120, -260], [240, -260], [240, -140], [120, -140], [0, -140], [-120, -140], [-240, -140], [-240, -20], [-120, -20], [0, -20], [120, -20], [240, -20], [240, 100], [120, 100], [0, 100], [-120, 100], [-240, 100], [-240, 220], [-120, 220], [0, 220], [120, 220], [240, 220])
p2_list = ([-240, -220], [-120, -220], [0, -220], [120, -220], [240, -220], [240, -100], [120, -100], [0, -100], [-120, -100], [-240, -100], [-240, 20], [-120, 20], [0, 20], [120, 20], [240, 20],[ 240, 140], [120, 140], [0, 140], [-120, 140], [-240, 140], [-240, 260], [-120, 260], [0, 260], [120, 260], [240, 260])
dieValue = dice1
P1_pos = player1.goto(p1_list[0])
pos = 0
w = True
while w == True:
player1_dice = input("\nBULL (P1): Please press 'ENTER' to roll the dice ")
if player1_dice == "":
print("BULL (P1) rolled a", dice1)
elif player1_dice != "":
print("BULL (P1): Please make sure to press 'ENTER' ")
for pos in range(dieValue) :
pos += 1
P1_pos = player1.goto(p1_list[pos])
pos = pos
dice()
Aucun commentaire:
Enregistrer un commentaire