Python Forum
Turtle Graphics Card Values in a List
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Turtle Graphics Card Values in a List
#1
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()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python idle turtle graphics help jojo 5 4,020 Apr-14-2019, 12:28 PM
Last Post: ichabod801
  dictionaries and list as values Pippi 6 3,485 Apr-13-2019, 09:05 AM
Last Post: perfringo
  card dealer school project kalle1234 5 11,121 Jan-05-2019, 09:21 PM
Last Post: ichabod801
  Turtle Graphics Help - Filling each shape in Nate 10 7,239 Nov-27-2018, 08:40 AM
Last Post: Nate
  making a dictionary from a list, one key with multiple values in a list within a list rhai 4 3,616 Oct-24-2018, 06:40 PM
Last Post: LeSchakal
  Issues with Inserting Values into an Empty List with a While Loop TommyMer 2 3,779 Sep-12-2018, 12:43 AM
Last Post: TommyMer
  Storing Minimum List of values from a recursive function sigsegv22 1 2,546 Sep-10-2018, 01:25 PM
Last Post: ichabod801
  Adding values to list and pickling mefiak 2 2,836 May-31-2018, 08:57 AM
Last Post: mefiak
  Playing Card Sorting ness828 4 77,267 Feb-05-2018, 09:01 PM
Last Post: sparkz_alot
  "List index out of range" for output values pegn305 3 5,310 Nov-26-2017, 02:20 PM
Last Post: heiner55

Forum Jump:

User Panel Messages

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