Click here to Skip to main content
15,887,332 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: File Saving Pin
CPallini30-May-09 2:59
mveCPallini30-May-09 2:59 
GeneralRe: File Saving Pin
Rajesh R Subramanian30-May-09 3:01
professionalRajesh R Subramanian30-May-09 3:01 
GeneralRe: File Saving Pin
Code-o-mat30-May-09 12:02
Code-o-mat30-May-09 12:02 
QuestionIExplorerBrowser and mouse double click Pin
CString(0xcccccccc)29-May-09 21:20
CString(0xcccccccc)29-May-09 21:20 
QuestionPrinting from a dialog based MFC application Pin
natejones29-May-09 18:09
natejones29-May-09 18:09 
AnswerRe: Printing from a dialog based MFC application Pin
CPallini29-May-09 21:30
mveCPallini29-May-09 21:30 
AnswerRe: Printing from a dialog based MFC application Pin
Nuri Ismail29-May-09 21:36
Nuri Ismail29-May-09 21:36 
Questiondice generation Pin
swtlibra29-May-09 18:01
swtlibra29-May-09 18:01 
i wana help in generating the dice in C language
numbers are generating eandomly but the problem is with image
actually i m making a game of ludo
the code is as follows
it is excuteable code
plzzzz any one can help

#include<<stdio.h>>
#include<<conio.h>>
#include<<iostream.h>>
#include<<graphics.h>>
#include<<math.h>>
#include<<stdlib.h>>
#include<<process.h>>
#include<<dos.h>>
#include<<string.h>>
#include<<malloc.h>>

int mx,my,d,c;
int size;
int dice;
void *dot;
void initgraphics();
void images();
void gen_dice();
int get_dice();
void image1();
void play();
void put_rect();

void images()
{
cleardevice();

//BOUNDARY
setcolor(13);
rectangle(0,0,450,475);

//HOMES
setcolor(14);
circle(90,100,70);
setcolor(4);
circle(360,100,70);
setcolor(2);
circle(90,380,70);
setcolor(1);
circle(360,380,70);

//STAY POINTS FOR YELLOW HOME
setcolor(14);
circle(75,277,10);
circle(75,250,10);
circle(45,250,10);
circle(105,250,10);
circle(135,250,10);
circle(165,250,10);
circle(45,223,10);

//STAY POINTS FOR BLUE HOME
setcolor(1);
circle(285,250,10);
circle(315,250,10);
circle(345,250,10);
circle(375,250,10);
circle(405,250,10);
circle(405,277,10);
circle(375,222,10);

//STAY POINTS FOR GREEN HOME
setcolor(4);
circle(225,50,10);
circle(225,85,10);
circle(225,120,10);
circle(225,155,10);
circle(225,190,10);
circle(255,50,10);
circle(195,85,10);

//STAY POINTS FOR GREEN HOME
setcolor(2);
circle(225,305,10);
circle(225,335,10);
circle(225,365,10);
circle(225,395,10);
circle(225,425,10);
circle(195,425,10);
circle(255,395,10);

//vertical lines for upper path
setcolor(3);
line(180, 0, 180, 210);
line(210,0,210,210);
line(240,0,240,210);
line(270,0,270,210);

//horizontal lines for upper path
line(180,0,270,0);
line(180,35,270,35);
line(180,70,270,70);
line(180,105,270,105);
line(180,140,270,140);
line(180,175,270,175);
line(180,210,270,210);

//vertical lines for lower path
line(180,290,180,475);
line(210,290,210,475);
line(240,290,240,475);
line(270,290,270,475);

//horizontal lines for lower path
line(180,290,270,290);
line(180,320,270,320);
line(180,350,270,350);
line(180,380,270,380);
line(180,410,270,410);
line(180,445,270,445);
line(180,476,270,476);

//vertical lines for left path
line(0,210,0,290);
line(30,210,30,290);
line(60,210,60,290);
line(90,210,90,290);
line(120,210,120,290);
line(150,210,150,290);
line(180,210,180,290);

//horizontal lines for left path
line(0,210,180,210);
line(0,235,180,235);
line(0,265,180,265);
line(0,290,180,290);

//vertical paths for right path
line(270,210,270,290);
line(300,210,300,290);
line(330,210,330,290);
line(360,210,360,290);
line(390,210,390,290);
line(420,210,420,290);
line(450,210,450,290);

//horizontal lines for right paths
line(270,210,450,210);
line(270,235,450,235);
line(270,265,450,265);
line(270,290,450,290);

settextstyle(SANS_SERIF_FONT,0,3);
setcolor(19);
outtextxy(200,235,"LUDO");


getch();
}

