Subscribe Our Channel

header ads

Search This Blog

Friday, December 31, 2021

HAPPY NEW YEAR C++ PROGRAMMING

 



//_________________**** WISH YOU ALL HAPPY NEW YEAR ***____________________//

//____________ WELCOME ALL OF YOU ON ROHIT TECH STUDY CHANNEL _____________//

//_________________ C++ PROGRAM TO WISH HAPPY NEW YEAR ____________________//


#include<iostream.h>

#include<conio.h>

#include<dos.h>

#include<stdlib.h>

#include<graphics.h>

void y_2021();

void next();

void main()


{

int gd=DETECT,gm;

initgraph(&gd,&gm,"c:\\tc\\bgi");

y_2021();

next();

getch();

closegraph();

}


void y_2021()

{


for(int r=0;r<500;r++)

{

circle(20,300,10);

setcolor(12);

settextstyle(10,0,4);

outtextxy(10,290,"2");


setcolor(15);

line(20,350,18,400);  // left

line(20,350,22,400);  //right

line(0,400,700,400);

line(10,320,0,350);

line(33,320,40,350);


circle(70,300,10);

settextstyle(10,0,4);

outtextxy(57,290,"0");

line(70,350,68,400);     // left

line(70,350,72,400);     //right

line(0,400,700,400);


line(57,320,47,350);

line(82,320,90,350);


circle(120,300,10);

settextstyle(10,0,4);

setcolor(14);

outtextxy(110,290,"2");


setcolor(15);

line(120,350,118,400);    // left

line(120,350,122,400);   //right

line(0,400,700,400);

line(110,320,100,350);

line(133,320,142,350);


circle(170+r,300,10);

settextstyle(10,0,4);

setcolor(13);

outtextxy(156+r,290,"1");

setcolor(15);


if(r%10==0)

{

line(170+r,350,158+r,400);  // left

line(170+r,350,182+r,400);  //right


delay(30);

}

else

{

line(170+r,350,168+r,400);  // left

line(170+r,350,172+r,400);  //right

delay(20);

}


line(0,400,700,400);

line(157+r,320,147+r,350);

line(180+r,320,188+r,350);

delay(20);

cleardevice();

}


for(int s=0;s<560;s++)   //second

{

circle(20,300,10);

settextstyle(10,0,4);

setcolor(12);

outtextxy(10,290,"2");


setcolor(15);

line(20,350,18,400);  // left

line(20,350,22,400);  //right

line(0,400,700,400);

line(10,320,0,350);

line(33,320,40,350);


circle(70,300,10);

settextstyle(10,0,4);

outtextxy(57,290,"0");


line(70,350,68,400);   // left

line(70,350,72,400);   //right

line(0,400,700,400);

line(57,320,47,350);

line(82,320,90,350);


circle(120,300,10);

settextstyle(10,0,4);

setcolor(14);

outtextxy(110,290,"2");


setcolor(15);

line(120,350,118,400);  // left

line(120,350,122,400);  //right

line(0,400,700,400);

line(110,320,100,350);

line(133,320,142,350);


circle(720-s,300,10);

settextstyle(10,0,4);

setcolor(13);

outtextxy(710-s,290,"2");


setcolor(15);

if(s%10==0)

{

line(720-s,350,704-s,400);  // left

line(720-s,350,740-s,400);//right

delay(20);

}


else

{

line(720-s,350,718-s,400);

line(720-s,350,722-s,400);

delay(20);

}


line(0,400,700,400);

line(714-s,320,700-s,350);

line(730-s,320,742-s,350);


settextstyle(7,0,4);

setcolor(10);

outtextxy(750-s,350,"HAPPY");


setcolor(15);


settextstyle(7,0,4);

setcolor(11);

outtextxy(880-s,350,"NEW");


setcolor(15);


settextstyle(7,0,4);

setcolor(12);

outtextxy(960-s,350," YEAR");


setcolor(15);


setcolor(BLUE);

line(740-s,382,1070-s,382);


setcolor(8);

circle(760-s,391,9);

circle(840-s,391,9);

circle(939-s,391,9);

circle(1030-s,391,9);


setcolor(15);

delay(35);

cleardevice();

}


circle(20,300,10);

settextstyle(10,0,4);


setcolor(12);

outtextxy(10,290,"2");


setcolor(15);


line(20,350,18,400);    // left

line(20,350,22,400);   //right

line(0,400,700,400);

line(10,320,0,350);

line(33,320,40,350);


circle(70,300,10);

settextstyle(10,0,4);

outtextxy(57,290,"0");

line(70,350,68,400);      // left

line(70,350,72,400);     //right

line(0,400,700,400);

line(57,320,47,350);

line(82,320,90,350);


circle(120,300,10);

settextstyle(10,0,4);

setcolor(14);

outtextxy(110,290,"2");


setcolor(15);

line(120,350,118,400);      // left

line(120,350,122,400);      //right

line(0,400,700,400);

line(110,320,100,350);

line(133,320,142,350);

}


void next()

