Turtle Graphics Card Values in a List - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Turtle Graphics Card Values in a List (/thread-17451.html) |
Turtle Graphics Card Values in a List - Muzz - Apr-11-2019 Hi everyone, New to python and trying to figure out how to make the numbers on my cards ive drawn move on to the the next value in a list every time a new card is laid down. Ive tried a few methods like incrementing the value in the list but im just stuck. So my list is Card_Values and the part that im trying to fix are the two "writes" in the def draw_values. Thanks in advance for any assistance. #import modules needed from turtle import * from random import * speed('fastest') def write_upside_down(string, **named_params): named_params['angle'] = 180 tk_canvas = getscreen().cv tk_canvas.create_text(xcor(), -ycor(), named_params, text = string) #---------------------------------------------------------------------------------# #List of colours# colours=['silver','light sky blue','black','tan','dim grey','light slate grey','white','dark olive green'] #List of card values--------------------------------------------------------------# Card_Values=(['2','3','4','5','6','7','8','9','10','J','Q','K','A']) #Useful constants #---------------------------------------------------------------------------------# #VARIABLES------------------------------------------------------------------------# card_length=200 card_width=150 card_border_width=1 #DEFINITIONS-----------------------------------------------------------------------# ########################## def draw_values(): penup() forward(65) setheading(-90) forward(25) write (Card_Values,font=("Arial", 10, "bold")) setheading(0) forward(65) setheading(-90) forward(160) setheading(0) forward(60) setheading(-90) write_upside_down(Card_Values,font=("Arial", 10, "bold")) setheading(180) forward(60) setheading(90) forward(160) setheading(-90) ##Define the suits## def Card(): forward(1) width(card_border_width) pendown() pencolor(colours[2]) fillcolor(colours[1]) begin_fill() seth(180) forward(card_width /2) seth(-90) forward(card_length) seth(0) forward(card_width) seth(90) forward(card_length) seth(180) forward(card_width / 2) end_fill() draw_values() penup() |