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

Namaste Friends,


As We Already know, Python Is Very Powerful Language. So, Today In This Post I Am Going To Write About How To Write Ludo Game In Python Using Tkinter Package?

Let's Start With Some Basic Information.




Q 1. What Is Ludo? And How To Play Ludo Game?


Ans. Ludo Is A Simple Type Of Board Game Originated In India Somewhere around the 6th Century That Can Be Played By 2 Or 4 Players. In This Game, All Players Have To Race Their Tokens From Stating Point To The Finishing Point According To The Roll Of The Dice.


Q 2. How To Write A Ludo Game In Python?


Ans. First, I Want To Clear One Thing That Writing Any Game In Any Programming Language Is Not Easy Work Because To Write Any Game, We need Sharp Mind, Good knowledge Of Programming Language And Hard Work. So, Before Writing Any Game, First Make Your Mind Strong.

To Write This Ludo Game In Python We Will Use MVC Method. Here, MVC is Stand For Model, View And Controller.

Model Belongs To Data Storage Or Database,
View Belongs To Graphics,
And Controller Is For Handling All Functions.

To Make Our Game More Easy To Write Here, I am Going to divide Our Game Function In Parts According To MVC Method.

Let's Create 5 Scripts In One Folder as


  •  GameConfig.py For Managing Normal Game Settings
  •  models.py For Managing Ludo Game Tkinter Canvas Settings
  •  views.py For Graphics
  •  controller.py For Handling All Of These Functions
  •  main.py for Executing Controller Script Functions


To Make This Game Easy To Write And Easy To Work, First We Will Create A Complete Grid Of Squares In Tkinter Canvas. Then, We will Create A Specific Train Like Track For Ludo Tokens In Those Square Grid. After That, We Will Use Tkinter Canvas create_oval Function For Representing Tokens In Canvas Grid and In The End, We Will Write Functions To Run These Game According To Ludo Game Rules And Also To Make Our Tutorial More Easy To Understand. Here, I Am Dividing These Tutorials In 4 Parts And In Current Part, We Will Write Simple GameConfig Script.

1. GameConfig.py



#
# ================================================= 
#    Configuration Settings
# =================================================
#
# Width Of All Boxes
S_WIDTH=36



# Height Of All Boxes
S_HEIGHT=36

# Number Of Boxes
AREA = 15


# =================================================
#     Colors Settings
# =================================================
#
# Track Color
C_0_A = "SkyBlue3" # When Active
C_0_D = "SkyBlue2" # when Deactive

# TEAM 
C_1 = "Blue"   # Default
C_1_A = "RoyalBlue2" # When Active
C_1_D = "RoyalBlue1" # When Deactive


C_2 = "red"
C_2_A = "firebrick2" 
C_2_D = "firebrick1"


C_3 = "green"
C_3_A = "green2" 
C_3_D = "green1"


C_4 = "yellow"
C_4_A = "yellow2" 
C_4_D = "yellow1"


# List Of Active Colors
COLOR = [C_1_A, C_2_A, C_3_A, C_4_A]


For Downloading These Example Codes Click Here

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


Thanks For Reading
Have A Nice Day.


Share this

Related Posts

Previous
Next Post »