SlideShare a Scribd company logo
Requirement for loading of game
void load_game()
{
setcolor(16);
settextstyle(1,HORIZ_DIR,1);
outtextxy(200,350,"Loading");
rectangle(275,355,450,370);
setcolor(1);
for(i=0;i<175;i+=2)
{
line(275+i,355,275+i,370);
delay(50);
}
}
Requirement for display numbers in board
void board()
{
int i,j,x1=100,y1=100,x2=400,y2=400,t,p;
char cc[3],no1=100;
for(i=1;i<=10;i++)
{ settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
setcolor(1);
if(i%2==0)
{
for(j=1;j<=10;j++)
{ sprintf(cc,"%d",no1);
no1--;
outtextxy(x2-25,y1+5,cc);
x2-=30;
}
x2=400;
y1+=30;
}
else
{
for(j=1;j<=10;j++)
{ sprintf(cc,"%d",no1);
no1--;
outtextxy(x1+5,y1+5,cc);
x1+=30;
}
x1=100;
y1+=30;
} } }
Requirement for roll of dice
dic=toupper(getche());
srand(time(NULL));
dic=(rand()%6)+1;
dice(dic);
Requirement for set turn of the player and show message if player move 1st
time his cookie or he got
six on dice.
void turn()
{
int dic,pos1=-1,pos2=-1,player=1;
do
{
score_bord(pos1,pos2);
if(player==1)
{
if(pos1==-1&&dic==6||pos1==-1&&dic==1)
{
pos1=0;
setfillstyle(1,0);
bar(0,0,getmaxx(),getmaxy());
setcolor(2);
settextstyle(7,HORIZ_DIR,2);
outtextxy(200,200,"Player 1: now I move my token");
setcolor(10);
outtextxy(200,250,"Press any key to move");
delay(10);
}
else if(pos1==-1&&dic<6)
{
player ++;
}
else if(dic==6)
{
pos1=set_position(pos1,1,dic);
setfillstyle(1,0);
bar(0,0,getmaxx(),getmaxy());
setcolor(2);
settextstyle(7,HORIZ_DIR,2);
outtextxy(100,200,"Player 1 - Hurray ! I got a six on dice");
}
else
{
player++;
pos1=set_position(pos1,1,dic);
}
setcolor(0);
rectangle(500,300,570,325);
}
else
{
if(pos2==-1&&dic==6||pos2==-1&&dic==1)
{
pos2=0;
setfillstyle(1,0);
bar(0,0,getmaxx(),getmaxy());
setcolor(2);
settextstyle(7,HORIZ_DIR,2);
outtextxy(200,200,"Player 2: now I move my token");
setcolor(10);
outtextxy(200,250,"Press any key to move");
delay(100);
}
else if(pos2==-1&&dic<6)
{player ++;}
else if(dic==6)
{
pos2=set_position(pos2,2,dic);
setfillstyle(1,0);
bar(0,0,getmaxx(),getmaxy());
setcolor(2);
settextstyle(7,HORIZ_DIR,2);
outtextxy(100,200,"Player 2 - Hurray ! I got a six on dice");
}
else
{
player--;
pos2=set_position(pos2,2,dic);
}
setcolor(0);
rectangle(500,350,570,375);
}
score_bord(pos1,pos2);
}
while(pos1<100&&pos2<100);
}
Requirement for set position of player on board and jump when he got a ladder or snake with message.
int set_position(int pos,int player,int dic)
{
int i,posx,posy,flage;
board();
dice(dic);
pos+=dic;
if(pos>100)
{
pos-=dic;
}
else
{
if(player==1)
{
posx=posx1;
posy=posy1;
flage=flage1;
}
else
{
posx=posx2;
posy=posy2;
flage=flage2;
}
for (i=0;i<dic;i++)
{
if(flage==0)
{posx-=30;}
else
{posx+=30;}
if(posx>385&&flage==1)
{
posy-=30;
flage=0;
posx=385;
}
else if(posx<115&&flage==0)
{
posy-=30;
flage=1;
posx=115;
}
}
if(pos==2||pos==7||pos==22||pos==27||pos==30||pos==44||pos==54||pos==61||
pos==70||pos==75)
{
setfillstyle(1,0);
bar(0,0,getmaxx(),getmaxy());
setcolor(2);
settextstyle(7,HORIZ_DIR,2);
if (player==1)
{outtextxy(200,200,"Player 1 - Hurray ! I got a ledder");}
else
{outtextxy(200,200,"Player 2 - Hurray ! I got a ledder");}
}
if(pos==36||pos==80||pos==91)
{
setfillstyle(1,0);
bar(0,0,getmaxx(),getmaxy());
setcolor(2);
settextstyle(7,HORIZ_DIR,2);
if (player==1)
{outtextxy(200,200,"Player 1 - Oh no ! I got a snake");}
else
{outtextxy(200,200,"Player 2 - Oh no ! I got a snake");}
}
if(pos==2)
{ // ladder 2 - 23
posx=175;
posy=325;
pos=23;
}
else if(pos==7)
{ // ladder 7 - 29
posx=355;
posy=325;
pos=29;
}
else if(pos==30)
{ // ladder 30 - 32
posx=355;
posy=295;
pos=32;
flage=0;
}
else if(pos==27)
{ // ladder 27 - 77
posx=205;
posy=175;
pos=77;
flage=0;
}
else if(pos==22)
{ // ladder 22 - 41
posx=115;
posy=265;
pos=41;
}
else if(pos==44)
{ // ladder 44 - 58
posx=205;
posy=265;
pos=58;
flage=0;
}
else if(pos==54)
{ // ladder 54 - 69
posx=355;
posy=205;
pos=69;
flage=1;
}
else if(pos==70)
{ //ladder 70 - 90
posx=385;
posy=145;
pos=90;
}
else if(pos==61)
{ // ladder 61 - 83
posx=175;
posy=145;
pos=83;
}
else if(pos==75)
{ // ladder 75 - 93
posx=325;
posy=115;
pos=93;
}
else if (pos==80)
{ // snake 80 - 1
posx=115;
posy=325;
pos=1;
flage=0;
}
else if (pos==36)
{ //snake 36 - 11
posx=385;
posy=355;
pos=11;
}
else if (pos==91)
{ //snake 91 - 47
posx=295;
pos=265;
pos=47;
}
}
if(player==1)
{
posx1=posx;
posy1=posy;
flage1=flage;
setfillstyle(2,14);
fillellipse(posx,posy,5,5);
setfillstyle(2,4);
fillellipse(posx2,posy2,5,5);
}
else
{
posx2=posx;
posy2=posy;
flage2=flage;
setfillstyle(2,4);
fillellipse(posx,posy,5,5);
setfillstyle(2,14);
fillellipse(posx1,posy1,5,5);
}
if(pos==100)
{
win_msg(player);
}
while(kbhit())
{ clearviewport(); }
return pos;
}
Requirement for winning message for player who win the game.
void win_msg(int player)
{
clearviewport();
setfillstyle(1,8);
bar(0,0,getmaxx(),getmaxy());
setcolor(10);
settextstyle(0,0,3);
outtextxy(75,75,"Snake");
setcolor(4);
outtextxy(210,75,"And");
setcolor(14);
outtextxy(300,75,"Ladder");
setcolor(3);
outtextxy(460,75,"Game");
setcolor(1);
settextstyle(4,0,7);
outtextxy(125,300,"GAME OVER");
setcolor(15);
settextstyle(7,HORIZ_DIR,2);
if (player==1)
{outtextxy(200,200,"Player 1 win this match");}
else
{outtextxy(175,200,"Player 2 win this match");}
setcolor(14);
circle(50,100,4);
}
Requirement main function for run full game.
coding:-
main()
{
int gd = DETECT, gm;
initgraph(&gd,&gm,"C:TCBGI");
load_game();
clearviewport();
start();
getch();
closegraph();
return 0;
}

