Add to Favorites    Make Home Page 14565 Online  
 Language Categories  
 Our Services  

Home » C Home » Games and Graphics Home » Ships Moving & one Ship come first (Mini Project)

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Ships Moving & one Ship come first (Mini Project)
Author Shaik.Sameenulla
Author Email shaik_sameenulla [at] yahoo.com
Description
Category C » Games and Graphics
Hits 386535
Code Select and Copy the Code
Code : /* Ship design */ // ship.h ships() { rectangle(200,100,450,350); line(200,225,450,225); line(325,100,325,350); arc(260,150,180,0,50); line(210,150,310,150); line(210,155,310,155); line(220,150,220,155); line(223,150,223,155); line(297,150,297,155); line(300,150,300,155); line(212,150,212,155); line(308,150,308,155); line(230,130,230,155); line(238,130,238,155); ellipse(234,130,2,1,4,2); setlinestyle(1,0,0); line(255,122,240,110); line(256,122,242,110); line(258,122,245,110); line(259,122,247,110); setlinestyle(0,0,1); line(250,122,250,155); line(262,122,262,155); ellipse(256,122,2,1,6,3); line(274,130,274,155); line(282,130,282,155); ellipse(278,130,2,1,4,2); rectangle(230,165,238,181); rectangle(247,165,255,181); rectangle(264,165,272,181); rectangle(281,165,289,181); setlinestyle(1,0,0); line(230,172,238,172); line(230,174,238,174); line(247,172,255,172); line(247,174,255,174); line(264,172,272,172); line(264,174,272,174); line(281,172,289,172); line(281,174,289,174); /* Text line */ setlinestyle(0,0,1); line(200,202,450,202); line(200,327,450,327); /*getch();*/ } /* Main program */ #include<graphics.h> #include<alloc.h> #include<stdio.h> #include<stdlib.h> #include<dos.h> #include "ship.h" main() { int gd=DETECT,gm; int i,ch,j,k,c; char choice,char1[1]; int p,q,r,area,*ship1; initgraph(&gd,&gm,"z:\lngs\tc\bgi"); cleardevice(); settextstyle(GOTHIC_FONT,HORIZ_DIR,2); setcolor(GREEN); outtextxy(300,250,"Welcome !"); outtextxy(310,270,"TO"); setcolor(243); outtextxy(290,290,"Ship Move Game"); sleep(2); start: cleardevice(); i=1; j=1; p=20; q=20; r=20; setcolor(243); ships(); select1(); nselect2(); nselect3(); nselect4(); while(j==1) { ch=getch(); if(ch==77 && i==1) { i=2; select2(); nselect1(); } else if(ch==80 && i==1) { i=3; select3(); nselect1(); } else if(ch==75 && i==2) { i=1; select1(); nselect2(); } else if(ch==80 && i==2) { i=4; select4(); nselect2(); } else if(ch==72 && i==3) { i=1; select1(); nselect3(); } else if(ch==77 && i==3) { i=4; select4(); nselect3(); } else if(ch==72 && i==4) { i=2; select2(); nselect4(); } else if(ch==75 && i==4) { i=3; select3(); nselect4(); } else if(ch==27) { setcolor(243); settextstyle(TRIPLEX_FONT,HORIZ_DIR,1); outtextxy(250,360,"Exit"); setcolor(GREEN); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); outtextxy(252,385,"Yes"); outtextxy(252,395,"No"); fflush(stdin); choice=getch(); if(choice=='Y' || choice=='y') {closegraph(); restorecrtmode(); exit(0); } else { setcolor(BLACK); settextstyle(TRIPLEX_FONT,HORIZ_DIR,1); outtextxy(250,360,"Exit"); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); outtextxy(252,385,"Yes"); outtextxy(252,395,"No"); continue; } } if(ch==13 && i==1) { area=imagesize(205,105,320,200); ship1=malloc(area); getimage(205,105,320,200,ship1); j=2; } }/*End of while loop */ cleardevice(); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2); for(i=5;i>=0;i--) { cleardevice(); setcolor(RED); outtextxy(300,200,"START"); sprintf(char1,"%d",i); setcolor(CYAN); outtextxy(320,220,char1); sleep(1); } cleardevice(); while(p<450 && q<450 && r<450) { cleardevice(); p=p+random(10); putimage(p,20,ship1,XOR_PUT); q=q+random(10); putimage(q,170,ship1,XOR_PUT); r=r+random(10); putimage(r,320,ship1,XOR_PUT); if(kbhit()) { ch=getch(); if(ch==27) { outtextxy(250,250,"Exit"); sleep(1); goto start; } } delay(10000000); delay(10000000); delay(10000000); delay(10000000); putimage(p,20,ship1,XOR_PUT); putimage(q,170,ship1,XOR_PUT); putimage(r,320,ship1,XOR_PUT); }/* End of while loop */ putimage(p,20,ship1,XOR_PUT); putimage(q,170,ship1,XOR_PUT); putimage(r,320,ship1,XOR_PUT); if(p>q && p>r) c=1; else if(q>r && q>p) c=2; else c=3; switch(c) { case 1: for(i=0;i<=20;i++) { setcolor(GREEN); outtextxy(p+120,70,"Win"); delay(1000000000); delay(1000000000); setcolor(BLACK); outtextxy(p+120,70,"Win"); delay(1000000000); delay(1000000000); delay(1000000000); } break; case 2: for(i=0;i<=20;i++) { setcolor(GREEN); outtextxy(q+120,220,"Win"); delay(100000000); delay(100000000); setcolor(BLACK); outtextxy(q+120,220,"Win"); delay(100000000); delay(100000000); delay(100000000); } break; case 3: for(i=0;i<=20;i++) { setcolor(GREEN); outtextxy(r+120,370,"Win"); delay(100000000); delay(100000000); setcolor(BLACK); outtextxy(r+120,370,"Win"); delay(100000000); delay(100000000); delay(100000000); } } cleardevice(); outtextxy(300,200,"Game Over"); sleep(1); goto start; closegraph(); restorecrtmode(); } select1() { settextstyle(TRIPLEX_FONT,HORIZ_DIR,2); setcolor(RED); outtextxy(220,203,"TITANIC1"); } select2() { settextstyle(TRIPLEX_FONT,HORIZ_DIR,2); setcolor(RED); outtextxy(345,203,"TITANIC2"); } select3() { settextstyle(TRIPLEX_FONT,HORIZ_DIR,2); setcolor(RED); outtextxy(220,328,"TITANIC3"); } select4() { settextstyle(TRIPLEX_FONT,HORIZ_DIR,2); setcolor(RED); outtextxy(345,328,"TITANIC4"); } nselect1() { settextstyle(TRIPLEX_FONT,HORIZ_DIR,2); setcolor(WHITE); outtextxy(220,203,"TITANIC1"); } nselect2() { settextstyle(TRIPLEX_FONT,HORIZ_DIR,2); setcolor(WHITE); outtextxy(345,203,"TITANIC2"); } nselect3() { settextstyle(TRIPLEX_FONT,HORIZ_DIR,2); setcolor(WHITE); outtextxy(220,328,"TITANIC3"); } nselect4() { settextstyle(TRIPLEX_FONT,HORIZ_DIR,2); setcolor(WHITE); outtextxy(345,328,"TITANIC4"); }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi �դ ?�� ��??���
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=876


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review