{

for(int j=0;j<10;j++)

{

setcolor(15);

circle(20,300,10);

settextstyle(10,0,4);


setcolor(12);

outtextxy(10,290,"2");


setcolor(15);

line(20,350,18,400);  // left

line(20,350,22,400);  //right

line(0,400,700,400);

line(10,320,0,350);

line(33,320,40,350);


circle(70,300,10);

settextstyle(10,0,4);

outtextxy(57,290,"0");

line(70,350,68,400);     // left

line(70,350,72,400);    //right

line(0,400,700,400);

line(57,320,47,350);

line(82,320,90,350);


circle(120,300,10);

settextstyle(10,0,4);


setcolor(14);

outtextxy(110,290,"2");


setcolor(15);

line(120,350,118,400);  // left

line(120,350,122,400); //right

line(0,400,700,400);

line(110,320,100,350);

line(133,320,142,350);


circle(170,300,10);

settextstyle(10,0,4);


setcolor(13);

outtextxy(156,290,"2");


setcolor(15);

line(170,350,168,400);  // left

line(170,350,172,400);//right

line(0,400,700,400);

line(159,320,147,350);

line(175,317,188,350);


settextstyle(7,0,4);

setcolor(10);

outtextxy(200,350,"HAPPY");


setcolor(15);

settextstyle(7,0,4);


setcolor(11);

outtextxy(320,350,"NEW");


setcolor(15);


settextstyle(7,0,4);

setcolor(12);

outtextxy(400,350,"YEAR");


setcolor(15);


setcolor(BLUE);

line(200,382,500,382);


setcolor(8);


circle(230,391,9);

circle(300,391,9);

circle(370,391,9);

circle(450,391,9);


if(j%2==0)

{

for(int i=0;i<60;i++)

{


setcolor(15);

circle(20,300,10);

settextstyle(10,0,4);


setcolor(12);

outtextxy(10,290,"2");


setcolor(15);

line(20,350,18,400);  // left

line(20,350,22,400);//right

line(0,400,700,400);

line(10,320,0,350);

line(33,320,40,350);


circle(70,300,10);

settextstyle(10,0,4);

outtextxy(57,290,"0");

line(70,350,68,400);     // left

line(70,350,72,400);    //right

line(0,400,700,400);

line(57,320,47,350);

line(82,320,90,350);



circle(120,300,10);

settextstyle(10,0,4);


setcolor(14);

outtextxy(110,290,"2");


setcolor(15);

line(120,350,118,400);  // left

line(120,350,122,400);  //right


line(0,400,700,400);

line(110,320,100,350);

line(133,320,142,350);


circle(170,300,10);

settextstyle(10,0,4);


setcolor(13);

outtextxy(156,290,"2");


setcolor(15);

line(170,350,168,400);  // left

line(170,350,172,400);  //right

line(0,400,700,400);

line(159,320,147,350);

line(175,317,188,350);


settextstyle(7,0,4);

setcolor(10);

outtextxy(200,350,"HAPPY");


setcolor(15);


settextstyle(7,0,4);

setcolor(11);

outtextxy(320,350,"NEW");


setcolor(15);


settextstyle(7,0,4);

setcolor(12);

outtextxy(400,350,"YEAR");


setcolor(15);


setcolor(BLUE);

line(200,382,500,382);


setcolor(8);

circle(230,391,9);

circle(300,391,9);

circle(370,391,9);

circle(450,391,9);


setcolor(2);

outtextxy(200-i,70-i,"'");

outtextxy(204,70-i,"'");


outtextxy(208+i,70+i,"'");

outtextxy(210-i,74+i,"'");


outtextxy(210-i,78-i,"'");

outtextxy(210+i,82+i,"'");


outtextxy(199+i,74-i,"'");

outtextxy(203+i,74-i,"'");

outtextxy(206-i,74-i,"'");

outtextxy(193-i,70-i,"'");


outtextxy(195,70-i,"'");

outtextxy(188+i,70+i,"'");

outtextxy(184-i,44+i,"'");


outtextxy(222-i,88-i,"'");

outtextxy(226+i,62+i,"'");

outtextxy(229+i,54-i,"'");

outtextxy(201+i,64-i,"'");

outtextxy(205-i,70-i,"'");


outtextxy(199+i+2,78-i,"'");

outtextxy(203-i,78-i+2,"'");

outtextxy(206+i+1,78-i,"'");


outtextxy(199-i,82+i,"'");

outtextxy(203+i,82+6-i,"'");

outtextxy(206+i,82-i,"'");


setcolor(13);

outtextxy(300-i,70-i,"'");

outtextxy(304,70-i,"'");

outtextxy(308+i,70+i,"'");

outtextxy(310-i,74+i,"'");


outtextxy(310-i,78-i,"'");

outtextxy(310+i,82+i,"'");

outtextxy(299+i,74-i,"'");


outtextxy(303+i,74-i,"'");

outtextxy(306-i,74-i,"'");


outtextxy(293-i,70-i,"'");


outtextxy(295,70-i,"'");


outtextxy(288+i,70+i,"'");


outtextxy(284-i,44+i,"'");


outtextxy(322-i,88-i,"'");


outtextxy(326+i,62+i,"'");


outtextxy(329+i,54-i,"'");


outtextxy(301+i,64-i,"'");


outtextxy(205-i,70-i,"'");


  outtextxy(299+i+2,78-i,"'");


outtextxy(303-i,78-i+2,"'");


outtextxy(306+i+1,78-i,"'");




outtextxy(299-i,82+i,"'");


outtextxy(303+i,82+6-i,"'");


outtextxy(306+i,82-i,"'");



setcolor(YELLOW);


outtextxy(400-i,70-i,"'");


outtextxy(404,70-i,"'");


outtextxy(408+i,70+i,"'");


outtextxy(410-i,74+i,"'");


outtextxy(410-i,78-i,"'");


outtextxy(410+i,82+i,"'");


outtextxy(399+i,74-i,"'");


outtextxy(403+i,74-i,"'");


outtextxy(406-i,74-i,"'");



outtextxy(393-i,70-i,"'");


outtextxy(395,70-i,"'");


outtextxy(388+i,70+i,"'");


outtextxy(384-i,44+i,"'");


outtextxy(422-i,88-i,"'");


outtextxy(426+i,62+i,"'");


outtextxy(429+i,54-i,"'");


outtextxy(401+i,64-i,"'");


outtextxy(205-i,70-i,"'");




outtextxy(399+i+2,78-i,"'");


outtextxy(403-i,78-i+2,"'");


outtextxy(406+i+1,78-i,"'");




outtextxy(399-i,82+i,"'");


outtextxy(403+i,82+6-i,"'");


outtextxy(406+i,82-i,"'");




setcolor(6);


outtextxy(500-i,80-i,"'");


outtextxy(504,80-i,"'");


outtextxy(508+i,80+i,"'");


outtextxy(510-i,84+i,"'");


outtextxy(510-i,88-i,"'");


outtextxy(510+i,92+i,"'");


outtextxy(499+i,84-i,"'");


outtextxy(503+i,84-i,"'");


outtextxy(506-i,84-i,"'");



outtextxy(493-i,80-i,"'");


outtextxy(495,80-i,"'");


outtextxy(488+i,80+i,"'");


outtextxy(484-i,54+i,"'");


outtextxy(522-i,98-i,"'");


outtextxy(526+i,72+i,"'");


outtextxy(529+i,64-i,"'");


outtextxy(501+i,74-i,"'");


outtextxy(405-i,80-i,"'");



outtextxy(499+i+2,88-i,"'");


outtextxy(503-i,88-i+2,"'");


outtextxy(506+i+1,88-i,"'");




outtextxy(499-i,82+i,"'");


outtextxy(503+i,82+6-i,"'");


outtextxy(506+i,82-i,"'");




setcolor(9);


outtextxy(100-i,90-i,"'");


outtextxy(104,90-i,"'");


outtextxy(108+i,90+i,"'");


outtextxy(110-i,94+i,"'");


outtextxy(110-i,98-i,"'");


outtextxy(110+i,92+i,"'");


outtextxy(199+i,94-i,"'");


outtextxy(103+i,94-i,"'");


outtextxy(106-i,94-i,"'");



outtextxy(193-i,90-i,"'");


outtextxy(195,90-i,"'");


outtextxy(188+i,90+i,"'");


outtextxy(184-i,64+i,"'");


outtextxy(122-i,98-i,"'");


outtextxy(126+i,82+i,"'");


outtextxy(129+i,74-i,"'");


outtextxy(101+i,84-i,"'");


outtextxy(105-i,90-i,"'");



outtextxy(199+i+2,98-i,"'");


outtextxy(103-i,98-i+2,"'");


outtextxy(106+i+1,98-i,"'");




outtextxy(199-i,92+i,"'");


outtextxy(103+i,92+6-i,"'");


outtextxy(106+i,92-i,"'");



setcolor(5);


outtextxy(100-i,190-i,"'");


outtextxy(104,190-i,"'");


outtextxy(108+i,190+i,"'");


outtextxy(110-i,194+i,"'");


outtextxy(110-i,198-i,"'");


outtextxy(110+i,192+i,"'");


outtextxy(199+i,194-i,"'");


outtextxy(103+i,194-i,"'");


outtextxy(106-i,194-i,"'");




outtextxy(193-i,190-i,"'");


outtextxy(195,190-i,"'");


outtextxy(188+i,190+i,"'");


outtextxy(184-i,164+i,"'");


outtextxy(122-i,198-i,"'");


outtextxy(126+i,182+i,"'");


outtextxy(129+i,174-i,"'");


outtextxy(101+i,184-i,"'");


outtextxy(105-i,190-i,"'");




outtextxy(199+i+2,198-i,"'");


outtextxy(103-i,198-i+2,"'");


outtextxy(106+i+1,198-i,"'");




outtextxy(199-i,192+i,"'");


outtextxy(103+i,192+6-i,"'");


outtextxy(106+i,192-i,"'");



setcolor(3);


outtextxy(500-i,130-i,"'");


outtextxy(504,130-i,"'");


outtextxy(508+i,130+i,"'");


outtextxy(510-i,134+i,"'");


outtextxy(510-i,138-i,"'");


outtextxy(510+i,132+i,"'");


outtextxy(499+i,134-i,"'");


outtextxy(503+i,134-i,"'");


outtextxy(506-i,134-i,"'");



outtextxy(493-i,130-i,"'");


outtextxy(495,130-i,"'");


outtextxy(488+i,130+i,"'");


outtextxy(484-i,114+i,"'");


outtextxy(522-i,138-i,"'");


outtextxy(526+i,112+i,"'");


outtextxy(529+i,124-i,"'");


outtextxy(501+i,124-i,"'");


outtextxy(405-i,130-i,"'");




  outtextxy(499+i+2,138-i,"'");


outtextxy(503-i,138-i+2,"'");


outtextxy(506+i+1,138-i,"'");




outtextxy(499-i,132+i,"'");


outtextxy(503+i,132+6-i,"'");


outtextxy(506+i,132-i,"'");




setcolor(10);


outtextxy(400-i,190-i,"'");


outtextxy(404,190-i,"'");


outtextxy(408+i,190+i,"'");


outtextxy(410-i,194+i,"'");


outtextxy(410-i,198-i,"'");


outtextxy(410+i,192+i,"'");


outtextxy(399+i,194-i,"'");


outtextxy(403+i,194-i,"'");


outtextxy(406-i,194-i,"'");




outtextxy(493-i,190-i,"'");


outtextxy(495,190-i,"'");


outtextxy(488+i,190+i,"'");


outtextxy(484-i,164+i,"'");


outtextxy(422-i,198-i,"'");


outtextxy(426+i,162+i,"'");


outtextxy(429+i,174-i,"'");


outtextxy(401+i,174-i,"'");


outtextxy(305-i,190-i,"'");




outtextxy(399+i+2,198-i,"'");


outtextxy(403-i,198-i+2,"'");


outtextxy(406+i+1,198-i,"'");




outtextxy(399-i,192+i,"'");


outtextxy(403+i,192+6-i,"'");


outtextxy(406+i,192-i,"'");


delay(6);

cleardevice();


}

}


setcolor(15);

circle(20,300,10);


settextstyle(10,0,4);

setcolor(12);

outtextxy(10,290,"2");


setcolor(15);

line(20,350,18,400);  // left

line(20,350,22,400);  //right


line(0,400,700,400);

line(10,320,0,350);

line(33,320,40,350);


circle(70,300,10);

settextstyle(10,0,4);

outtextxy(57,290,"0");


line(70,350,68,400);     // left

line(70,350,72,400);    //right

line(0,400,700,400);

line(57,320,47,350);

line(82,320,90,350);


circle(120,300,10);

settextstyle(10,0,4);

setcolor(14);

outtextxy(110,290,"2");


setcolor(15);

line(120,350,118,400);  // left

line(120,350,122,400);//right

line(0,400,700,400);

line(110,320,100,350);

line(133,320,142,350);


circle(170,300,10);

settextstyle(10,0,4);


setcolor(13);

outtextxy(156,290,"2");


setcolor(15);

line(170,350,168,400);  // left

line(170,350,172,400);    //right

line(0,400,700,400);

line(159,320,147,350);

line(175,317,188,350);


settextstyle(7,0,4);

setcolor(10);

outtextxy(200,350,"HAPPY");


setcolor(15);


settextstyle(7,0,4);

setcolor(11);

outtextxy(320,350,"NEW");


setcolor(15);


settextstyle(7,0,4);

setcolor(12);

outtextxy(400,350,"YEAR");


setcolor(15);

}


setcolor(BLUE);

line(200,382,500,382);


setcolor(8);

circle(230,391,9);

circle(300,391,9);

circle(370,391,9);

circle(450,391,9);


settextstyle(10,0,4);

setcolor(11);

outtextxy(200,250,"WISH");

setcolor(13);

outtextxy(350,250,"YOU");

setcolor(14);

outtextxy(480,250,"ALL");


}

Download Source Code

Thursday, December 30, 2021

HAPPY NEW YEAR C++ PROGRAMMING | NEW YEAR 2022 C PROGRAMMING





//____________ WELCOME ALL OF YOU ON ROHIT TECH STUDY CHANNEL _____________//

//----------------- C++ PROGRAM TO WISH HAPPY NEW YEAR -------------------//


#include<stdio.h>

#include<conio.h>

#include<iostream.h>

#include<dos.h>

#include<stdlib.h>

#include<graphics.h>


void Entry();

void Entry2();

void shoot();

void shootagain();

void area();

void explode(int,int,int);

void main()

{


int gd=DETECT,gm;

initgraph(&gd,&gm,"c:\\tc\\bgi");


Entry();

Entry2();

shoot();

getch();

closegraph();

}


void shoot()

{

int i=0;

int x=0,y=480,x1=15,y1=460;

while(i<350)

{

area();

line(x+i,y-i,x1+i,y1-i);

delay(50);

i=i+10;

cleardevice();

}

explode(x+350,y-350,5);

shootagain();

}

void shootagain()

{

int i=0;

int x=600,y=480,x1=585,y1=460;

while(i<250)

{

setcolor(15);

area();

line(x-i,y-i,x1-i,y1-i);

delay(30);

i=i+10;

cleardevice();

}

explode(x-300,y-300,5);

}


void explode(int x,int y,int r)

{

int k,j,interval=0;

for(k=0;k<2;k++)

{

interval=interval+50;

for(j=0;j<interval;j++)

{

area();

setcolor(BLACK);

setcolor(rand()/15);

// horizontal left and right

circle(x+j,y,r+k);

circle(x-j,y,r+k);

//vertical up and down

circle(x,y+j,r+k);

circle(x,y-j,r+k);

//slighten down

circle(x+j,y+j,r+k);

circle(x-j,y-j,r+k);

//slighten up

circle(x-j,y+j,r+k);

circle(x+j,y-j,r+k);

delay(30);

cleardevice();

}

}

}