More Related Content

What's hot

Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithm
Kapil Pandit
 
pptuni1
pptuni1pptuni1
pptuni1
Sachin Yadav
 
Tabela derivadas-e-integrais
Tabela derivadas-e-integraisTabela derivadas-e-integrais
Tabela derivadas-e-integrais
mariasousagomes
 
Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++
Ankit Kumar
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
Kandarp Tiwari
 
Caropro
CaroproCaropro
Caropro
daquicaro
 
Aditazz 01-ul
Aditazz 01-ulAditazz 01-ul
Aditazz 01-ul
michaelsbergin
 
Bubble archery game(c program)
Bubble archery game(c program)Bubble archery game(c program)
Bubble archery game(c program)
SETYA HADI
 
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
Badhon Biswas
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
Prianka Padmanaban
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
hayato
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicals
Manoj Chauhan
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision Detection
Jenchoke Tachagomain
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2ME
Jenchoke Tachagomain
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programs
Amit Kapoor
 
Tik tic tok
Tik tic tokTik tic tok
Tik tic tok
RIDDHICHOUHAN2
 
Processing ii
Processing iiProcessing ii
Processing ii
citylore
 
Tactical motifs 2
Tactical motifs 2Tactical motifs 2
Tactical motifs 2
Dattatraya Patwardhan
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
Aditya Sharma
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of Pune
Bhavesh Shah
 

What's hot (20)

Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithm
 
pptuni1
pptuni1pptuni1
pptuni1
 
Tabela derivadas-e-integrais
Tabela derivadas-e-integraisTabela derivadas-e-integrais
Tabela derivadas-e-integrais
 
Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
Caropro
CaroproCaropro
Caropro
 
Aditazz 01-ul
Aditazz 01-ulAditazz 01-ul
Aditazz 01-ul
 
Bubble archery game(c program)
Bubble archery game(c program)Bubble archery game(c program)
Bubble archery game(c program)
 
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicals
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision Detection
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2ME
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programs
 
