I am trying to code a snakes and ladders game using the turtle library. The position of each player has been defined using coordinates. Now I have some trouble coding the dice and getting the players to move accordingly.
Here is the bit of code I need help with:
def dice():
turtle.addshape("bull.gif")
player1 = turtle.Turtle()
player1.shape("bull.gif")
player1.penup()
player1.goto(-240, -260)
dice1 = random.randint(1, 6)
#dice2 = random.randint(1, 6)
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' ")
P1_coor =
P1_pos = 1
dieValue = dice1
pos = 0
for pos in range(dieValue):
newPos = pos + P1_pos + 1
player1.goto(newPos)
P1_pos = newPos
dice()
Aucun commentaire:
Enregistrer un commentaire