void area()

{

//Area

setcolor(15);

line(0,350,600,350);


setcolor(2);

rectangle(0,350,100,150);

rectangle(40,350,60,300);


setcolor(9);

rectangle(10,170,30,200);

rectangle(70,170,90,200);


setcolor(10);

rectangle(10,230,30,260);

rectangle(70,230,90,260);


setcolor(12);

rectangle(100,350,180,250);


setcolor(11);

line(100,250,140,180);

line(180,250,140,180);


setcolor(13);

rectangle(110,280,130,300);

rectangle(150,280,170,300);

rectangle(130,350,160,330);


setcolor(14);

rectangle(180,350,350,300);

rectangle(190,310,220,330);

rectangle(340,310,310,330);


setcolor(4);

rectangle(370,350,440,150);

rectangle(385,350,405,300);


setcolor(2);

rectangle(380,170,400,200);

rectangle(410,170,430,200);


setcolor(11);

rectangle(380,230,400,260);

rectangle(410,230,430,260);


setcolor(11);

settextstyle(BOLD_FONT,HORIZ_DIR,1);

outtextxy(250,10,"HAPPY NEW YEAR");


setcolor(13);

settextstyle(TRIPLEX_SCR_FONT,HORIZ_DIR,3);

outtextxy(230,60,"GOOD BYE 2021");


setcolor(10);

settextstyle(DEFAULT_FONT,HORIZ_DIR,3);

outtextxy(250,100,"WELCOME 2022");


setcolor(14);

settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1);

outtextxy(532,324,"ROHIT TECH STUDY");

}


void Entry2()

{

int i;

char a[5];

settextjustify(CENTER_TEXT, CENTER_TEXT);

settextstyle(DEFAULT_FONT,HORIZ_DIR,10);

setcolor(13);

for(i=10;i>=0;i--)

{

sprintf(a,"%d",i);

outtextxy(getmaxx()/2,getmaxy()/2,a);

delay(1000);


if(i==0)

break;

cleardevice();

}

cleardevice();

}


void Entry()

{


for(int r=0;r<2500;r++)

{

setcolor(15);

circle(170,300,10);

settextstyle(10,0,4);


setcolor(13);

outtextxy(156,290,"0");


setcolor(10);

line(170,350,168,400);  // left

line(170,350,180,400);  //right


setcolor(14);

line(0,400,700,400);

line(157,320,147,350);

line(180,317,188,350);

settextstyle(2,0,7);

if(r==30)

{

setcolor(10);

outtextxy(250,295,"A NEW YEAR MEANS");

outtextxy(250,320,"A NEW CHAPTER.");

}

if(r==370)

{

cleardevice();

}

if(r==800)

{

setcolor(11);

outtextxy(250,295,"I HOPE 2022 IS AN INCREDIBLE");

outtextxy(250,320,"PART OF YOUR STORY.");

}

if(r==1400)

{

cleardevice();

}

if(r==1800)

{

setcolor(13);

outtextxy(250,295,"LETS GET STARTED 2022");

}

if(r==2400)

{

cleardevice();

break;

}

       }

      cleardevice();

Download source code

HAPPY NEW YEAR C++ PROGRAMMING | NEW YEAR WISH PROGRAMMING

 




//HAPPY NEW YEAR ALL OF YOU BY ROHIT  TECH STUDY

//WISHES HAPPY NEW YEAR PROGRAM


#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void shoot();

void shootagain();

void area();

void explode(int,int,int);

void main()

{

int gm,gd=DETECT;

initgraph(&gd,&gm,"C:\\TC\\BGI");

shoot();

getch();

closegraph();

}

void shoot()

{

int i=0;

int x=0,y=480,x1=15,y1=460;

while(i<350)

{

area();

line(x+i,y-i,x1+i,y1-i);

delay(50);

i=i+10;

cleardevice();

}

explode(x+350,y-350,5);

shootagain();

}

void shootagain()

{

int i=0;

int x=600,y=480,x1=585,y1=460;

while(i<250)

{

setcolor(15);

area();

line(x-i,y-i,x1-i,y1-i);

delay(30);

i=i+10;

cleardevice();

}

explode(x-300,y-300,5);

}


void explode(int x,int y,int r)

{

int k,j,interval=0;

for(k=0;k<2;k++)

{

interval=interval+50;

for(j=0;j<interval;j++)

{

area();

setcolor(BLACK);

setcolor(rand()/15);

// horizontal left and right

circle(x+j,y,r+k);

circle(x-j,y,r+k);

//vertical up and down

circle(x,y+j,r+k);

circle(x,y-j,r+k);

//slighten down

circle(x+j,y+j,r+k);

circle(x-j,y-j,r+k);

//slighten up

circle(x-j,y+j,r+k);

circle(x+j,y-j,r+k);

delay(30);

cleardevice();

}

}

}

void area()

{

//Area

setcolor(15);

line(0,350,600,350);

rectangle(0,350,100,150);

rectangle(40,350,60,300);

rectangle(10,170,30,200);

rectangle(70,170,90,200);

rectangle(10,230,30,260);

rectangle(70,230,90,260);


rectangle(100,350,180,250);

line(100,250,140,180);

line(180,250,140,180);

rectangle(110,280,130,300);

rectangle(150,280,170,300);

rectangle(130,350,160,330);


rectangle(180,350,350,300);

rectangle(190,310,220,330);

rectangle(340,310,310,330);


rectangle(370,350,440,150);

rectangle(385,350,405,300);

rectangle(380,170,400,200);

rectangle(410,170,430,200);

rectangle(380,230,400,260);

rectangle(410,230,430,260);

settextstyle(BOLD_FONT,HORIZ_DIR,1);

outtextxy(110,10,"HAPPY NEW YEAR");

settextstyle(TRIPLEX_SCR_FONT,HORIZ_DIR,3);

outtextxy(140,50,"GOOD BYE 2020");

settextstyle(DEFAULT_FONT,HORIZ_DIR,3);

outtextxy(100,85,"WELCOME 2021");

settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1);

outtextxy(445,324,"ROHIT TECH STUDY");

}


Download source code


Thursday, December 23, 2021

BIRD HUNTING C++ PROGRAMMING




//.......... WELCOME ALL OF YOU ON ROHIT TECH STUDY CHANNEL ...............//

//___________---__ C++ PROGRAM TO CREATE BIRD HUNTING ___---______________//


#include<graphics.h>

#include<stdio.h>

#include<conio.h>

#include<dos.h>


int a,b,c,d,x,y,s;


void man();

void tree();

void gun();

void bird();



void main()

{

int a,b,c,d,x,y;


int gdriver = DETECT,gmode;

initgraph(&gdriver,&gmode,"C:\\TC\\BGI");


man();

gun();

bird();

tree();


delay(2000);

b=0;

c=0;

for(a=0;a<43;a++)

{


//....bullet.....

line(130+b,296-c,132+b,294-c);

line(130+b,296-c,131+b,297-c);

line(132+b,294-c,133+b,295-c);

line(131+b,297-c,133+b,295-c);

line(132+b,294-c,134+b,293-c);

b=b+6;

c=c+6;

delay(50);

cleardevice();

man();

tree();

gun();

bird();

}



d=0;

for(a=0;a<110;a++)

{


//_____falling bird______//

circle(410,50+d,4);

line(409,48+d,405,44+d);

line(409,48+d,413,44+d);

ellipse(397,50+d,0,360,8,4);

floodfill(398,51+d,WHITE);

line(390,50+d,372,50+d);

line(390,50+d,373,48+d);

line(390,50+d,373,47+d);

line(390,50+d,373,52+d);

line(390,50+d,373,53+d);


//...bird legs...//

line(397,48+d,394,43+d);

line(397,48+d,399,43+d);


d=d+3;

delay(30);

cleardevice();


man();

tree();

gun();


}


//----Falling bird----//


circle(410,50+d,4);

line(409,48+d,405,44+d);

line(409,48+d,413,44+d);

ellipse(397,50+d,0,360,8,4);

floodfill(398,51+d,WHITE);

line(390,50+d,372,50+d);

line(390,50+d,373,48+d);

line(390,50+d,373,47+d);

line(390,50+d,373,52+d);

line(390,50+d,373,53+d);


//...BIRD leg...//

line(397,48+d,394,43+d);

line(397,48+d,399,43+d);

getch();

}


void man()

{


//----- man ---//

ellipse(100,300,0,360,7,9);

circle(102,298,1);

line(103,303,105,303);

rectangle(99,310,102,315);

rectangle(97,315,105,335);

line(97,335,97,355);

line(105,335,101,355);

ellipse(101,357,0,360,5,2);

line(102,322,107,327);

line(103,326,108,330);

line(107,327,110,320);

line(108,330,111,321);


//  ground //

setcolor(13);

line(0,360,600,360);

setcolor(15);

}


void gun()

{


// gun  //

line(97,324,127,299);

line(104,320,129,299);

line(97,324,102,329);

line(104,320,102,329);

line(108,317,110,320);

line(126,299,127,300);


}

void bird()

{


//bird

circle(395,20,4);

line(394,20,388,20);

ellipse(395,33,0,360,4,8);

floodfill(396,34,WHITE);

line(395,38,391,53);

line(395,38,393,54);

line(396,38,395,52);

line(396,38,397,53);


}

void tree()

{


//tree

setcolor(6);

line(350,30,420,50);

line(350,40,425,65);

line(417,0,417,50);

line(417,63,417,400);


line(450,0,450,180);

line(450,210,450,400);

ellipse(406,400,250,0,10,10);

ellipse(460,400,180,270,10,10);

line(450,210,530,120);

line(450,175,500,120);

line(500,120,505,100);

line(505,125,510,105);

line(505,125,520,105);


setcolor(15);


setfillstyle(1,LIGHTGREEN);

circle(580,100,50);

floodfill(590,120,WHITE);

circle(520,50,50);

floodfill(522,52,WHITE);

circle(600,50,50);

floodfill(620,20,WHITE);

circle(300,20,50);

floodfill(310,25,WHITE);

circle(320,40,50);

floodfill(325,65,WHITE);

floodfill(360,30,WHITE);

circle(240,50,50);

floodfill(230,55,WHITE);

}


Download source code


 

Tuesday, December 21, 2021

CHRISTMAS DAY C PROGRAMMING, MERRY CHRISTMAS IN C GRAPHICS PROGRAM

 



//__________ WELCOME ALL OF YOU ON ROHIT  TECH STUDY CHANNEL ______________//