Tik tic tok
Tik tic tokTik tic tok
Tik tic tok
 
Processing ii
Processing iiProcessing ii
Processing ii
 
Tactical motifs 2
Tactical motifs 2Tactical motifs 2
Tactical motifs 2
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of Pune
 

Similar to graphics Assidnment

#include stdio.h #include string.h #include stdlib.h #in.pdf
#include stdio.h #include string.h #include stdlib.h #in.pdf#include stdio.h #include string.h #include stdlib.h #in.pdf
#include stdio.h #include string.h #include stdlib.h #in.pdf
singhanubhav1234
 
Proga 090525
Proga 090525Proga 090525
Proga 090525
Atsushi Tadokoro
 
Proga 0601
Proga 0601Proga 0601
Proga 0601
Atsushi Tadokoro
 
Processing iii
Processing iiiProcessing iii
Processing iii
citylore
 
Proga 0622
Proga 0622Proga 0622
Proga 0622
Atsushi Tadokoro
 
Proga 0608
Proga 0608Proga 0608
Proga 0608
Atsushi Tadokoro
 
Programa expresiones regulares
Programa expresiones regularesPrograma expresiones regulares
Programa expresiones regulares
Anel Sosa
 
Bubble archery game(c program)
Bubble archery game(c program)Bubble archery game(c program)
Bubble archery game(c program)
SETYA HADI
 
Proga 0518
Proga 0518Proga 0518
Proga 0518
Atsushi Tadokoro
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdf
asif1401
 
Better performance through Superscalarity
Better performance through SuperscalarityBetter performance through Superscalarity
Better performance through Superscalarity
Mårten Rånge
 
Sbaw090519
Sbaw090519Sbaw090519
Sbaw090519
Atsushi Tadokoro
 
Kwp2 100114
Kwp2 100114Kwp2 100114
Kwp2 100114
Atsushi Tadokoro
 
Graphics programs
Graphics programsGraphics programs
Graphics programs
NAVYA RAO
 
The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)
theijes
 
C Code and the Art of Obfuscation
C Code and the Art of ObfuscationC Code and the Art of Obfuscation
C Code and the Art of Obfuscation
guest9006ab
 
Ssaw08 0624
Ssaw08 0624Ssaw08 0624
Ssaw08 0624
Atsushi Tadokoro
 
Making Games in JavaScript
Making Games in JavaScriptMaking Games in JavaScript
Making Games in JavaScript
Sam Cartwright
 
You are task to add a yawning detection to the programme below;i.pdf
You are task to add a yawning detection to the programme below;i.pdfYou are task to add a yawning detection to the programme below;i.pdf
You are task to add a yawning detection to the programme below;i.pdf
sales223546
 
Kwp2 091217
Kwp2 091217Kwp2 091217
Kwp2 091217
Atsushi Tadokoro
 

Similar to graphics Assidnment (20)

#include stdio.h #include string.h #include stdlib.h #in.pdf
#include stdio.h #include string.h #include stdlib.h #in.pdf#include stdio.h #include string.h #include stdlib.h #in.pdf
#include stdio.h #include string.h #include stdlib.h #in.pdf
 
Proga 090525
Proga 090525Proga 090525
Proga 090525
 
Proga 0601
Proga 0601Proga 0601
Proga 0601
 
Processing iii
Processing iiiProcessing iii
Processing iii
 
Proga 0622
Proga 0622Proga 0622
Proga 0622
 
Proga 0608
Proga 0608Proga 0608
Proga 0608
 
Programa expresiones regulares
Programa expresiones regularesPrograma expresiones regulares
Programa expresiones regulares
 
Bubble archery game(c program)
Bubble archery game(c program)Bubble archery game(c program)
Bubble archery game(c program)
 
Proga 0518
Proga 0518Proga 0518
Proga 0518
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdf
 
Better performance through Superscalarity
Better performance through SuperscalarityBetter performance through Superscalarity
Better performance through Superscalarity
 
Sbaw090519
Sbaw090519Sbaw090519
Sbaw090519
 
Kwp2 100114
Kwp2 100114Kwp2 100114
Kwp2 100114
 
Graphics programs
Graphics programsGraphics programs
Graphics programs
 
The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)
 
C Code and the Art of Obfuscation
C Code and the Art of ObfuscationC Code and the Art of Obfuscation
C Code and the Art of Obfuscation
 
Ssaw08 0624
Ssaw08 0624Ssaw08 0624
Ssaw08 0624
 
Making Games in JavaScript
Making Games in JavaScriptMaking Games in JavaScript
Making Games in JavaScript
 
You are task to add a yawning detection to the programme below;i.pdf
You are task to add a yawning detection to the programme below;i.pdfYou are task to add a yawning detection to the programme below;i.pdf
You are task to add a yawning detection to the programme below;i.pdf
 
Kwp2 091217
Kwp2 091217Kwp2 091217
Kwp2 091217
 

graphics Assidnment