Student name id
Md. Mazharul Islam (180203)
Rayhain Jobair (180209)
Abid Afsan Hamid (180217)
Sheikh Asif Hasan (180223)
The game of Snakes and Ladders is today considered a classic, and is loved by children from all over the world. Whilst the game itself is known my most people, its origin is less well-known. As a matter of fact, the game of Snakes and Ladders is an ancient Indian invention, and was not played for mere entertainment, but had a philosophical dimension to it as well.
History of the ludo game(snake & ladder):
The board game, today called Snakes and Ladders, originated in ancient India, where it was known with the name Mokshapat or Moska Patamu. It’s not exactly known when or who invented it, through it’s believed the game was played at a time as early as 2ad century BC. According to some historians , the game was invented by Saint Gyandev In the 13th century AD. Orginlly ,the game was used as a part of moral instruction to children. The squaries in which ladders start were each supposed to stand for a virtue, and those housing the head of a snake were supposed to stand for a evil. The snakes outnumbered the ladders in the original Hindu game. The game was transported to England by the colonial rules in the latter part of the 19th century, with some notifications. The modified game was named snakes and Ladders and stripped of it’s moral and religious aspects and the number of laders and snakes were equlizesd.
This game is played between two or more people. Each of the player can play the game with rolling the dice.
How to play:
- Each player puts their counter on the space that says ‘start here’.
- Take it in turns to roll the dice. Move your counter forward the number of spaces shown on the dice.
- If your counter lands at the bottom of a ladder, you can move up to the top of the ladder.
- If your counter lands on the head of a snake, you must slide
down to the bottom of the snake.
- The first player to get to the space that says ‘home’ is the winner.
Using graphichal function:
Declaration: void line(int x1, int y1, int x2, int y2);
line function is used to draw a line from a point(x1,y1) to point(x2,y2) i.e. (x1,y1) and (x2,y2) are end points of the line.The code given below draws a line.
Declaration: void circle(int x, int y, int radius);
Circle function is used to draw a circle with center (x,y) and third parameter specifies the radius of the circle. The code given below draws a circle.
Declaration: void floodfill(int x, int y, int border);
floodfill function is used to fill an enclosed area. Current fill pattern and fill color is used to fill the area.(x, y) is any point on the screen if (x,y) lies inside the area then inside will be filled otherwise outside will be filled,border specifies the color of boundary of area. To change fill pattern and fill color use setfillstyle. Code given below draws a circle and then fills it.
Declaration: void setfillstyle( int pattern, int color);
Setfillstylefunction sets the current fill pattern andfill color.
Declaration: void setcolor(int color);
Total 16 colors are available. Strictly speaking number of available colors depends on current graphics mode and driver.For Example :- BLACK is assigned 0, RED is assigned 4 etc. Setcolorfunction is used to change the current drawing color.e.g. Setcolor(RED) or setcolor(4) changes the current drawing color to RED. Remember that default drawing color is WHITE.
Declaration: void outtextxy(int x, int y, char *string);
Outtextxy function display text or string at a specified point(x,y) on the screen.
Declaration: int getmaxx();
Getmaxx function returns the maximum X coordinate for current graphics mode and driver.
Declaration: int getmaxy();
getmaxy function returns the maximum Y coordinate for current graphics mode and driver.
getchfunction prompts a user to press a character and that character isn’t printed on screen,getch header file is conio.h. This function is not a part of standard C library.
Declaration: void delay(unsigned int);
delay function is used to suspend execution of a program for a particular time.
Declaration: void cleardevice();
cleardevice function clears the screen in graphics mode and sets the current position to (0,0). Clearing the screen consists of filling the screen with current background color.
rand is using for print random number.
In our code we use graphics. For this we need to use graphics .h header file. For this we need to ready our codeblocks for supporting graphics .h. Then we use as usual header file. Now we go to our code:
At first we declare a global array. Then we also declare two array for snake and for ladder that’s return type is boolean. Then we make a rectangular board where we use some line function to draw the 100 square boxes where every boxes have value sequence according the basic ludo game. For this we use loop and in this we use sprintf and outtextxy, function of c++. Then for changing the color of the value we use setcolor function. Then we make some snake using circle function. For coloring that snake we use setfillstyle and floodfill function to color the snake. Then we use ladder to increasing the value. The ladder is made with line function. We using so many line function to make the ladder. Now in main function we use random number to roll the dice. Then according to the value the pointer will move .And the value is set in the current score. And all the value will print beside the board and it will using the function outtextxy. We also make a dice which will show the value of random number in star. We also use placeguti function for changing the row and column form lower to upper. It will the row when one row is end the column will increase in 45. So the column will change and then it starting from the right.
And in this process the code executed. It is the main functionality of our function.
When we run the code a window and console will pop up like shown below:
First view after opening the consol…….
Then after pressing 1……
After that press 3 to open the game……..
Then after throwing the dice ………
At the last, when game is over it will show who will win……
Now the code link is here ……….
- This code can be downloaded from this link.