GUI Programme
#include
#include
#include
void Screen();
void action(int);
void main()
{
union REGS ii,oo;
int Call=0;
int Chosen_Previously=1,Chosen=1;
Screen();
while(1)//infinite loop
{
if(kbhit())//keyboard hit scan
{
//interrupt issue to scan the ascii ans scan codes of the key hit
ii.h.ah=0;
int86(22,&ii,&oo);
//if upper key has been pressed
if(oo.h.ah==72)
{
if(Chosen==1)
Chosen=4;
else
Chosen--;
}
//if lower key has been pressed
if(oo.h.ah==80)
{
if(Chosen==4)
Chosen=1;
else
Chosen++;
}
//if enter is pressed
if(oo.h.ah==28)
{
switch(Chosen)
{
case 1:
// Game();// word game function
break;
case 2:
// SENTENCE();// sentence function
break;
case 3:
// Passage();// passage function
break;
case 4:
clrscr();
exit(0);//terminate program
}//switch
Call=1;
}
}//kbhit
if(Chosen_Previously!=Chosen)//highlights options
{
Chosen_Previously=Chosen;
action(Chosen);
}
if(Call==1)// if enter is pressed
{
Call=0;
action(Chosen);
}
}//while 1
}//main
void Screen()
{
textbackground(0);
textcolor(3);
clrscr();
gotoxy(33,3);
cprintf("Typing Tutor!");
textbackground(4);
textcolor(7);
gotoxy(23,9);
cprintf(" WORDS-GAME ");
gotoxy(57,9);
cprintf("* ");
gotoxy(21,9);
cprintf(" *");
textbackground(1);
gotoxy(23,11);
cprintf(" SENTENCE-PRACTICE ");
gotoxy(23,13);
cprintf(" PASSAGE-TYPING ");
gotoxy(23,15);
cprintf(" EXIT ");
}
void action(int Choice)
{
textbackground(0);
clrscr();
textbackground(0);
textcolor(6);
gotoxy(33,3);
cprintf("Typing Tutor!");
textbackground(1);
gotoxy(23,9);
cprintf(" WORDS-GAME ");
gotoxy(23,11);
cprintf(" SENTENCE-PRACTICE ");
gotoxy(23,13);
cprintf(" PASSAGE-TYPING ");
gotoxy(23,15);
cprintf(" EXIT ");
for(int loop=0;loop<4;loop++)
{
textbackground(0);
gotoxy(57,9+loop*2);
cprintf(" ");
gotoxy(21,9+loop*2);
cprintf(" ");
}
switch(Choice)
{
case 1:
textbackground(4);
textcolor(7);
gotoxy(23,9);
cprintf(" WORDS-GAME ");
gotoxy(57,9);
cprintf("* ");
gotoxy(21,9);
cprintf(" *");
break;
case 2:
textbackground(4);
textcolor(7);
gotoxy(23,11);
cprintf(" SENTENCE-PRACTICE ");
gotoxy(57,11);
cprintf("* ");
gotoxy(21,11);
cprintf(" *");
break;
case 3:
textbackground(4);
textcolor(7);
gotoxy(23,13);
cprintf(" PASSAGE-TYPING ");
gotoxy(57,13);
cprintf("* ");
gotoxy(21,13);
cprintf(" *");
break;
case 4:
textbackground(4);
textcolor(7);
gotoxy(23,15);
cprintf(" EXIT ");
gotoxy(57,15);
cprintf("* ");
gotoxy(21,15);
cprintf(" *");
break;
default :
break;
}
}
Another GUI
#include
#include
#include
#include
#include"mouse.h"
int x,y;
void ComeIn(int,int,int);
void GoOut(int,int,int);
int Arcade_Game_Menu();
int Board_Game_Menu();
int About();
void Options_Arcade_Game_In(int,int,int,int);
void Options_Arcade_Game_Out(int,int,int,int);
void Options_Board_Game_In(int,int,int);
void Options_Board_Game_Out(int,int,int);
void RestoreGraphics();
void Preview_Chatur(int);
void Preview_Chitrakaar(int);
void Preview_Type(int);
void Preview_Tetris(int);
void Preview_DevilHunt(int);
void Preview_Glutton(int);
void Preview_Tank(int);
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
int i,j,k;
int mousex,mousey,button;
int del=0 ;
x=getmaxx()/2;
y=getmaxy()/2;
RestoreGraphics();
ComeIn(1,1,1);
if(initmouse()==0)
{
closegraph();
restorecrtmode();
exit(1);
}
restrictmouseptr(1,1,2*x-1,2*y-1);
settextstyle(GOTHIC_FONT,0,1);
// MAIN MENU // Activator loop //
while(1)
{
getmousepos(&button,&mousex,&mousey);
if((button&1)==1)
{
hidemouseptr();
while((button&1)==1)
{
getmousepos(&button,&mousex,&mousey);
}
showmouseptr();
getmousepos(&button,&mousex,&mousey);
if(mousex>x-235&&mousex
{
hidemouseptr();
setcolor(0);
outtextxy(x-240+5,y-60,"Various");
GoOut(0,1,1); Board_Game_Menu(); ComeIn(0,1,1);
showmouseptr();
}
else if(mousex>x-30&&mousex
{
hidemouseptr();
setcolor(0);
outtextxy(x-28+3,y-150,"Games");
GoOut(1,0,1); Arcade_Game_Menu(); ComeIn(1,0,1);
showmouseptr();
}
else if(mousex>x+175&&mousex
{
hidemouseptr();
setcolor(0);
outtextxy(x+190+3,y-60,"Exit");
GoOut(1,1,1);
break;
}
}
if(mousex>x-235&&mousex
{setcolor(5);outtextxy(x-240+5,y-60,"Various");del=1;}
else if(mousex>x+175&&mousex
{setcolor(5);outtextxy(x+190+3,y-60,"Exit");del=1;}
else if(mousex>x-30&&mousex
{setcolor(5);outtextxy(x-28+3,y-150,"Games");del=1;}
else if(del==1)
{
hidemouseptr();
setcolor(0);
outtextxy(x-240+5,y-60,"Various");
outtextxy(x-28+3,y-150,"Games");
outtextxy(x+190+3,y-60,"Exit");
del=0;
showmouseptr();
}
}//while 1
closegraph();
}
void ComeIn(int game,int edu,int about)
{
int i,j;
settextstyle(GOTHIC_FONT,0,1);
setcolor(4);
for(j=0;j<300;j+=5)
{
for(i=0;i<6;i++)
{
setcolor(1+i);
if(game==1)
circle(x-200-300+j,y-100,30+i);
if(edu==1)
circle(x-0,y-180-300+j,30+i);
if(about==1)
circle(x+200+300-j,y-100,30+i);
}
delay(20);
if(j<295)
for(i=0;i<6;i++)
{
setcolor(0);
if(game==1)
circle(x-200-300+j,y-100,30+i);
if(edu==1)
circle(x-0,y-180-300+j,30+i);
if(about==1)
circle(x+200+300-j,y-100,30+i);
}
}
}
void GoOut(int game,int edu,int about)
{
int i,j;
settextstyle(GOTHIC_FONT,0,1);
for(j=300;j>=0;j-=5)
{
for(i=5;i>=0;i--)
{
setcolor(1+i);
if(game==1)
circle(x-200-300+j,y-100,30+i);
if(edu==1)
circle(x-0,y-180-300+j,30+i);
if(about==1)
circle(x+200+300-j,y-100,30+i);
}
delay(20);
// if(j<295)
for(i=5;i>=0;i--)
{
setcolor(0);
if(game==1)
circle(x-200-300+j,y-100,30+i);
if(edu==1)
circle(x-0,y-180-300+j,30+i);
if(about==1)
circle(x+200+300-j,y-100,30+i);
}
}
}
int Arcade_Game_Menu()
{
int button,mousex,mousey;
int del=0;
Options_Arcade_Game_In(1,1,1,1);
settextstyle(GOTHIC_FONT,0,1);
showmouseptr();
while(1)
{
getmousepos(&button,&mousex,&mousey);
if((button&2)==2)
{
hidemouseptr();
while((button&2)==2)
{
getmousepos(&button,&mousex,&mousey);
}
showmouseptr();
}
if((button&1)==1)
{
hidemouseptr();
while((button&1)==1)
{
getmousepos(&button,&mousex,&mousey);
}
showmouseptr();
getmousepos(&button,&mousex,&mousey);
if(mousex>x-30&&mousex
{
hidemouseptr();
Options_Arcade_Game_Out(1,1,1,1);
return 0;
}
if(mousex>x-50&&mousex
{
//call related function
}
if(mousex>x-50&&mousex
{
//call related function
}
if(mousex>x-50&&mousex
{
//call related function
}
if(mousex>x-50&&mousex
{
//call related function
}
showmouseptr();
}
if(mousex>x-50&&mousex
{
if(del==0)
// Preview_Tank(DRAW);
settextstyle(GOTHIC_FONT,0,1);
setcolor(8);
outtextxy(x-19,y-43,"Tank");
del=1;
}
else if(mousex>x-50&&mousex
{
if(del==0)
// Preview_Glutton(DRAW);
settextstyle(GOTHIC_FONT,0,1);
setcolor(8);
outtextxy(x-28,y+7,"Glutton");
del=1;
}
else if(mousex>x-50&&mousex
{
if(del==0)
// Preview_DevilHunt(DRAW);
settextstyle(GOTHIC_FONT,0,1);
setcolor(8);
outtextxy(x-46,y+57,"Devil's Hunt");
del=1;
}
else if(mousex>x-50&&mousex
{
if(del==0)
// Preview_Tetris(DRAW);
settextstyle(GOTHIC_FONT,0,1);
setcolor(8);
outtextxy(x-20,y+107,"Tetris");
del=1;
}
else if(del==1)
{
hidemouseptr();
settextstyle(GOTHIC_FONT,0,1);
setcolor(0);
outtextxy(x-20,y+107,"Tetris");
outtextxy(x-46,y+57,"Devil's Hunt");
outtextxy(x-19,y-43,"Tank");
outtextxy(x-28,y+7,"Glutton");
del=0;
showmouseptr();
}
}
}
int Board_Game_Menu()
{
int button,mousex,mousey;
int del=0;
Options_Board_Game_In(1,1,1);
settextstyle(GOTHIC_FONT,0,1);
setcolor(14);
showmouseptr();
while(1)
{
getmousepos(&button,&mousex,&mousey);
if((button&2)==2)
{
hidemouseptr();
while((button&2)==2)
{
getmousepos(&button,&mousex,&mousey);
}
showmouseptr();
}
if((button&1)==1)
{
hidemouseptr();
while((button&1)==1)
{
getmousepos(&button,&mousex,&mousey);
}
showmouseptr();
getmousepos(&button,&mousex,&mousey);
if(mousex>x-235&&mousex
{
hidemouseptr();
Options_Board_Game_Out(1,1,1);
return 0;
}
if(mousex>x+50&&mousex
{
//call related function
}
if(mousex>x+50&&mousex
{
//call related function
}
if(mousex>x+50&&mousex
{
//call related function
}
showmouseptr();
}
if(mousex>x+50&&mousex
{
if(del==0)
// Preview_Chatur(DRAW);
setcolor(8);
settextstyle(GOTHIC_FONT,0,1);
outtextxy(x+65,y+7,"Tryster");del=1;
}
else if(mousex>x+50&&mousex
{
if(del==0)
// Preview_Chitrakaar(DRAW);
setcolor(8);
settextstyle(GOTHIC_FONT,0,1);
outtextxy(x+62,y+57,"Chitrakaar");
del=1;
}
else if(mousex>x+50&&mousex
{
if(del==0)
// Preview_Type(DRAW);
setcolor(8);
settextstyle(GOTHIC_FONT,0,1);
outtextxy(x+50,y+107,"Typing Tutor");
del=1;
}
else if(del==1)
{
hidemouseptr();
// Preview_Chitrakaar(DELETE);
// Preview_Chatur(DELETE);
// Preview_Type(DELETE);
setcolor(0);
outtextxy(x+65,y+7,"Tryster");
outtextxy(x+62,y+57,"Chitrakaar");
outtextxy(x+50,y+107,"Typing Tutor");
del=0;
showmouseptr();
}
}
}
void Options_Arcade_Game_In(int tank,int glutton,int tetris,int devilhunt)
{
int i,j;
for(i=0;i<350;i++)
{
for(j=0;j<15;j++)
{
setcolor(j/3);
line(x-400+i,y-25+j,x-300+i,y-25+j);
line(x+400-i,y+25+j,x+300-i,y+25+j);
line(x-400+i,y+75+j,x-300+i,y+75+j);
line(x+400-i,y+125+j,x+300-i,y+125+j);
}
delay(3);
if(i<349)
for(j=0;j<15;j++)
{
setcolor(0);
line(x-400+i,y-25+j,x-300+i,y-25+j);
line(x+400-i,y+25+j,x+300-i,y+25+j);
line(x-400+i,y+75+j,x-300+i,y+75+j);
line(x+400-i,y+125+j,x+300-i,y+125+j);
}
}
}
void Options_Arcade_Game_Out(int tank,int glutton,int tetris,int devilhunt)
{
int i,j;
for(i=349;i>=0;i--)
{
for(j=0;j<15;j++)
{
setcolor(j/3);
line(x-400+i,y-25+j,x-300+i,y-25+j);
line(x+400-i,y+25+j,x+300-i,y+25+j);
line(x-400+i,y+75+j,x-300+i,y+75+j);
line(x+400-i,y+125+j,x+300-i,y+125+j);
}
delay(3);
for(j=0;j<15;j++)
{
setcolor(0);
line(x-400+i,y-25+j,x-300+i,y-25+j);
line(x+400-i,y+25+j,x+300-i,y+25+j);
line(x-400+i,y+75+j,x-300+i,y+75+j);
line(x+400-i,y+125+j,x+300-i,y+125+j);
}
}
}
void Options_Board_Game_In(int chatura,int chitrakaar,int typetut)
{
int i,j;
for(i=0;i<250;i++)
{
for(j=0;j<15;j++)
{
setcolor(j/3);
line(x+400-i,y+25+j,x+300-i,y+25+j);
line(x+400-i,y+75+j,x+300-i,y+75+j);
line(x+400-i,y+125+j,x+300-i,y+125+j);
}
delay(3);
if(i<249)
for(j=0;j<15;j++)
{
setcolor(0);
line(x+400-i,y+25+j,x+300-i,y+25+j);
line(x+400-i,y+75+j,x+300-i,y+75+j);
line(x+400-i,y+125+j,x+300-i,y+125+j);
}
}
}
void Options_Board_Game_Out(int chatura,int chitrakaar,int typetut)
{
int i,j;
for(i=249;i>=0;i--)
{
for(j=0;j<15;j++)
{
setcolor(j/3);
line(x+400-i,y+25+j,x+300-i,y+25+j);
line(x+400-i,y+75+j,x+300-i,y+75+j);
line(x+400-i,y+125+j,x+300-i,y+125+j);
}
delay(3);
for(j=0;j<15;j++)
{
setcolor(0);
line(x+400-i,y+25+j,x+300-i,y+25+j);
line(x+400-i,y+75+j,x+300-i,y+75+j);
line(x+400-i,y+125+j,x+300-i,y+125+j);
}
}
}
void RestoreGraphics()
{
struct palettetype pal;
getpalette(&pal);
setrgbpalette(pal.colors[1],10,0,0);
setrgbpalette(pal.colors[2],15,5,5);
setrgbpalette(pal.colors[3],20,10,10);
setrgbpalette(pal.colors[4],25,15,15);
setrgbpalette(pal.colors[5],30,20,20);
setrgbpalette(pal.colors[6],35,25,25);
setrgbpalette(pal.colors[13],50,50,31);
}
Face Maker GUI
#include
#include
#include
#include
#include"mouse.h"
#define SMILE 0
#define LAUGH 1
#define CRY 2
#define ANGRY 3
#define ANNOY 4
void Face(int);
void press_button(int);
void Screen();
int main()
{
int gd=DETECT,gm,o;
initgraph(&gd,&gm,"");
union REGS ii,oo;
int x,y;
x=getmaxx()/2;
y=getmaxy()/2;
Screen();
if(initmouse()==0)
{
closegraph();
restorecrtmode();
exit(1);
}
restrictmouseptr(x-290,y-225,x+290,y+225);
showmouseptr();
int button,mx,my;
while(1)
{
getmousepos(&button,&mx,&my);
if(kbhit()||(button&1)==1) // if left button is pressed !
{
if((button&1)==1||kbhit()) // if left button is pressed !
hidemouseptr(); // hiding the mouse pointer
while((button&1)==1) // if left button is kept pressed
{
getmousepos(&button,&mx,&my);
}
//interrupt issue to scan the ascii ans scan codes of the key hit
if(kbhit())
{
ii.h.ah=0;
int86(22,&ii,&oo);
}
else
{
oo.h.ah=450;//bogus value
}
settextstyle(DEFAULT_FONT,0,1);
if(oo.h.ah==31||(mx>x-175&&mx
{
setcolor(8);
outtextxy(x-170+1,y+121,"Smile");
press_button(1);
setcolor(15);
outtextxy(x-170+1,y+121,"Smile");
setcolor(5);
outtextxy(x-170+1,y+121,"S");
Face(SMILE);
}
else if(oo.h.ah==38||(mx>x-100&&mx
{
setcolor(8);
outtextxy(x-95+1,y+121,"Laugh");
press_button(2);
setcolor(15);
outtextxy(x-95+1,y+121,"Laugh");
setcolor(5);
outtextxy(x-95+1,y+121,"L");
Face(LAUGH);
}
else if(oo.h.ah==46||(mx>x-25&&mx
{
setcolor(8);
outtextxy(x-13+1,y+121,"Cry");
press_button(3);
setcolor(15);
outtextxy(x-13+1,y+121,"Cry");
setcolor(5);
outtextxy(x-13+1,y+121,"C");
Face(CRY);
}
else if(oo.h.ah==30||(mx>x+50&&mx
{
setcolor(8);
outtextxy(x+55+1,y+121,"Angry");
press_button(4);
setcolor(15);
outtextxy(x+55+1,y+121,"Angry");
setcolor(5);
outtextxy(x+55+1,y+121,"A");
Face(ANGRY);
}
else if(oo.h.ah==49||(mx>x+125&&mx
{
setcolor(8);
outtextxy(x+131+1,y+121,"aNnoy");
press_button(5);
setcolor(15);
outtextxy(x+131+1,y+121,"aNnoy");
setcolor(5);
outtextxy(x+131+1,y+121," N");
Face(ANNOY);
}
else if(oo.h.ah==1||oo.h.ah==45||(mx>x-15&&mx
{
return 0;
}
showmouseptr();
}
}
}
void press_button(int which)
{
int x,y;
x=getmaxx()/2+75*(which-1);
y=getmaxy()/2;
setcolor(8);
setlinestyle(SOLID_LINE,0,3);
rectangle(x-175,y+100,x-125,y+150);
setlinestyle(SOLID_LINE,0,1);
setcolor(15);
for(int o=0;o<3;o++)
{
line(x-176+o,y+151-o,x-124,y+151-o);
line(x-124-o,y+100+o,x-124-o,y+151);
}
delay(200);
setcolor(15);
setlinestyle(SOLID_LINE,0,3);
rectangle(x-175,y+100,x-125,y+150);
setlinestyle(SOLID_LINE,0,1);
setcolor(8);
for(o=0;o<3;o++)
{
line(x-176+o,y+151-o,x-124,y+151-o);
line(x-124-o,y+100+o,x-124-o,y+151);
}
}
void Screen()
{
int x,y;
x=getmaxx()/2;
y=getmaxy()/2;
setlinestyle(SOLID_LINE,0,3);
rectangle(x-175,y+100,x-125,y+150);
rectangle(x-100,y+100,x-50,y+150);
rectangle(x-25,y+100,x+25,y+150);
rectangle(x+100,y+100,x+50,y+150);
rectangle(x+175,y+100,x+125,y+150);
rectangle(x-15,y+170,x+15,y+200);
setfillstyle(SOLID_FILL,6);
floodfill(x,y,15);
setfillstyle(SOLID_FILL,7);
for(int o=0;o<5;o++)
floodfill(x-150+o*75,y+135,15);
setlinestyle(SOLID_LINE,0,1);
setcolor(8);
for(int oo=0;oo<5;oo++)
for(o=0;o<3;o++)
{
line(x-176+75*oo+o,y+151-o,x-124+75*oo,y+151-o);
line(x-124+75*oo-o,y+100+o,x-124+75*oo-o,y+151);
}
setcolor(15);
outtextxy(x+131+1,y+121,"aNnoy");
setcolor(5);
outtextxy(x+131+1,y+121," N");
setcolor(15);
outtextxy(x+55+1,y+121,"Angry");
setcolor(5);
outtextxy(x+55+1,y+121,"A");
setcolor(15);
outtextxy(x-13+1,y+121,"Cry");
setcolor(5);
outtextxy(x-13+1,y+121,"C");
setcolor(15);
outtextxy(x-170+1,y+121,"Smile");
setcolor(5);
outtextxy(x-170+1,y+121,"S");
setcolor(15);
outtextxy(x-95+1,y+121,"Laugh");
setcolor(5);
outtextxy(x-95+1,y+121,"L");
outtextxy(x-3,y+181,"X");
}
void Face(int mood)
{
int x,y;
x=getmaxx()/2;
y=getmaxy()/2;
int loop;
setfillstyle(SOLID_FILL,6);
bar(x-100,y-150,x+100,y+50);
setcolor(5);
circle(x,y-50,40);
setfillstyle(SOLID_FILL,14);
floodfill(x,y-50,5);
switch(mood)
{
case SMILE:
setcolor(RED);
arc(x,y-55,210,330,30);
circle(x-15,y-60,5);
circle(x+15,y-60,5);
break;
case LAUGH:
setcolor(RED);
arc(x,y-55,210,330,30);
arc(x,y-70,230,310,40);
circle(x-15,y-60,5);
circle(x+15,y-60,5);
setfillstyle(SOLID_FILL,15);
floodfill(x,y-28,RED);
break;
case CRY:
setcolor(RED);
arc(x,y-5,50,130,30);
circle(x-15,y-60,5);
circle(x+15,y-60,5);
for(loop=0;loop<2;loop++)
{
circle(x-15,y-50+5*loop,2-loop);
circle(x+15,y-50+5*loop,2-loop);
}
break;
case ANGRY:
setcolor(RED);
ellipse(x-15,y-60,0,360,5,7);
ellipse(x+15,y-60,0,360,5,7);
arc(x,y-5,50,130,30);
break;
case ANNOY:
setcolor(RED);
arc(x-20,y-30,50,130,10);
arc(x-7,y-45,230,310,10);
arc(x+7,y-30,50,130,10);
arc(x+20,y-45,230,310,10);
ellipse(x-15,y-60,0,360,5,6);
ellipse(x+15,y-60,0,360,5,6);
break;
default: break;
}
}
Subscribe to:
Post Comments (Atom)
Translate
Network Blogs
Labels
Blog Archive
-
▼
2010
(81)
-
▼
May
(10)
- Beep codes for IBM, AMI and Phoenix BIOS
- Beep Code Manual
- "Spyware", "Mal-ware", "hijackers", "Dialers"
- Next Wave of Growth
- 3D game demo embedded for your website
- source code to create pacman type game using C++
- creating typing tutor using C++
- source code for games using C++
- i-phone game development
- Social Media Marketing Tips
-
▼
May
(10)
Some Useful WebSites
Tweet Pictures of virtualinfocom
Followers
Blog Archive
-
▼
2010
(81)
-
▼
May
(10)
- Beep codes for IBM, AMI and Phoenix BIOS
- Beep Code Manual
- "Spyware", "Mal-ware", "hijackers", "Dialers"
- Next Wave of Growth
- 3D game demo embedded for your website
- source code to create pacman type game using C++
- creating typing tutor using C++
- source code for games using C++
- i-phone game development
- Social Media Marketing Tips
-
▼
May
(10)
About Me
Search This Blog
virtualinfocom's Fan Box
virtualinfocom on Facebook
Comments (0)
Post a Comment