how to create ludo game using python and Tkinter - First Part

Namaste Friends,

This Is Our First Part Our Ludo Game Tutorial And In This Part, I Am Going To Write About how To Create Ludo Game Using Python And Tkinter Module.

If You Are A New Reader Then Check Our Previous Tutorial Click Here

In Today's Post We are Going To write Script For Our Ludo Game. As I Already Described In My Previous Tutorial, To Run This Game First We will Create A Grid Of Squares In Tkinter Canvas That Will Act as A Ground Level Track For Our Tokens And Then We Will Create Different Roots For Our Tokens To Run On This Main Track According To Ludo Game Rules. So, Here I Am Writing a Model Script Of Ludo Game.


# Import Module
from GameConfig import *

# Function For Track Coordinates Calculations
def tracks(s, r):
 return [s.format(i) for i in r]

# Creating Main Track Square Boxes
TRACK = []
TRACK+= tracks("6.{}", range(6))[::-1]
TRACK+= ['7.0']
TRACK+= tracks("8.{}", range(6))
TRACK+= tracks("{}.6", range(9,15))
TRACK+= ['14.7']
TRACK+= tracks("{}.8", range(9,15))[::-1]
TRACK+= tracks("8.{}", range(9,15))
TRACK+= ['7.14']
TRACK+= tracks("6.{}", range(9,15))[::-1]
TRACK+= tracks("{}.8", range(6))[::-1]
TRACK+= ['0.7']
TRACK+= tracks("{}.6", range(6))

# Creating Ending Tracks
F_TRACK.append(tracks("7.{}", range(1,7)))
F_TRACK.append(tracks("{}.7", range(8,14))[::-1])
F_TRACK.append(tracks("7.{}", range(8,14))[::-1])
F_TRACK.append(tracks("{}.7", range(1,7)))

# Now Creating Roots
TRAIN_1=TRACK[8:]+TRACK[:7]+F_TRACK[0]+['7.6']  # ROOT One
TRAIN_2=TRACK[21:]+TRACK[:20]+F_TRACK[1]+['8.7'] # Root Two
TRAIN_3=TRACK[34:]+TRACK[:33]+F_TRACK[2]+['7.8'] # Root Three
TRAIN_4=TRACK[47:]+TRACK[:46]+F_TRACK[3]+['6.7'] # Root Four

# Station

TEAM = []
TEAM.append(["C{}".format(i) for i in STATIONS[0]]+["C{}".format(i) for i in STATIONS[3]])
TEAM.append(["C{}".format(i) for i in STATIONS[1]]+["C{}".format(i) for i in STATIONS[2]])
#print TEAM

(TRAIN_1, STATIONS[0], C_1, "A"),
(TRAIN_2, STATIONS[1], C_2, "B"),
(TRAIN_3, STATIONS[2], C_3, "B"),
(TRAIN_4, STATIONS[3], C_4, "A"),

# Stops

For Downloading These Example Codes Click Here

For Previous Tutorial Click Here

And In Our Next Tutorial, We Will Continue This Tutorial.

Thanks For Reading
Have A Nice Day.

Share this

Related Posts

Next Post »