//------------_ C++ PROGRAM TO CELEBRATE CHRISTMAS DAY _-------------------//


#include<iostream.h>

#include<stdio.h>

#include<conio.h>

#include<dos.h>

#include<graphics.h>

#include<stdlib.h>

void drawtree(int midx, int fill_pattern)

{


int x=30,y=30,i;


for(i=0;i<70;i=i+30)

{


int poly[7];


poly[0]=midx;

poly[1]=30+i+y/2;


poly[2]=midx+20+x;

poly[3]=60+i+2*y;


poly[4]=midx-20-x;

poly[5]=60+i+2*y;


poly[6]=poly[0];

poly[7]=poly[1];


setfillstyle(fill_pattern,2);

fillpoly(4,poly);

x=x+30;

y=y+30;

}

}


void drawbark(int midx,int fill_pattern)

{


setfillstyle(fill_pattern,6);

bar(midx-25,300,midx+25,360);

}


void drawstar(int midx)

{

int poly[8];

poly[0]=midx;

poly[1]=40;


poly[2]=midx-18;

poly[3]=30;


poly[4]=midx+18;

poly[5]=30;


poly[6]=poly[0];

poly[7]=poly[1];

setfillstyle(1,15);

fillpoly(4,poly);


int poly1[10];

poly1[0]=midx;

poly1[1]=17;


poly1[2]=midx+15;

poly1[3]=55;


poly1[4]=poly[0];

poly1[5]=poly[1];


poly1[6]=midx-15;

poly1[7]=55;


poly1[8]=poly1[0];

poly1[9]=poly1[1];

setfillstyle(1,15);

fillpoly(4,poly1);

}


int main()

{


int gdrive=DETECT, gmode, errorcode;

int midx, fill_pattern=0;


initgraph(&gdrive, &gmode,"C:\\TC\\BGI");

errorcode=graphresult();

if(errorcode!=grOk)

{

printf("Graphics error:%s\n",grapherrormsg(errorcode));

printf("PRESS ANY KEY TO HALT:");

getch();

exit(1);

}


midx=getmaxx()/2;


do

{

fill_pattern=random(12);

setlinestyle(4,0,0);

if(fill_pattern==0)

continue;

drawtree(midx,fill_pattern);

drawbark(midx,fill_pattern);

drawstar(midx);


//...Draw the decorative bulbs...//

setfillstyle(1,random(15)+1);

sector(midx+50,120,230,310,8,13);

setfillstyle(1,random(15)+1);

sector(midx-50,120,230,310,8,13);

setfillstyle(1,random(15)+1);

sector(midx+95,210,230,310,8,13);

setfillstyle(1,random(15)+1);

sector(midx-95,210,230,310,8,13);

setfillstyle(1,random(15)+1);

sector(midx+140,300,230,310,8,13);

setfillstyle(1,random(15)+1);

sector(midx-140,300,230,310,8,13);


settextstyle(3,0,2);

setcolor(random(15)+1);

outtextxy(440,10,"WISH YOU A");


setcolor(random(15)+1);

outtextxy(410,35,"MERRY CHRISTMAS");


settextstyle(3,0,5);

setcolor(random(15)+1);

outtextxy(490,55,"&");


settextstyle(8,0,3);

setcolor(random(15)+1);

outtextxy(390,100,"HAPPY NEW YEAR");


settextstyle(10,0,4);

setcolor(random(15)+1);

outtextxy(440,120,"2022");


settextstyle(10,0,4);

setcolor(random(15)+1);

outtextxy(120,360,"CHRISTMAS DAY");


settextstyle(2,0,6);

setcolor(random(15)+1);

outtextxy(250,435,"ROHIT TECH STUDY");


delay(400);

}


while(!kbhit());

closegraph();

return 0;

}

Download source code


Saturday, December 18, 2021

JOGGING MAN IN C++ PROGRAMMING

 



//___________ WELCOME ALL OF YOU ON ROHIT TECH STUDY CHANNEL ______________//

//____________   C++ PROGRAM TO CREATE MAN JOGGING ____________________//


#include<graphics.h>

#include<stdio.h>

#include<conio.h>

#include<dos.h>

void body();

void first();

void second();

int i,a=0,b=0,c=0,d=0;


void main()

{

int gdriver = DETECT,gmode;

initgraph(&gdriver,&gmode,"C:\\TC\\BGI");


for(i=0;i<100;i++)

{

body();

if(i%2==0)

{

first();

}

else

{

second();

}

a=a+5;

delay(250);

cleardevice();

}

getch();

}



void first()

{

b=a;


setcolor(14);

//FIRST HAND

line(10+b,310,0+b,320);

line(10+b,308,0+b,318);

line(0+b,320,8+b,323);

line(0+b,318,8+b,323);


setcolor(10);

//SECOND HAND

line(10+b,310,15+b,320);

line(9+b,310,16+b,321);

line(15+b,320,18+b,312);

line(16+b,321,19+b,313);


setcolor(GREEN);

//FIRST LEG

setfillstyle(1,GREEN);

line(10+b,340,13+b,360);

line(13+b,360,10+b,375);

ellipse(13+b,375,0,360,4,2);

floodfill(14+b,375,GREEN);


setcolor(WHITE);

//SECOND LEG

setfillstyle(1,WHITE);

line(10+b,340,8+b,360);

line(8+b,360,1+b,364);

ellipse(2+b,367,0,360,2,4);

floodfill(3+b,367,WHITE);

}



void second()

{

c=a;


setcolor(12);

//SECOND HAND in 2

line(10+c,310,5+c,323);

line(8+c,310,4+c,323);

line(5+c,323,12+c,320);

line(4+c,323,12+c,320);

setcolor(15);


//FIRST HAND in 2

line(10+c,310,13+c,323);

line(11+c,310,14+c,324);

line(13+c,323,18+c,313);

line(14+c,324,17+c,313);


setcolor(15);


//LEG

setfillstyle(1,WHITE);

line(10+c,340,11+c,363);

line(11+c,360,7+c,375);

ellipse(9+c,375,0,360,4,2);

floodfill(10+c,375,WHITE);


setcolor(11);

setfillstyle(1,11);

line(10+c,340,13+c,360);

line(13+c,360,2+c,363);

ellipse(1+c,365,0,360,2,4);

floodfill(2+c,365,11);

}



void body()

{

// road

   setcolor(7);

   line(0,370,640,370);

   line(0,430,640,430);

   line(0,455,640,455);


   // hills

   setcolor(7);

   line(0,200,50,150);

   line(50,150,150,200);

   line(150,200,300,100);

   line(300,100,450,175);

   line(450,175,640,125);


   // sun

   setcolor(14);

   circle(475,75,25);


   // text

   settextstyle(3,0,2);

   setcolor(a);

   outtextxy(150,430,"CREATE BY ROHIT TECH STUDY");


setcolor(15);

ellipse(10+a,290,0,360,5,10);

circle(12+a,288,1);

line(10+a,300,10+a,340);

}

Download source code




Wednesday, December 15, 2021

FLYING BIRDS IN C++ PROGRAMMING

 



Download source code

//___________ WELCOME ALL OF YOU ON ROHIT TECH STUDY CHANNEL ______________//

//____________   C++ PROGRAM TO CREATE FLYING BIRDS ____________________//


#include<graphics.h>

#include<stdio.h>

#include<conio.h>

#include<dos.h>


void bird();

void Wingsup();

void Wingsdown();

int a,b,c,d,e;

int c1=20;

int c2=20;


void main()

{


int gdriver = DETECT,gmode;

initgraph(&gdriver,&gmode,"C:\\TC\\BGI");


b=0;

c=0;

d=0;


for(a=1;a<220;a++)

{


bird();

if(a%2==0)

{

Wingsup();

}

else

{

Wingsdown();

}

delay(100);

cleardevice();


b=b+3;

}

getch();

}


void bird()

{


//______birds_________//

setcolor(6);

circle(50+b,100,5);


setcolor(5);

line(53+b,98,60+b,100);

line(53+b,102,60+b,100);


setcolor(14);

circle(50+b,98,1);


setcolor(13);

ellipse(35+b,100,0,360,10,5);

line(28+b,100,15+b,95);

line(28+b,100,14+b,96);

line(29+b,100,13+b,97);

line(29+b,101,12+b,98);

line(29+b,102,10+b,99);

line(29+b,103,12+b,100);


for(int j=0;j<7;j++)

{

if(j==0){c1=40;c2=40;

}

else if(j==1){c1=-20;c2=-20;

}

else if(j==2){c1=20;c2=20;

}

else if(j==3){c1=70;c2=70;

}

else if(j==4){c1=60;c2=100;

}

else if(j==5){c1=20;c2=120;

}

else if(j==6){c1=0;c2=140;

}

else{c1=40;c2=60;

}


setcolor(14);

circle(50+b-c1,100+c2,5);


setcolor(3);

line(53+b-c1,98+c2,60+b-c1,100+c2);

line(53+b-c1,102+c2,60+b-c1,100+c2);


setcolor(13);

circle(50+b-c1,98+c2,1);


setcolor(12);

ellipse(35+b-c1,100+c2,0,360,10,5);

line(28+b-c1,100+c2,15+b-c1,95+c2);

line(28+b-c1,100+c2,14+b-c1,96+c2);

line(29+b-c1,100+c2,13+b-c1,97+c2);

line(29+b-c1,101+c2,12+b-c1,98+c2);

line(29+b-c1,102+c2,10+b-c1,99+c2);

line(29+b-c1,103+c2,12+b-c1,100+c2);

}

}


void Wingsdown()

{

c=b;


//_____wings down_________//

setcolor(10);

ellipse(35+c,106,210,360,6,15);

line(36+c,100,30+c,110);

line(39+c,107,36+c,113);

line(36+c,107,33+c,113);


for(int j=0;j<7;j++)

{

if(j==0){c1=40;c2=40;

}

else if(j==1){c1=-20;c2=-20;

}

else if(j==2){c1=20;c2=20;

}

else if(j==3){c1=70;c2=70;

}

else if(j==4){c1=60;c2=100;

}

else if(j==5){c1=20;c2=120;

}

else if(j==6){c1=0;c2=140;

}

else{c1=40;c2=60;

}


setcolor(11);

ellipse(35+c-c1,106+c2,210,360,6,15);

line(36+c-c1,100+c2,30+c-c1,110+c2);

line(39+c-c1,107+c2,36+c-c1,113+c2);

line(36+c-c1,107+c2,33+c-c1,113+c2);

}

}


