LUDO
LUDO
BELGAUM-590014
Submitted by:
CERTIFICATE
This is to certify that the Mini-Project on Computer Graphics and Visualization work entitled
“LUDO-BOARD GAME USING OPENGL” has been successfully carried out bySAURABH
PAUL(1DT11CS039) and VIJAY KUMAR(1DT11CS054)abonafide students of
DayanandaSagar Academy of Technology and Management in partial fulfilment of the
requirements for the award of degree in Bachelor of Engineering in Computer Science and
Engineering ofVisvesvaraya Technological University, Belgaum during academic year 2014-
2015. It is certified that all corrections/suggestions indicated for Internal Assessment have been
incorporated in the report deposited in the departmental library. The mini project report has been
approved as it satisfies the academic requirements in respect of project work for the said degree.
2.
DSATM Page - 2 -
ABSTRACT
OpenGL is a library for doing computer graphics.By using it, we can create interactive applications which
render high-quality color images composed of 3D geometric objects and images. OpenGL is window and operating
system independent. As such, the part of our application which does rendering is platform
independent.However, in order for OpenGL to be able to render, it needs awindow to draw into. Generally,
The Project OpenGL Ludo-Board Game is a computer graphics project. The computer
graphics project used open source library – OpenGL with the c++. This c++ project is based on
one of the oldest Board Game – the Ludo. This OpenGL Ludo game is of two player game and
not the regular four player.
Ludo is a board game for two to four players,in which the players race their four tokens from
start to finish accordingly to die rolls.Like other cross and circle games,Ludo is derived from the
Indian game Pachisi but simpler.The game and its variant are popular in many countries .
DSATM Page - 3 -
ACKNOWLEDGEMENT
It gives us immense pleasure to present before you our project titled ‘LUDO-BOARD
GAME USING OPENGL’ .The joy and satisfaction that accompany the successful completion
of any task would be incomplete without the mention of those who made it possible. We are glad
to express our gratitude towards our prestigious institution DAYANANDA SAGAR
ACADEMY OF TECHNOLOGY AND MANAGEMENT for providing us with utmost
knowledge, encouragement and the maximum facilities in undertaking this project.
We wish to express a sincere thanks to our respected Principal Dr. B.R.Lakshmikantha for all
the support.
We express our deepest gratitude and special thanks to Dr.C.Nandini, Prof &H.O.D, Dept. Of
Computer Science Engineering, for all her guidance and encouragement.
We sincerely acknowledge the guidance and constant encouragement of our mini-project guides,
Assistant Prof.Mr.Raghu. M. T
SAURABH PAUL
(1DT11CS039)
VIJAY KUMAR
(1DT11CS054)
DSATM Page - 4 -
CONTENTS
1. INTRODUCTION
1.1 Computer Graphics
1.2 OpenGL Technology
1.3 Project Description
2. REQUIREMENT SPECIFICATION
2.1 Hardware Requirements
2.2 Software Requirements
3. INTERFACE AND ARCHITECTURE
Architecture
4. IMPLEMENTATION AND SOURCE CODE
5. SNAPSHOTS
6. FUTURE ENHANCEMENT
7. CONCLUSION
8. REFERENCES
9. APPENDIX
Personal Details
DSATM Page - 5 -
INTRODUCTION
1.1 Computer Graphics
Computers have become a powerful tool for the rapid andeconomical production of
pictures. There is virtually no area in whichgraphical displays cannot be used to some advantage,
and so it is notsurprising to find the use of computer graphics so widespread. Althoughearly
applications in engineering and science had to rely on expensiveand cumbersome equipment, advances in computer
technology havemade interactive computer graphics a practical tool. Today, we findcomputer graphics
used routinely in such diverse areas as science,engineering, medicine, business, industry, government,
art,entertainment, advertising, education, and training.
Computer graphics aregraphicscreated usingcomputersand,
moregenerally, therepresentationandmanipulationof image databy acomputer.
The development of computer graphics has made computerseasier to interact with, and better for
understanding and interpretingmany types of data.
Developments in computer graphics have had aprofound impact on many types of media and
have revolutionizedanimation,moviesand thevideo gameindustry.
A major use of computer graphics is in design processes,particularly for engineering and architectural
+systems, but almost allproducts are now computer designed.
Generally referred to as CAD.computer-aided design methods are now routinely used in the design
of buildings, automobiles, aircraft, watercraft, spacecraft, computers,textiles, and many, many
other products.
Here we have used “OpenGL” as the graphics software system to implement our mini project “LUDO-BOARD
GAME”Now let us have a quick look at OpenGL.
DSATM Page - 6 -
this is controlled by the windowingsystem on whatever platform we are working on. As OpenGL
is platformindependent, we need some way to integrate OpenGL into eachwindowing system.Every windowing
system where OpenGL is supported has additionalAPI calls for managing OpenGL windows, color maps
and other features. These additional APIs are platform dependent. For the sake of simplicity,we are using an
additional freeware library for simplifying interacting withwindowing systems, GLUT.GLUT, the OpenGL Utility
Toolkit is a library to make writing openGLprograms regardless of windowing systems much easier.
The Project OpenGL Ludo game is an computer graphics project. The computer
graphics project used open source library – OpenGL with the C/C++. This C/C++ project is
based on one of the oldest Board Game – the Ludo. This OpenGL Ludo game is of two player
game and not the regular four player.
DSATM Page - 7 -
OpenGL Ludo game rules
At the start of the OpenGL Ludo game, the player’s four pieces are placed in the start area of
their colour.
Players take it in turn to throw a single die. A player must first throw a six to be able to move
a piece from the starting area onto the starting square.
In each subsequent turn the player moves a piece forward 1 to 6 squares as indicated by the
die.
When a player throws a 6 the player may bring a new piece onto the starting square, or may
choose to move a piece already in play. Any throw of a six results in another turn.
If a player cannot make a valid move they must pass the die to the next player.
If a player’s piece lands on a square containing an opponent’s piece, the opponent’s piece is
captured and returns to the starting area.
A piece may not land on a square that already contains a piece of the same colour (unless
playing doubling rules).
Once a piece has completed a circuit of the board it moves up the home column of its own
colour. The player must throw the exact number to advance to the home square.
The winner is the first player to get all four of their pieces onto the home square.
The centre of the cross is the finishing square which is often divided into four colored
triangles. Eachcolored triangle is combined with a colored middle column appears as an
arrow pointing to the finish.
The shaft of each arrow is a player’s “home column” and is five squares long. To the left of
each home column, one square from the edge of the board is a starting square, also colored.
During game play a piece moves from its starting square, clockwise around the perimeter of
the board, and up the player’s home column to the finishing square.
In the space to the left of each arm is a circle or square to hold a player’s pieces before they
are allowed into play. There are no resting squares, but the colored home column may only
be entered by its own player’s tokens
DSATM Page - 8 -
Chapter-2
REQUIREMENT SPECIFICATION
DSATM Page - 9 -
Chapter-3
IMPLEMENTATION
void check_cond()
if((k1>27&&p1==0)&&(k2>27&&p1==0)&&(l1>27&&p2==0)&&(l2>27&&p2==0))
dice1=0;
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glClearColor(0,0,0,0);
glFlush();
about();
else if(s1==2)
{ dice1=0;
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glClearColor(0,0,0,0);
glFlush();
about1();
DSATM Page - 10 -
else if(s2==2)
{ dice1=0;
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glClearColor(0,0,0,0);
glFlush();
about2();
int C[10][10];
GLint rand();
int D[10][10];
C[0][0]=A[k2][0];C[0][1]=A[k2][1];C[1][0]=A[k1][0];C[1][1]=A[k1][1];
D[0][0]=B[l2][0];D[0][1]=B[l2][1];D[1][0]=B[l1][0];D[1][1]=B[l1][1];
if(ra1+k1>57||ra1+k2>57||ra1+l1>57||ra1+l2>57)
{z=1;}
if(btn==GLUT_LEFT_BUTTON&&state==GLUT_DOWN)
if(ply1==1&&ply2==0)
DSATM Page - 11 -
{
if(k1==0&&x>483&&x<517&&y<615&&y>580)
if(ra1==6||ra1==1)
player1(1);
else
player1(2);
else if(k2==0&&x>412&&x<447&&y<545&&y>510)
if(ra1==6||ra1==1)
player1(2);
else
player1(1);
else if(x>(C[0][0]-20)&&x<(C[0][0]+20)&&y>(C[0][1]-
20)&&y<(C[0][1]+20)&&z1==1&&k2>0)
player1(2);
else if(x>(C[1][0]-20)&&x<(C[1][0]+20)&&y>(C[1][1]-
20)&&y<(C[1][1]+20)&&z1==1&&k1>0)
player1(1);
if(z==1&&dice1==1)
{ z=0;
z1=1;
ra1=rand()%2+rand()%3+rand()%2+rand()%3;
DSATM Page - 12 -
if(ra1==0)
ra1=1;
dice(ra1);
else
{if(l1==0&&x>833&&x<873&&y>84&&y<124)
if(ra1==6||ra1==1)
player2(1);
else
player2(2);
else if(l2==0&&x>906&&x<940&&y<190&&y>158)
if(ra1==6||ra1==1)
player2(2);
else
player2(1);
else if(x>(D[0][0]-20)&&x<(D[0][0]+20)&&y>(D[0][1]-
20)&&y<(D[0][1]+20)&&z1==1&&l2>0)
DSATM Page - 13 -
player2(2);
else if(x>(D[1][0]-20)&&x<(D[1][0]+20)&&y>(D[1][1]-
20)&&y<(D[1][1]+20)&&z1==1&&l1>0)
player2(1);
if(z==1&&dice1==1)
{ z=0;
z1=1;
ra1=rand()%2+rand()%3+rand()%2+rand()%3;
if(ra1==0)
ra1=1;
dice(ra1);
void display2();
void wait(void);
DSATM Page - 14 -
void call(int w);
void display1(void);
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<=h)
glOrtho(-1.0,1.0,-1.0*(GLfloat)h/(GLfloat)w,
2.0*(GLfloat)h/(GLfloat)w,-20.0,20.0);
else
glOrtho(-1.0*(GLfloat)w/(GLfloat)h,
1.0*(GLfloat)w/(GLfloat)h,-1.0,1.0,-20.0,20.0);
glMatrixMode(GL_MODELVIEW);
glutPostRedisplay();
Int main(int)
enter=1;
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);
init();
glutCreateMenu(options);
DSATM Page - 15 -
glutAddMenuEntry("Game Mode or Restart",4);
glutAddMenuEntry("Quit",5);
glutMouseFunc(myMouse);
glutKeyboardFunc(key);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
font=GLUT_BITMAP_9_BY_15;//GLUT_BITMAP_HELVETICA_12;
glutMainLoop();
DSATM Page - 16 -
Chapter-4
SNAPSHOTS
DSATM Page - 17 -
Chapter-5
FUTURE AND ENHANCEMENT
DSATM Page - 18 -
Chapter – 6
CONCLUSION
The conclusion here - is that the application of this project. i.e.,where all this project’s result can be
used. This project would be helpful in playing two playerludo-board game. Or it can also be enhanced to
be used for a four player game. Even though the Ludo game is in C++ designed is enriched
with many options, it is a two dimensional demo, in future this computer graphics project can
be re designed with 3D animation and sound effects.
DSATM Page - 19 -
Chapter-7
REFERENCE(S)
Websites: www.openglprojects.com
www.cglabprograms.com
DSATM Page - 20 -
Chapter-8
APPENDIX
Personal Details
NAME:SAURABH PAUL
USN: 1DT11CS039
NAME:VIJAY KUMAR
USN:IDT11CS054
SEMESTER AND SECTION: SIXTH SEM
DEPARTMENT:COMPUTER SCIENCE
COLLEGE:DAYANANDA SAGAR ACADEMY OF TECHNOLOGY AND
MANAGEMENT
EMAIL ID: [email protected]
EMAIL ID:[email protected]
DSATM Page - 21 -