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

Home » C Home » Games and Graphics Home »

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

Search Projects & Source Codes:

Title
Author Raghu Ram Kolipaka
Author Email raghuram.kolipaka [at] gmail.com
Description This is a Analog Clock in synchronisation with the system
clock ,written in C graphics.This is a good project for those intersted
in
C graphics,if you understand this code,you can develop your own graphic
programs.
Category C » Games and Graphics
Hits 5749
Code Select and Copy the Code
#include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> #include<dos.h> #include<stdlib.h> int a=300,b=150,r=100,bobx1,boby1,bobx2,boby2,bobx3,boby3,flag=1; int hour,min,sec,hour_ang,min_ang,sec_ang; int x3,y3,x4,y4,x5,y5,x41,y41,x42,y42,x43,y43,x51,y51,x52,y52,x53,y53; int color=5; void drawclock(); void clock(int); void introduction(); void end(); void main() { int gd=DETECT,gm,i,j; char *buff; struct time t; void end(); x3=x4=x5=x41=x42=x43=x51=x52=x53=a; y3=y4=y5=y41=y42=y43=y51=y52=y53=b; gettime(&t); hour=t.ti_hour; min=t.ti_min; sec=t.ti_sec; if(hour>12)hour=hour-12; initgraph(&gd,&gm,"C:TCBGI"); introduction(); cleardevice(); drawclock(); for(i=sec;!kbhit();i++) { clock(i); } getch(); end(); getch(); // closegraph(); } /*************************INTRODUCTION **********************/ void introduction() {int i,j,k,x,y; int size=5,style=1; settextjustify(CENTER_TEXT, CENTER_TEXT); settextstyle(style, HORIZ_DIR, size); setcolor(BLUE); outtextxy(100,200," WELCOME TO "); delay(1000); setcolor(GREEN); outtextxy(100,250," RAGHU'S CLOCK SHOW"); delay(1000); cleardevice(); setfillstyle(1,3); for(i=0;i<15;i++) { setcolor(i); settextstyle(1,0,3); outtextxy(500,400,"Loading......"); for(j=0;j<100;j++) { circle(a,b+50,j); delay(10); } } } /**************************DRAWS THE CLOCK ********************************/ void drawclock() { int i,j,k; int x1,x2,y1,y2,x3,y3; char *ch; setcolor(15); setfillstyle(1,0); settextstyle(0,0,1); floodfill(a-r-1,b,0); for(i=0;i<3;i++) { circle(a,b,r+i); //----Draws the outer circles circle(a,b,i); //----Draws the center pixels } for(i=0;i<360;i=i+6) //-----Draws the minute identification marks { x1=a+r*cos(3.14*i/180); y1=b+r*sin(3.14*i/180); x2=a+(r-5)*cos(3.14*i/180); y2=b+(r-5)*sin(3.14*i/180); line(x1,y1,x2,y2); } for(j=0;j<360;j=j+30) //-------Draws the 5 min identification marks { x1=a+r*cos(3.14*j/180); y1=b+r*sin(3.14*j/180); x2=a+(r-10)*cos(3.14*j/180); y2=b+(r-10)*sin(3.14*j/180); line(x1,y1,x2,y2); } line(a-r,b,a-r,b+300); line(a+r,b,a+r,b+300); line(a-r,b+300,a+r,b+300); floodfill(a,b+150,15); for(i=-60,j=1;i<300;i=i+30,j++) //-------Draws the numbers { sprintf(ch,"%d",j); x1=a+(r-20)*cos(3.14*i/180); y1=b+(r-20)*sin(3.14*i/180); outtextxy(x1,y1,ch); } setfillstyle(1,color); floodfill(a+5,b,15); setfillstyle(1,8); floodfill(0,0,15); } /********************ACTUAL CLOCK OPERATION************************/ void clock(int sec) { int i,j,k; if(sec==60) {sec=sec-60; min++;} if(min==60){min=0;hour++;} if(hour>12){hour=hour-12;} //-------Angles calculation sec_ang=(sec*6)-90; min_ang=((min*6)-90)+(sec/10); hour_ang=(hour*30)+(sec/120)-90; sound(5000); setcolor(color); line(a,b,x3,y3); line(a,b,x41,y41); line(a,b,x42,y42); line(x41,y41,x4,y4); line(x42,y42,x4,y4); setfillstyle(1,color); floodfill(x43,y43,color); line(a,b,x51,y51); line(a,b,x52,y52); line(x51,y51,x5,y5); line(x52,y52,x5,y5); setfillstyle(1,color); floodfill(x53,y53,color); x3=a+(r-35)*cos(3.14*sec_ang/180); y3=b+(r-35)*sin(3.14*sec_ang/180); x4=a+(r-35)*cos(3.14*min_ang/180); y4=b+(r-35)*sin(3.14*min_ang/180); x41=a+(r-45)*cos(3.14*(min_ang-3)/180); y41=b+(r-45)*sin(3.14*(min_ang-3)/180); x42=a+(r-45)*cos(3.14*(min_ang+3)/180); y42=b+(r-45)*sin(3.14*(min_ang+3)/180); x43=a+(r-45)*cos(3.14*(min_ang)/180); y43=b+(r-45)*sin(3.14*(min_ang)/180); x5=a+(r-40)*cos(3.14*hour_ang/180); y5=b+(r-40)*sin(3.14*hour_ang/180); x51=a+(r-50)*cos(3.14*(hour_ang-5)/180); y51=b+(r-50)*sin(3.14*(hour_ang-5)/180); x52=a+(r-50)*cos(3.14*(hour_ang+5)/180); y52=b+(r-50)*sin(3.14*(hour_ang+5)/180); x53=a+(r-50)*cos(3.14*(hour_ang)/180); y53=b+(r-50)*sin(3.14*(hour_ang)/180); setcolor(RED); line(a,b,x51,y51); line(a,b,x52,y52); line(x51,y51,x5,y5); line(x52,y52,x5,y5); setfillstyle(1,RED); floodfill(x53,y53,RED); setcolor(GREEN); line(a,b,x41,y41); line(a,b,x42,y42); line(x41,y41,x4,y4); line(x42,y42,x4,y4); setfillstyle(1,GREEN); floodfill(x43,y43,GREEN); setcolor(BLUE); line(a,b,x3,y3); nosound(); if(flag==1) for(i=75;i<105;i++) { bobx1=a+(r+5)*cos(3.14*i/180); boby1=b+(r+5)*sin(3.14*i/180); bobx2=a+(r+150)*cos(3.14*i/180); boby2=b+(r+150)*sin(3.14*i/180); bobx3=a+(r+125)*cos(3.14*i/180); boby3=b+(r+125)*sin(3.14*i/180); setcolor(3); line(bobx1,boby1,bobx3,boby3); outtextxy(bobx3,boby3,"Raghu"); circle(bobx2,boby2,20); circle(bobx2,boby2,25); setfillstyle(2,4); delay(15); setcolor(0); line(bobx1,boby1,bobx3,boby3); outtextxy(bobx3,boby3,"Raghu"); flag=0; circle(bobx2,boby2,25); circle(bobx2,boby2,20); } if(flag==0) for(i=105;i>75;i--) { bobx1=a+(r+5)*cos(3.14*i/180); boby1=b+(r+5)*sin(3.14*i/180); bobx2=a+(r+150)*cos(3.14*i/180); boby2=b+(r+150)*sin(3.14*i/180); bobx3=a+(r+125)*cos(3.14*i/180); boby3=b+(r+125)*sin(3.14*i/180); setcolor(3); line(bobx1,boby1,bobx3,boby3); outtextxy(bobx3,boby3,"Raghu"); circle(bobx2,boby2,25); circle(bobx2,boby2,20); setfillstyle(2,4); delay(15); setcolor(0); line(bobx1,boby1,bobx3,boby3); outtextxy(bobx3,boby3,"Raghu"); flag=1; circle(bobx2,boby2,25); circle(bobx2,boby2,20); } } void end() { int i,j,k; cleardevice(); settextstyle(1,0,1); setcolor(3); outtextxy( 150,100,"For any help and suggestions"); outtextxy(170,120," please send your requests to my e-mail:"); while(!kbhit()) { for(i=0,j=600;i<600,j>0;i++,j--) { setcolor(random(15)); outtextxy(150+i,160," raghuram.kolipaka@gmail.com"); outtextxy(150+j,200," raghuram_kolipaka@yahoo.co.in"); setcolor(0); outtextxy(150+i,160," raghuram.kolipaka@gmail.com"); outtextxy(150+j,200," raghuram_kolipaka@yahoo.co.in"); } if(i==600) { for(i=600,j=0;i>0,j<600;i--,j++) { setcolor(random(15)); outtextxy(150+i,160," raghuram.kolipaka@gmail.com"); outtextxy(150+j,200," raghuram_kolipaka@yahoo.co.in"); setcolor(0); outtextxy(150+i,160," raghuram.kolipaka@gmail.com"); outtextxy(150+j,200," raghuram_kolipaka@yahoo.co.in"); } } } }

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
Copyright ©2003-2017 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=1161


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