void Wingsup()

{

d=b;

//______wings up______//

ellipse(35+d,94,0,150,6,15);

line(36+d,100,30+d,90);

line(36+d,87,38+d,93);

line(34+d,87,36+d,93);


for(int j=0;j<7;j++)

{

if(j==0){c1=40;c2=40;

}

else if(j==1){c1=-20;c2=-20;

}

else if(j==2){c1=20;c2=20;

}

else if(j==3){c1=70;c2=70;

}

else if(j==4){c1=60;c2=100;

}

else if(j==5){c1=20;c2=120;

}

else if(j==6){c1=0;c2=140;

}

else{

c1=40;c2=60;

}


ellipse(35+d-c1,94+c2,0,150,6,15);

line(36+d-c1,100+c2,30+d-c1,90+c2);

line(36+d-c1,87+c2,38+d-c1,93+c2);

line(34+d-c1,87+c2,36+d-c1,93+c2);

}

}

3D CAR ANIMATION IN C++ GRAPAPHICS PROGRAM | C++ PROJECT

 3D CAR ANIMATION IN C++ LANGUAGE | C++ PROJECT


Download source code

// WELCOME ALL OF YOU  ON ROHIT TECH STUDY CHANNEL //

// Animated 3D Car in Turbo C++. It consist of Lights effect, Sound Effect.//

// Press 'L' for Lights effect and 'H' for Horn.//


#include<graphics.h>

#include<conio.h>

#include<dos.h>

#include<stdlib.h>

#include<process.h>


void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm,"c:\\tc\\bgi");

setbkcolor(0);

int t;

while(1)

{

settextstyle(2,0,5);

outtextxy(100,10,"Press L,H ,T,P");

outtextxy(100,30,"Press 1 for Quit");

as:

setcolor(13);

ellipse(380,127,20,152,130,35);

//////////////////////////////rear//////////////////////////


line(490,109,560,142);

line(560,142,569,142);

line(569,142,582,102);

line(582,102,620,92);

line(593,132,617,125);


line(617,124,627,96);

line(620,92,628,97);


line(472,86,602,96);

line(501,113,575,121);

line(443,77,475,80);


line(443,77,432,93);

line(475,80,472,85);


line(593,132,593,137);

line(593,137,600,141);

line(600,141,600,185);

line(600,185,608,192);

line(608,192,608,234);

line(608,234,586,253);

line(586,253,577,248);


/////////////////////////mirror//////////////

line(263,112,363,127);

line(193,160,263,112);

line(193,160,220,170);

line(220,170,280,180);

line(280,180,320,185);

line(320,185,363,127);

////////////////////////////////sidemirror////////////////////


line(340,194,460,169);

line(460,169,519,152);


ellipse(512,144,300,30,10,10);

ellipse(467,143,28,100,50,30);

line(510,128,521,138);

line(435,116,440,171);


////////////////////////////////////////cont////////////////


line(339,194,372,144);

ellipse(454,208,87,123,128,95);

line(372,144,384,128);

int b,x,y;


////////////////////////lower/////////////////////


line(365,298,524,264);

line(365,298,330,310);

line(330,310,323,310);



///////////////////////////////bumper//////////////////


ellipse(162,221,135,190,90,40);

line(96,193,140,174);

line(140,174,160,168);

line(160,168,192,161);


//////////////////////front////////////////


ellipse(75,246,95,190,18,18);

line(57,251,57,286);

ellipse(181,178,232,263,200,137);

ellipse(195,180,256,286,200,137);



ellipse(191,171,228,247,200,100);

ellipse(231,198,234,275,200,80);


ellipse(196,167,228,246,200,90);

ellipse(231,184,234,276,200,80);

ellipse(191,200,228,246,200,90);

ellipse(228,218,234,276,200,80);

ellipse(258,268,180,220,200,40);

ellipse(178,296,244,355,16,10);

ellipse(238,249,227,250,200,60);



/////////////wheel1/////////////////


ellipse(302,281,320,77,26,45);

ellipse(290,277,65,162,40,45);

ellipse(278,288,144,212,31,45);


/////////////wheel2////////////////////


ellipse(302+260,229,328,87,26,45);

ellipse(290+280-7,277-50+2,90,162,40,45);

ellipse(278+270,288-50,144,215,27,45);

 b=0;

int v=0;


/////////

ellipse(302+250+v,227+b,295,90,29,41);

ellipse(302+234+v,231+b,245,306,50,40);

ellipse(302+248+v,229+b,0,360,21,30);


ellipse(302+247+v,229+b,0,360,8,10);

setfillstyle(6,11);


line(546+v,201+b,546+v,220+b);

line(551+v,201+b-2,551+v,220+b);


line(546+v,238+b,546+v,257+b);

line(551+v,238+b+2,551+v,257+b+2);



line(530+v,225+b,541+v,225+b);

line(530+v,230+b,541+v,230);


line(557+v,225+b,570+v,225+b);

line(557+v,230+b,570+v,230+b);

line(563+v,206+b,552+v,222+b);

line(534+v,246+b,543+v,232+b);


line(566+v,210+b,556+v,223+b);

line(536+v,250+b,544+v,238+b);


line(536+v,207+b,546+v,222+b);

line(532+v,213+b,542+v,224+b);


line(556+v,235+b,566+v,247+b);

line(551+v,237+b,563+v,253+b);


////////////////////////////////////////////////////

v=-260;

b=56;

ellipse(302+233+v,221+b,260,60,49,51);

ellipse(302+243+v,224+b,0,360,28,35);

ellipse(300+245+v,223+b,0,360,10,12);


ellipse(285+249+v,239+b,210,260,30,33);

b=45;

v=v-4;

line(546+v,201+b,546+v,220+b+2);

line(551+v,201+b,551+v,220+b+2);

b=b+8;

line(546+v,238+b,546+v,257+b+4);

line(551+v,238+b,551+v,257+b+4);

v=v-2;

line(530+v-6,225+b,541+v,225+b);

line(530+v-6,230+b,541+v,230+b);

v=v+5;

line(557+v,225+b,570+v+3,225+b);

line(557+v-1,230+b,570+v+3,230+b);



b=b-5;

v=v-5;

line(565+v+3,206+b,552+v+4,222+b-2);

b=b+15;


line(534+v,246+b,543+v+3,232+b-5);

b=b-10;

line(566+v+7,210+b-5,556+v+4,220+b);

line(536+v-5,250+b,544+v-2,238+b-4);



line(536+v,207+b-8,545+v,222+b-5);

line(531+v,212+b-8,542+v,224+b-2);


line(556+v,235+b,566+v+3,247+b+5);

line(551+v,237+b,563+v+2,253+b+3);


///////////////////lights////////////////////////


ellipse(199,250,144,345,18,8);

line(185,245,206,230);

ellipse(223,234,340,110,8,5);

line(230,237,217,252);

line(206,230,220,229);


/////////////////////////////////////

line(90,223,152,236);

line(152,236,137,254);

line(90,223,90,242);


ellipse(240,270,104,136,100,60);

ellipse(185,237,120,160,100,60);

ellipse(80,221,357,134,10,10);


line(152,236,168,228);

///////////////////////////////////////////////


line(435,116,440,171);


//////////////////////////////////////////hp//////////


line(134,185,196,160);

line(214,212,318,185);

////////////////////LIGHT/////////////////////////////


ellipse(166,247,99,330,8,8);

ellipse(171,243,310,129,7,7);

putpixel(174,250,13);

putpixel(173,251,13);

putpixel(164,239,13);

putpixel(165,238,13);


/////////////////////////////////////////road/////////////////////

setcolor(13);

line(1,430,639,300);

line(1,445,639,315);


line(1,210,93,194);

line(1,195,194,158);

line(520,90,639,71);

line(478,86,639,56);


int c=0;

line(10,194+c,10,208+c);

line(40,189+c,40,204+c);

line(70,183+c,70,198+c);

line(100,176+c,100,190+c);

line(130,170+c,130,177+c);

line(160,166+c,160,168+c);

line(190,160+c,190,161+c);


line(190+330,78+c,190+330,89+c);


line(190+360,72+c,190+360,85+c);

line(190+390,67+c,190+390,81+c);

line(190+420,62+c,190+420,76+c);

line(190+449,57+c,190+449,71+c);


c=236;


line(10,192+c,10,208+c);

line(40,189+c-2,40,204+c-3);

line(70,183+c-3,70,198+c-3);

line(100,176+c-2,100,190+c-2);

line(130,170+c-2,130,177+c+5);

line(160,166+c-3,160,168+c+8);

line(190,160+c-4,190,161+c+9);


line(190+30,156+c-5,190+30,170+c-5);



line(190+30+30,156+c-12,190+30+30,170+c-12);


line(190+90,156+c-18,190+90,170+c-17);


line(190+120,156+c-25,190+120,170+c-25);


line(190+150,156+c-30,190+150,170+c-30);


line(190+180,156+c-37,190+180,170+c-36);



line(190+210,156+c-42,190+210,170+c-42);



line(190+240,156+c-48,190+240,170+c-48);



line(190+270,156+c-55,190+270,170+c-54);



line(190+300,156+c-61,190+300,170+c-61);

line(190+330,78+c+10,190+330,89+c+13);

line(190+360,72+c+11,190+360,85+c+13);

line(190+390,67+c+10,190+390,81+c+10);

line(190+420,62+c+8,190+420,76+c+10);

line(190+449,57+c+8,190+449,71+c+8);


/////////////////road///////////////////


setcolor(12);

line(1,310,25,306);

line(6,318,30,315);

line(1,310,6,318);

line(25,306,30,314);


setcolor(12);


line(605,310-128,629,306-128);

line(610,318-128,634,315-128);

line(605,310-128,610,318-128);

line(629,306-128,634,314-128);


setcolor(12);

line(46,302,70,298);

line(51,310,75,307);

line(46,302,51,310);

line(70,298,75,306);



setfillstyle(1,0);

floodfill(64,303,12);


setfillstyle(1,14);

floodfill(14,314,12);

floodfill(617,183,12);


setfillstyle(1,0);

floodfill(14,314,12);

floodfill(617,183,12);


setfillstyle(1,14);

floodfill(64,303,12);


t=getch();

if(t=='1')

exit(0);

if(t=='h')

{

sound(710);

delay(500);

nosound();

 ////break;/////

}

if(t=='t')

{

while(!kbhit())

{

setfillstyle(1,0);

floodfill(536,213,13);

floodfill(563,213,13);

floodfill(561,244,13);

floodfill(538,244,13);

floodfill(274,295,13);

floodfill(294,295,13);

floodfill(274,265,13);

floodfill(294,265,13);

floodfill(548,250,13);

floodfill(548,214,13);

floodfill(533,228,13);

floodfill(563,228,13);

floodfill(262,281,13);

floodfill(308,281,13);

floodfill(284,251,13);

floodfill(284,295,13);


setfillstyle(1,random(12));


floodfill(200,250,13);

delay(10);


//setfillstyle(1,11);


 floodfill(170,250,13);

 floodfill(80,230,13);

 }

setfillstyle(1,0);

floodfill(200,250,13);

delay(10);


 floodfill(170,250,13);

 floodfill(80,230,13);

}

if(t=='l')

{

while(!kbhit())

{


delay(120);

setfillstyle(6,0);

floodfill(536,213,13);

floodfill(563,213,13);

floodfill(561,244,13);

floodfill(538,244,13);

floodfill(274,295,13);

floodfill(294,295,13);

floodfill(274,265,13);

floodfill(294,265,13);


setfillstyle(1,0);

floodfill(64,303,12);


/////////////////////road//////////////


setfillstyle(9,0);


 /////////////////////color///////////////


floodfill(81-40+5,419+7,13);

floodfill(151-40,409+7,13);

floodfill(211-40,397+7,13);

floodfill(271-40,380+7,13);

floodfill(331-40,368+7,13);

floodfill(396-40,355+7,13);

floodfill(450-40,345+7,13);

floodfill(510-40,335+7,13);

floodfill(570-40,325+7,13);

floodfill(630-40,312+7,13);


//////////////////////

floodfill(50,197,13);

floodfill(110,177,13);

floodfill(166,165,13);

floodfill(527,86,13);

floodfill(587,71,13);


setfillstyle(6,14);

floodfill(548,250,13);

floodfill(548,214,13);

floodfill(533,228,13);

floodfill(563,228,13);

floodfill(262,281,13);

floodfill(308,281,13);

floodfill(284,251,13);

floodfill(284,295,13);

//////////////////////road//////////


setfillstyle(9,10);


////////////////////color//////////////////


floodfill(19,429,13);

floodfill(81,419,13);

floodfill(151,409,13);

floodfill(211,397,13);

floodfill(271,380,13);

floodfill(331,368,13);

floodfill(396,355,13);

floodfill(450,345,13);

floodfill(510,335,13);

floodfill(570,325,13);

floodfill(630,312,13);

//////////////////////////////////////

floodfill(20,197,13);

floodfill(80,187,13);

floodfill(133,174,13);

floodfill(517,86,13);

floodfill(557,81,13);

floodfill(627,70,13);


setfillstyle(1,14);

floodfill(14,314,12);

floodfill(617,183,12);


///////////////////////////////////////

setfillstyle(10,4);

floodfill(302+248,230,13);

floodfill(302+248+v,230+b,13);


/////////////light///////////////////////


setfillstyle(6,11);

floodfill(200,250,13);

floodfill(170,250,13);

floodfill(80,230,13);


delay(120);


setfillstyle(6,0);/////////////////////ty

floodfill(548,250,13);

floodfill(548,214,13);

floodfill(533,228,13);

floodfill(563,228,13);

floodfill(262,281,13);

floodfill(308,281,13);

floodfill(284,251,13);

floodfill(284,295,13);


//////////////////////road/////////////////////////


setfillstyle(9,0);


///////////////color//////////////////////////


floodfill(19,429,13);

floodfill(81,419,13);

floodfill(151,409,13);

floodfill(211,397,13);

floodfill(271,380,13);

floodfill(331,368,13);

floodfill(396,355,13);

floodfill(450,345,13);

floodfill(510,335,13);

floodfill(570,325,13);

floodfill(630,312,13);

///////////////////////////////////////////////////////

floodfill(20,197,13);

floodfill(80,187,13);

floodfill(133,174,13);

floodfill(517,86,13);

floodfill(557,81,13);

floodfill(627,70,13);

/////////////////////////////

setfillstyle(1,0);

floodfill(14,314,12);

floodfill(617,183,12);


setfillstyle(6,10);


floodfill(536,213,13);

floodfill(563,213,13);

floodfill(561,244,13);

floodfill(538,244,13);

floodfill(274,295,13);

floodfill(294,295,13);

floodfill(274,265,13);

floodfill(294,265,13);


//////////////////////road//////////////////


setfillstyle(9,14);

//////////////////////color/////////////////////


floodfill(81-40+5,419+7,13);

floodfill(151-40,409+7,13);

floodfill(211-40,397+7,13);

floodfill(271-40,380+7,13);

floodfill(331-40,368+7,13);

floodfill(396-40,355+7,13);

floodfill(450-40,345+7,13);

floodfill(510-40,335+7,13);

floodfill(570-40,325+7,13);

floodfill(630-40,312+7,13);

/////////////////////////////////////////


floodfill(50,197,13);

floodfill(110,177,13);

floodfill(166,165,13);

floodfill(527,86,13);

floodfill(587,71,13);

setfillstyle(1,14);

floodfill(64,303,12);


setfillstyle(9,4);

floodfill(302+248,230,13);

floodfill(302+248+v,230+b,13);


delay(20);

setfillstyle(1,14);


floodfill(200,250,13);


floodfill(170,250,13);

 floodfill(80,230,13);


 delay(20);

setfillstyle(1,0);


floodfill(200,250,13);

floodfill(170,250,13);

 floodfill(80,230,13);

}          }

if(t=='p')

{

int n=0;

while(!kbhit())

{

if(n<=60)

n++;

setcolor(0);

rectangle(1+1,-10,90-1,-12+n);

delay(14);


setcolor(9);

rectangle(1,-10,90,-10+n);

if(n==60)

{

outtextxy(10,10,"THANK YOU");

outtextxy(10,20,"---ROHIT");


delay(400);

 }

}

}

}