void gen_dice()
{
switch (get_dice())
{
case 1: //dice output is 1
put_rect();
putimage(535, 165, dot, COPY_PUT);
put_rect();
break;
case 2: //dice output is 2
put_rect();
putimage(515, 145, dot, COPY_PUT);
putimage(555, 185, dot, COPY_PUT);
put_rect();
break;
case 3: //dice output is 3
put_rect();
putimage(515, 145, dot, COPY_PUT);
putimage(535, 165, dot, COPY_PUT);
putimage(555, 185, dot, COPY_PUT);
put_rect();
break;
case 4: //dice output is 4
put_rect();
putimage(515, 145, dot, COPY_PUT);
putimage(555, 145, dot, COPY_PUT);
putimage(515, 185, dot, COPY_PUT);
putimage(555, 185, dot, COPY_PUT);
put_rect();
break;
case 5: //dice output is 5
put_rect();
putimage(515, 145, dot, COPY_PUT);
putimage(555, 145, dot, COPY_PUT);
putimage(535, 165, dot, COPY_PUT);
putimage(515, 185, dot, COPY_PUT);
putimage(555, 185, dot, COPY_PUT);
put_rect();
break;
case 6: //dice output is 6
put_rect();
putimage(515, 145, dot, COPY_PUT);
putimage(515, 165, dot, COPY_PUT);
putimage(515, 185, dot, COPY_PUT);
putimage(555, 145, dot, COPY_PUT);
putimage(555, 165, dot, COPY_PUT);
putimage(555, 185, dot, COPY_PUT);
put_rect();
break;
}

}

int get_dice()
{
dice=random(6);
if(dice==0)
{
dice++;
}
return (dice);
}

void image1()
{




setcolor(0);
setfillstyle(1, 0);
rectangle(535, 165, 545, 175);
floodfill(540, 170, 0);
size=imagesize(535, 165, 545, 175);
dot=malloc(size);
getimage(535, 165, 545, 175, dot);
//cleardevice();


images();
play();

}



void play()
{
int ch;
again:
ch=getche();
if(ch==13)
{
gen_dice();
goto again;
}
else if(ch==27)
{
exit(0);
}
}


void main(void)
{
clrscr();

initgraphics();
image1();
getch();

}
void put_rect()
{
setcolor(WHITE);
setfillstyle(SOLID_FILL, 15);
rectangle(500, 130, 580, 210);
floodfill(510, 140, 15);
}
QuestionRe: dice generation Pin
CPallini29-May-09 21:25
mveCPallini29-May-09 21:25 
AnswerRe: dice generation Pin
swtlibra29-May-09 21:36
swtlibra29-May-09 21:36 
QuestionRe: dice generation Pin
CPallini30-May-09 2:56
mveCPallini30-May-09 2:56 
AnswerRe: dice generation Pin
swtlibra30-May-09 23:42
swtlibra30-May-09 23:42 
GeneralRe: dice generation Pin
CPallini31-May-09 0:02
mveCPallini31-May-09 0:02 
QuestionThe peculiarities of reality : leaner but not faster ? Pin
GJBR29-May-09 10:30
GJBR29-May-09 10:30 
AnswerRe: The peculiarities of reality : leaner but not faster ? Pin
David Crow29-May-09 10:58
David Crow29-May-09 10:58 
GeneralRe: The peculiarities of reality : leaner but not faster ? Pin
GJBR29-May-09 11:10
GJBR29-May-09 11:10 
AnswerRe: The peculiarities of reality : leaner but not faster ? Pin
BobInNJ29-May-09 11:14
BobInNJ29-May-09 11:14 
GeneralRe: The peculiarities of reality : leaner but not faster ? Pin
GJBR29-May-09 11:42
GJBR29-May-09 11:42 
AnswerRe: The peculiarities of reality : leaner but not faster ? Pin
Stuart Dootson29-May-09 13:14
professionalStuart Dootson29-May-09 13:14 
AnswerRe: The peculiarities of reality : leaner but not faster ? Pin
Joe Woodbury29-May-09 13:29
professionalJoe Woodbury29-May-09 13:29 
AnswerRe: The peculiarities of reality : leaner but not faster ? Pin
Luc Pattyn29-May-09 13:40
sitebuilderLuc Pattyn29-May-09 13:40 
Questionimage in picture control not displayed properly after moving Pin
dumnbncool29-May-09 10:06
dumnbncool29-May-09 10:06 
Questionurgent help Pin
ramina sen29-May-09 8:18
ramina sen29-May-09 8:18 
AnswerRe: urgent help Pin
David Crow29-May-09 8:28
David Crow29-May-09 8:28 
GeneralRe: urgent help Pin
ramina sen29-May-09 8:33
ramina sen29-May-09 8:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.