circle(300,100,3);

nosound();

getch();

}

Sunday, December 12, 2021

clock animation c++ programming

 



Download source code

//____________ WELCOME ALL OF YOU ON ROHIT TECH STUDY CHANNEL _____________//

//------------------- C++ PROGRAM TO CREATE A CLOCK -----------------------//


#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

#include<graphics.h>

#include<dos.h>

void main()

{

struct  time t;

struct arccoordstype sec_arc, min_arc, hr_arc;

int i;

int gd = DETECT,gm;

initgraph(&gd,&gm,"c://TC//BGI");


setcolor(10);

//Outer circle

circle(320,240,100);

circle(320,240,99);


//Inner circle

circle(320,240,80);

circle(320,240,79);

setcolor(WHITE);


//mark four points

line(320,160,320,165); //top

line(320,320,320,315); //bottom

line(400,240,395,240); //left

line(240,240,245,240); //right


      while(!kbhit())

      {

      printf("Time is : %2d:%2d:%3d\r",t.ti_hour%12, t.ti_min, t.ti_sec);

      setcolor(0);

      line(320,240, sec_arc.xend, sec_arc.yend);

      line(320,240, min_arc.xend, min_arc.yend);

      line(320,240, hr_arc.xend, hr_arc.yend);


      //Store time into struct t

      gettime(&t);


      //hour

      setcolor(0);

      arc(320,240,270,90-(t.ti_hour*6*5),55);

      setcolor(YELLOW);

      getarccoords(&hr_arc);

      line(320,240, hr_arc.xend, hr_arc.yend);


      //minute

      setcolor(0);

      arc(320,240,270,90-t.ti_min*6,65);

      setcolor(CYAN);

      getarccoords(&min_arc);

      line(320,240, min_arc.xend, min_arc.yend);


      //center circle

      setcolor(WHITE);

      pieslice(320,240,0,360,5);


      //second

      setcolor(0);

      arc(320,240,270,90-t.ti_sec*6,75);

      setcolor(RED);

      getarccoords(&sec_arc);

      line(320,240, sec_arc.xend, sec_arc.yend);

      delay(250);

      }

getch();

 }

snake game in c++ graphics programing

 


Download source code

/***********  WELCOME ALL OF YOU ON ROHIT TECH STUDY CHANNEL **************/

/************        C++ PROGRAME TO CREATE SNAKE GAME      ***************/


#include<iostream.h>

#include<conio.h>

#include<graphics.h>

#include<dos.h>

#include<stdlib.h>

#include<stdio.h>

#include<time.h>

#include<string.h>

class Snake

{

 int p1,p2,v1,v2,v3,e1,e2,prev,now,n,colr,dsp,cnt,dly,m;

 int stp,egGen;

 int xr,yr;

 void caught();

 public:

  long scr;

 int strtX,strtY,endX,endY;

 int pos[100][2];

 void show();

 void init();

 void egg();

 void transpose();

 void gnrtCond();

 void gnrtUnCond();

 void check();

 void checkEgg();

 void move();

 void chngDir();

 void sndEt();

 void sndCgt();

 int test();

 void score();

 Snake();

 Snake(Snake*);

 ~Snake();

 };

Snake::Snake()

 {

 }

Snake::~Snake()

{


}

void Snake::checkEgg()

{

 if((e1 == p1) && (e2 == p2))

 {sndEt();

  egg();

  dly--;

  score();

  n++;

  }

}

void Snake::sndEt()

{nosound();

 sound(2500);

 delay(2);

 nosound();

}

void Snake::sndCgt()

{nosound();

 for(int x=1000;x>0;x--)

 {sound(x);

  delay(1);

  }

 nosound();

}

void Snake::score()

{ char *p;


  ltoa(scr,p,10);

  settextstyle(8,0,1);

  setcolor(0);

  outtextxy(585,40,p);

  if(egGen != 1){

  scr = scr + dly / 10;

  }

  ltoa(scr,p,10);

  setcolor(10);

  outtextxy(585,40,p);


}

void Snake::gnrtCond()

{if(n < 367)

 {if(now == 8 && (prev != 8 && prev != 2))

  {pos[0][0] = p1;

   pos[0][1] = p2 - dsp;

   prev = now;

   }

  if(now == 4 && (prev != 4 && prev != 1))

  {pos[0][0] = p1 + dsp;

   pos[0][1] = p2;

   prev = now;

   }

  if(now == 2 && (prev != 8 && prev != 2))

  {pos[0][0] = p1;

   pos[0][1] = p2 + dsp;

   prev = now;

   }

  if(now == 1 && (prev != 1 && prev != 4))

  {pos[0][0] = p1 - dsp;

   pos[0][1] = p2;

   prev = now;

   }

}

}

void Snake::gnrtUnCond()

{

  if( prev == 8 )

  {pos[0][0] = p1;

   pos[0][1] = p2 - dsp;

   }

 if( prev == 4 )

  {pos[0][0] = p1 + dsp;

   pos[0][1] = p2;

   }

 if( prev == 2 )

  {pos[0][0] = p1;

   pos[0][1] = p2 + dsp;

   }

 if( prev == 1 )

  {pos[0][0] = p1 - dsp;

   pos[0][1] = p2;

   }

 p1 = pos[0][0];

 p2 = pos[0][1];

}

void Snake::check()

{

 if(p1 > endX)

  {p1 = strtX;}

 else if(p1 < strtX)

  {p1 = endX;}


 if(p2 > endY)

  {p2 = strtY;}

 else if(p2 < strtY)

  {p2 = endY;}


 pos[0][0] = p1;

 pos[0][1] = p2;

for(int i = 1;i < n;i++)

  { if(p1 == pos[i][0] && p2 == pos[i][1])

  {caught();

   break;

  }

 }

}

void Snake::show()

{

  int x = getcolor();

  if(egGen != 1)

  {

  setcolor(getbkcolor());

  setfillstyle(1,getbkcolor());

  fillellipse(v1,v2,yr,yr);

   }

  else

   egGen = 0;

  if(egGen == 2)

   egGen--;

  setcolor(colr);

  setfillstyle(1,9);

  if(now == 8 || now == 2)

   fillellipse(pos[0][0],pos[0][1],xr,yr);

  else if(now == 4 || now == 1)

   fillellipse(pos[0][0],pos[0][1],yr,xr);

  setcolor(x);

}

void Snake::transpose()

{ int i,j,x,y;

   p1 = pos[0][0];

   p2 = pos[0][1];

   if(!egGen){

   v1 = pos[n-1][0];

   v2 = pos[n-1][1];

   }

   else

    egGen = 0;

   for(i = n-1;i >= 1;i--)

   {pos[i][0] = pos[i-1][0];

    pos[i][1] = pos[i-1][1];

   }

}

void Snake::move()

{ int st = 0;

  do{

   if(!kbhit())

   {checkEgg();

    if(!st)

     show();

    else

     st = 0;

    delay(dly/4);

    transpose();

    delay(dly/4);

    gnrtUnCond();

    delay(dly/4);

    check();

   delay(dly/4);

    }

   else if(stp){

   chngDir();

   gnrtCond();

   check();

   show();

   st = 1;

   }

   }while(stp);

}

void Snake::init()

{time_t tm;

 srand(time(&tm));

 dsp = 20;

 n = 5;

 prev = 4;

 for(int i = 4;i >= 0;i--)

 {pos[i][0] = 201 + (n - i - 1) * dsp;

  pos[i][1] = 301;

  }

  strtX = 21;

  strtY = 21;

  endX = 481;

  endY = 361;

  colr = 14;

  now = prev;

  dsp = 20;

  stp = 111;

  cnt = -1;

  scr = 0;

  dly = 150;

   xr = 3;

   yr = 9;

  egg();

  egGen = 1;

  score();

  int x = getcolor();

  setlinestyle(0,1,3);

  setcolor(15);

  rectangle(strtX-15,strtY-15,endX+15,endY+15);

  rectangle(endX+25,strtY-15,getmaxx()-15,endY+15);

  rectangle(strtX-15,endY+25,getmaxx()-15,getmaxy()-5);

  line(endX+25,strtY+75,getmaxx()-15,strtY+75);

  line(endX+25,strtY+200,getmaxx()-15,strtY+200);

  line(endX+25,strtY+275,getmaxx()-15,strtY+275);

  setlinestyle(0,1,1);

  settextstyle(8,0,1);

  setcolor(11);

  outtextxy(514,40,"SCORE");

  setcolor(14);

  settextstyle(11,0,5);

  outtextxy(524,110," CONTROLS ");

  outtextxy(522,135,"p = PAUSE");

  outtextxy(522,155,"g = RESUME");

  outtextxy(522,175,"e = EXIT");

  setcolor(10);

  outtextxy(513,195,"   ROHIT  ");

  setcolor(10);

  outtextxy(512,205," TECH STUDY ");

  setcolor(CYAN);

  settextstyle(4,0,9);

  outtextxy(getmaxx()-500,getmaxy()-110,"SNAKE");

  settextstyle(8,0,1);

  setcolor(x);

}

void Snake::caught()

{

 stp = 0;

 sndCgt();

for(int i=0;i<=7;i++)

 {

 if(i%2)

  {

  setcolor(10);

   outtextxy(512,250,"GAME OVER");

   delay(900);

   }

  else

  {

  setcolor(0);

   outtextxy(512,250,"GAME OVER");

   delay(500);

  }

  }

sleep(1);

}

void Snake::chngDir()

{int clr;

 fillsettingstype *p;

 char x = getch();

 if(x == 72)

  now = 8;

 else if(x == 77)

  now = 4;

 else if(x == 80)

  now = 2;

 else if(x == 75)

  now = 1;

 else if(x == 'e')

  caught();

 else if(x == 'p')

 {

  int twnkl = 1;

  settextstyle(11,0,9);

  while(1)

  {if(kbhit())

   {int c = getch();

    if(c == 'g')

    {

    clr = getcolor();

     setcolor(0);

     rectangle(endX+40,endY-10,getmaxx()-35,getmaxy()-160);

     outtextxy(endX+60,endY-29,"PAUSE");

     break;

     }

    }

   else

   {if(twnkl%2)

    {

    clr = getcolor();

     setcolor(10);

     rectangle(endX+40,endY-10,getmaxx()-35,getmaxy()-160);

     outtextxy(endX+60,endY-29,"PAUSE");

     setcolor(clr);

      delay(1000);

     }

    else

    {

     clr = getcolor();

     setcolor(0);

     rectangle(endX+40,endY-10,getmaxx()-35,getmaxy()-160);

     outtextxy(endX+60,endY-29,"PAUSE");

     delay(1000);

    }

   }

   twnkl++;

  }

    settextstyle(8,0,1);

 }

}

Snake::Snake(Snake *p)

{

 *p=NULL;

}

void Snake::egg()

{ do

  {e1 = (rand() % 100) * dsp + strtX;

   e2 = (rand() % 100) * dsp + strtY;

   }while(test());

  int x = getcolor();

  setcolor(7);

  setfillstyle(1,random(15)+1);

  fillellipse(e1,e2,xr+2,xr+2);

  setcolor(x);

  egGen = 2;

}

int Snake::test()

{ for(int i=0;i<n;i++)

  {if(e1 == pos[i][0] && e2 == pos[i][1])

    break;

   if(v1 == e1 && v2 == e2)

    break;

   if((e1 >= endX+1) || (e2 >= endY+1))

    break;

   }

 if(i != n)

  return 1;

 else

  return 0;

}


void main()

{Snake snk;

 int gd=DETECT,gm,i,j,k,x,y;

 clrscr();

 initgraph(&gd,&gm,"c:\\tc\\bgi");

 snk.init();

 snk.move();


 closegraph();

 restorecrtmode();

 }

Snake game in C++ Programming


Download source code




//----------WELCOME ALL OF YOU ON ROHIT TECH STUDY  CHANNEL----------------//

//__________C++ GRAPHICS PROGRAM TO MAKE RATTLE SNAKE GAME_________________//


#include <graphics.h>

#include <stdlib.h>

#include <stdio.h>

#include <conio.h>

#include <dos.h>

#include <iostream.h>

#include <fstream.h>

#include <string.h>



void main(void)

{

   int gdriver = DETECT, gmode, errorcode;

   void

*body,*food,*tail1,*tail2,*tail3,*tail4,*head1,*head2,*head3,*head4;

   int x, y,X[5000],Y[5000],i=3,

maxx,maxy,speed=100,bo=10,t[10],score=0,hscore=20;

   unsigned int size;

   char a='6',b,scor[4],hs[4];

   int k=2,l,r1,r2,f=0,z=100,first=0,second=1;;

   r1=300;

   r2=350;


   ifstream infile("c:\tc\bin\rattle.txt");

   infile.getline(hs,4);

   infile.close();

   hscore = atoi(hs);


   /* initialize graphics and local variables */

   initgraph(&gdriver, &gmode, "c:\\tc\\bgi");


   /* read result of initialization */

   errorcode = graphresult();


   if (errorcode != grOk)

   {

      printf("Graphics error: %s", grapherrormsg(errorcode));

      printf("Press any key to halt:");

      getch();

      exit(1);

   }

   maxx = getmaxx();

   maxy = getmaxy();

   y = 160;

   x = 80;

   for(int j=0; j<=3; j++)

   {

X[i-j]=x-bo*(j+1);

Y[i-j]=y;


   }


   //body


   setfillstyle(1,2);

   bar(10,10,20,20);

   setcolor(0);

   setlinestyle(0,1,3);

   line(9,9,21,21);

   line(9,21,21,9);

   size = imagesize(10,10,20,20);

   body = malloc(size);

   getimage(10,10,20,20,body);

   cleardevice();


   setcolor(0);

   //tail1-right

   t[0]=20; t[1]=10;

   t[2]=10; t[3]=10;

   t[4]=20; t[5]=15;

   t[6]=10; t[7]=20;

   t[8]=20; t[9]=21;

   fillpoly(5, t);

   size = imagesize(10,10,20,21);

   tail1 = malloc(size);

   getimage(10,10,20,21,tail1);

   cleardevice();


   //tail2-left

   t[0]=10; t[1]=10;

   t[2]=20; t[3]=10;

   t[4]=10; t[5]=15;

   t[6]=20; t[7]=20;

   t[8]=10; t[9]=21;

   fillpoly(5, t);

   size = imagesize(10,10,20,21);

   tail2 = malloc(size);

   getimage(10,10,20,21,tail2);

   cleardevice();


   //tail3-up

   t[0]=10; t[1]=20;

   t[2]=10; t[3]=10;

   t[4]=15; t[5]=20;

   t[6]=20; t[7]=10;

   t[8]=20; t[9]=21;

   fillpoly(5, t);

   size = imagesize(10,10,20,21);

   tail3 = malloc(size);

   getimage(10,10,20,21,tail3);

   cleardevice();


   //tail4-down

   t[0]=10; t[1]=10;

   t[2]=10; t[3]=21;

   t[4]=15; t[5]=10;

   t[6]=20; t[7]=21;

   t[8]=20; t[9]=10;

   fillpoly(5, t);

   size = imagesize(10,10,20,21);

   tail4 = malloc(size);

   getimage(10,10,20,21,tail4);

   cleardevice();


   //head1-right

   setlinestyle(1,1,1);

   setcolor(2);

   fillellipse(10,10,10,5);

   setcolor(4);

   //eyes

   fillellipse(15,7,1,1);

   fillellipse(15,13,1,1);

   size = imagesize(10,5,20,15);

   head1 = malloc(size);

   getimage(10,5,20,15,head1);


   //head2-left

   //eyes

   fillellipse(5,7,1,1);

   fillellipse(5,13,1,1);

   size = imagesize(0,5,10,15);

   head2 = malloc(size);

   getimage(0,5,10,15,head2);

   cleardevice();


   //head3-up

   //eyes

   setcolor(2);

   fillellipse(12,12,5,10);

   setcolor(4);

   fillellipse(9,6,1,1);

   fillellipse(15,6,1,1);

   size = imagesize(7,2,18,12);

   head3 = malloc(size);

   getimage(7,2,18,12,head3);


   //head4-down

   //eyes

   fillellipse(9,17,1,1);

   fillellipse(15,17,1,1);

   size = imagesize(7,12,18,22);

   head4 = malloc(size);

   getimage(7,12,18,22,head4);

   cleardevice();


   //food

   setcolor(15);

   setfillstyle(1,15);

   fillellipse(10,10,3,5);

   size = imagesize(5,3,15,17);

   food = malloc(size);

   getimage(5,3,15,17,food);

   cleardevice();


    /* repeat until a key is pressed */

   maxx=getmaxx();

   maxy=getmaxy();

   setlinestyle(0,1,3);

   setcolor(9);

   rectangle(0,0,maxx,maxy);

   setlinestyle(0,1,2);

   line(maxx-150,0,maxx-150,maxy);

   setcolor(8);

   setfillstyle(1,8);

   bar(maxx-147,3,maxx-3,63);

   setcolor(12);

   int maze=1;

   if(maze==1)

   {

   setfillstyle(1,6);

   bar(4,4,maxx-154,14);

   bar(4,4,14,maxy-4);

   bar(4,maxy-4,maxx-154,maxy-14);

   bar(maxx-154-10,4,maxx-154,maxy-4);

   }


   settextstyle(0,0,1);

   delay(300);

   outtextxy(maxx-125,45,"RATTLE SNAKE");

    outtextxy(maxx-115,10,"MODIFY BY");

   outtextxy(maxx-135,30,"ROHIT TECH STUDY");

   delay(300);

   setcolor(11);

   setlinestyle(0,1,2);

   rectangle(maxx-145,65,maxx-5,205);

   outtextxy(maxx-128,70,"INSTRUCTIONS");

   delay(200);

   setcolor(6);

   outtextxy(maxx-140,90,"Commands      Key");

   delay(300);

   setcolor(8);

   outtextxy(maxx-140,110," Move Up      8");

   delay(50);

   outtextxy(maxx-140,130," Move Down    5");

    delay(50);

   outtextxy(maxx-140,150," Move Right   6");

    delay(50);

   outtextxy(maxx-140,170," Move Left    4");

    delay(50);

   outtextxy(maxx-140,190," Exit         0");

   delay(200);

   setcolor(12);

   setlinestyle(0,1,2);

   rectangle(maxx-145,210,maxx-5,350);

   setcolor(1);

   outtextxy(maxx-130,220,"Player's Name");

   setcolor(15);

   outtextxy(maxx-100,230,"ROHIT");

   setcolor(4);

   delay(200);

   itoa(score,scor,10);

   outtextxy(maxx-140,250,"Score");

   outtextxy(maxx-50,250,scor);

   delay(200);

   setcolor(10);

   outtextxy(maxx-140,280,"Level");

   delay(200);

   setcolor(13);

   outtextxy(maxx-140,310,"Maze        1");

   delay(200);

   setcolor(14);

   outtextxy(maxx-140,340,"High Score  ");

   outtextxy(maxx-50,340,hs);


   for(j=0; j<=1000; j++)

   {

putpixel(random(maxx-150),random(maxy),6);

delay(1);

   }


   while (a!='0')

   {


       // plot new image

      if(a=='6')

    putimage(x, y, head1, XOR_PUT);

      if(a=='4')

    putimage(x, y, head2, XOR_PUT);

      if(a=='8')

    putimage(x, y, head3, XOR_PUT);

      if(a=='5')

    putimage(x, y, head4, XOR_PUT);


      for(j=0; j<k; j++)

      {

   putimage(X[i-j], Y[i-j], body, XOR_PUT);

      }


      if((X[i-j-1]-X[i-j])<0  && (Y[i-j-1]-Y[i-j])==0)

    putimage(X[i-j], Y[i-j], tail1, XOR_PUT);


      if((X[i-j-1]-X[i-j])>0  && (Y[i-j-1]-Y[i-j])==0)

    putimage(X[i-j], Y[i-j], tail2, XOR_PUT);


      if((X[i-j-1]-X[i-j])==0  && (Y[i-j-1]-Y[i-j])<0)

    putimage(X[i-j], Y[i-j], tail3, XOR_PUT);


      if((X[i-j-1]-X[i-j])==0  && (Y[i-j-1]-Y[i-j])>0)

    putimage(X[i-j], Y[i-j], tail4, XOR_PUT);


      delay(speed);


      if(second==1)

      {

setcolor(15);

outtextxy(maxx-140,360,"Press Any Key...");

getch();

setcolor(0);

outtextxy(maxx-140,360,"Press Any Key...");

a='6';


second=2;

      }



      if(first==1)

      {

setcolor(15);

outtextxy(maxx-140,360,"Congratulations  ");

sound(100);

delay(300);

nosound();

getch();

setcolor(0);

outtextxy(maxx-140,360,"Congratulations  ");

second++;

first=2;


      }


// erase old image

      if(a=='6')

    putimage(x, y, head1, XOR_PUT);

      if(a=='4')

    putimage(x, y, head2, XOR_PUT);

      if(a=='8')

    putimage(x, y, head3, XOR_PUT);

      if(a=='5')

    putimage(x, y, head4, XOR_PUT);



      for(j=0; j<k; j++)

      {

   putimage(X[i-j], Y[i-j], body, XOR_PUT);


      }


      if((X[i-j-1]-X[i-j])<0  && (Y[i-j-1]-Y[i-j])==0)

    putimage(X[i-j], Y[i-j], tail1, XOR_PUT);


      if((X[i-j-1]-X[i-j])>0  && (Y[i-j-1]-Y[i-j])==0)

    putimage(X[i-j], Y[i-j], tail2, XOR_PUT);


      if((X[i-j-1]-X[i-j])==0  && (Y[i-j-1]-Y[i-j])<0)

    putimage(X[i-j], Y[i-j], tail3, XOR_PUT);


      if((X[i-j-1]-X[i-j])==0  && (Y[i-j-1]-Y[i-j])>0)

    putimage(X[i-j], Y[i-j], tail4, XOR_PUT);



      if(f==0)

      {

putimage(r1,r2,food,XOR_PUT);

f=1;

      }


      z--;

if((x>=r1 && y>=r2 && x<=r1+10 && y<=r2+10)||

(x<=r1 && y<=r2 &&x>=r1-10 && y>=r2-10) || z==0)

      {

if(z!=0)

{

sound(800);

delay(20);

setcolor(0);

score += 10;

outtextxy(maxx-50,250,scor);

itoa(score,scor,10);

if(score>hscore)

{

strcpy(hs,scor);

setfillstyle(1,1);

bar(maxx-140,337,maxx-20,348);

setcolor(14);

outtextxy(maxx-50,340,hs);

outtextxy(maxx-140,340,"High Score  ");

if(first==0)

{

first=1;

}

}

setcolor(4);

outtextxy(maxx-50,250,scor);

k++;

nosound();

}

z=100;

putimage(r1,r2,food,XOR_PUT);

repr1:

r1=random(450);

    if(r1<50)

       goto repr1;

repr2:

r2=random(400);

    if(r2<50)

goto repr2;


f=0;

      }



      i++;

      X[i]=x;

      Y[i]=y;


b=a;

if(kbhit())

{

rep:

a=getch();


if((b=='6' && a=='4') || (b=='4' && a=='6'))

a=b;


if((b=='8' && a=='5') || (b=='5' && a=='8'))

a=b;


if(a!='6' && a!='4' && a!='8' && a!='0' && a!='5')

a=b;

      }


      if(a=='8')

y -= bo;


      if(a=='5')

y += bo;


      if(a=='4')

x -= bo;


      if(a=='6')

x += bo;


 for(j=i+1; j<i-k; j--)

 {

 if((Y[i]>=Y[j] && Y[i]<=Y[j]+10) || (Y[i]<=Y[j] && Y[i]>=X[j]-10))

 {

 if((X[i]>=X[j] && X[i]<=X[j]+10) || (X[i]<=X[j] && X[i]>=X[j]-10))

 {

 a='0';

 }


 outtextxy(maxx-140,360,"C");


 }


 if((X[i]>=X[j] && X[i]<=X[j]+10) || (X[i]<=X[j] && X[i]>=X[j]-10))

 {

 if((Y[i]>=Y[j] && Y[i]<=Y[j]+10) || (Y[i]<=Y[j] && Y[i]>=X[j]-10))

 {

 a='0';

 }


 outtextxy(maxx-140,360,"C");

 }


 }


if(maze==1)

{

if(x<=14 || x>=maxx-184 || y<=14 || y>=maxy-14)

{

a='0';

}

}

}


if(score>hscore)

{

ofstream onfile("c:\tc\bin\rattle.txt");

onfile<<scor;

onfile.close();

   }


   setcolor(15);

   outtextxy(maxx-140,390," Gameover");

   sound(100);

   delay(400);

   nosound();

   getch();

   /* clean up */

   free(body);

   closegraph();

}

 

Featured Post

Happy Republic Day Wish Using HTML and CSS | 26 January wish using HTML/CSS

 Happy Republic Day Wish Using HTML and CSS, 26 January wish using HTML/CSS <!-- WELCOME ALL OF YOU ON COMPUTER SOFT SKILLS CHANNEL -----...

Popular Posts