exanews

exanews jam digital

Animasi Jam Digital Dengan Dev C++


Langkah - Langkah Membuatnya:

1. Buka Dev C++ > New Project
2. Project Options > Pilih Compiler > Base Compiler Set: TDM-GCC 4.9.2 32-bit Release
3. Pilih Parameter > Masukkan Linker Berikut:
-lbgi 
-lgdi32 
-luser32
Didalam Kolom Linker > Klik Ok
4. Silahkan Copy-Paste Script Program Dibawah Ini Ke Project Baru Anda: 
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
using namespace std;
main(){
 ulang:
 system("cls");
 int n_hour,n_minute;
 char ulang;
 printf("  *****************************************************\n");
 printf("  **********Selamat Datang Di Program Jam Saya*********\n");
 printf("  *****************************************************\n");
 printf("\n  Input Jam (0-23) : ",n_hour);
 scanf("%d",&n_hour);
 printf("\n  Input Menit (0-59) : ",n_minute);
 scanf("%d",&n_minute);
 if(((n_hour>=24)||(n_hour<0))||((n_minute>=60)||(n_minute<0))){
  goto ulang;
 }
 else{
 printf("\n\n");
 printf("  ******************Terimakasih ^_^********************");
 printf("\n\n");
 printf("  Credit : Khairul Fuad 5SIA2\n");
 //pengaturan kanvas
 initwindow(900,750);
 int midx=getmaxx()/2;
 int midy=getmaxy()/2;
 //deklarasi variable
 int h,dt,mn,ms;
 for(;;){//perulangan gak habis-habis
 for(h=n_hour;h<=23;h++){//perulangan jam
  n_hour=n_hour*0;
  for(mn=n_minute;mn<=59;mn++){//perulangan menit
   n_minute=n_minute*0;
   for(dt=0;dt<=59;dt++){//perulangan detik
    setcolor(1);
    //badan jam
    setlinestyle(0,0,3);
    ellipse(midx,midy-50+20,295,245,270,255);//lapisan 1 1
    ellipse(midx,midy-50+20,262,278,270,255);//lapisan 1 2
    setcolor(9);
    ellipse(midx,midy-70+20,0,360,230,205);//lapisan 2
    
    //wajah jam
    setcolor(10);
    setlinestyle(0,0,1);
    ellipse(midx,midy-70+20,0,360,180,155);//lapisan 3
    //kaki depan
    //kaki kiri
    setcolor(1);
    setlinestyle(0,0,2);
    line(midx-101,midy+164+20,midx-132,midy+252+20);//tepi lurus kiri
    line(midx-30,midy+181+20,midx-50,midy+252+20);//tepi lurus kanan
    arc(midx-86,midy+262+20,55,98,100);//tepi lengkung atas
    arc(midx-90,midy+162+20,246,295,100);//tepi lengkung bawah
    //kaki kanan
    line(midx+101,midy+164+20,midx+132,midy+252+20);
    line(midx+30,midy+181+20,midx+50,midy+252+20);
    arc(midx+86,midy+262+20,82,125,100);//tepi lengkung atas
    arc(midx+90,midy+162+20,246,295,100);//tepi lengkung bawah
    //kaki belakang
    //kaki belakang kiri
    line(midx-264,midy+179,midx-218,midy+117);
    line(midx-235,midy+215,midx-178,midy+160);
    arc(midx-245,midy+194,145,295,24);
    //kaki belakang kanan
    line(midx+264,midy+179,midx+218,midy+117);
    line(midx+235,midy+215,midx+178,midy+160);
    arc(midx+245,midy+194,245,35,24);
    //tombol hidup Radio
    setcolor(1);
    setlinestyle(0,0,2);
    circle(midx+182,midy-130,18);
    setcolor(9);
    arc(midx+182,midy-130,110,70,10);
    line(midx+182,midy-130,midx+182,midy-142);
    //tombol jam
    setcolor(1);
    circle(midx-182,midy-130,18);
    setcolor(9);
    circle(midx-182,midy-130,9);
    line(midx-182,midy-130,midx-182,midy-135);
    line(midx-182,midy-130,midx-177,midy-130);
    //tombol forward
    setcolor(1);
    circle(midx+203,midy-40,18);
    setcolor(9);
    int f1[]={midx+204,midy-46,midx+210,midy-40,midx+204,midy-34,midx+204,midy-46};
    drawpoly(4,f1);
    int f2[]={midx+197,midy-46,midx+203,midy-40,midx+197,midy-34,midx+197,midy-46};
    drawpoly(4,f2);
    //tombol backward
    setcolor(1);
    circle(midx-203,midy-40,18);
    setcolor(9);
    int b1[]={midx-204,midy-46,midx-210,midy-40,midx-204,midy-34,midx-204,midy-46};
    drawpoly(4,b1);
    int b2[]={midx-197,midy-46,midx-203,midy-40,midx-197,midy-34,midx-197,midy-46};
    drawpoly(4,b2);
    settextjustify(CENTER_TEXT,VCENTER_TEXT);
    settextstyle(0,HORIZ_DIR,1);
    //tombol Alarm 1
    setcolor(1);
    circle(midx-170,midy+50,18);
    setcolor(9);
    circle(midx-170,midy+50,8);
    outtextxy(midx-170,midy+52,"1");
    setlinestyle(0,0,5);
    line(midx-164,midy+55,midx-164,midy+55);
    line(midx-177,midy+55,midx-177,midy+55);
    line(midx-173,midy+40,midx-178,midy+42);
    line(midx-167,midy+40,midx-162,midy+42);
    //tombol Alarm 2
    setcolor(1);
    setlinestyle(0,0,2);
    circle(midx+170,midy+50,18);
    setcolor(9);
    circle(midx+170,midy+50,8);
    outtextxy(midx+170,midy+52,"2");
    setlinestyle(0,0,5);
    line(midx+163,midy+55,midx+163,midy+55);
    line(midx+176,midy+55,midx+176,midy+55);
    line(midx+173,midy+40,midx+178,midy+42);
    line(midx+167,midy+40,midx+162,midy+42);
    //antena
    setcolor(15);
    //antena kiri
    setlinestyle(0,0,2);
    arc(midx-203,midy-210,47,227,115);
    arc(midx-33,midy-52,111,163,260);
    setcolor(9);
    arc(midx-254,midy-261,260,275,120);
    arc(midx-254,midy-256,358,15,120);
    //antena kanan
    setcolor(15);
    setlinestyle(0,0,2);
    arc(midx+203,midy-210,313,133,115);
    arc(midx+33,midy-52,17,69,260);
    setcolor(9);
    arc(midx+254,midy-261,265,280,120);
    arc(midx+254,midy-256,165,182,120);
    //pengaturanb teks radio AM/FM
    setcolor(9);
    settextjustify(CENTER_TEXT,VCENTER_TEXT);
    settextstyle(9,HORIZ_DIR,1);
    outtextxy(midx+95,midy-120,"AM/FM");
    //menambahkan angka 0
    char jam[5];
    char menit[5];
    if((h<10)&&(mn<10)){
     sprintf(jam,"0%d",h);
     sprintf(menit,"0%d",mn);
    }
    else if((h<10)&&(mn>=10)){
     sprintf(jam,"0%d",h);
     sprintf(menit,"%d",mn);
    }
    else if((h>=10)&&(mn<10)){
     sprintf(jam,"%d",h);
     sprintf(menit,"0%d",mn);
    }
    else{
     sprintf(jam,"%d",h);
     sprintf(menit,"%d",mn);
    }
    //menampilkan digit jam
    //pengaturan text
    settextjustify(CENTER_TEXT,VCENTER_TEXT);
    settextstyle(9,HORIZ_DIR,9);
    if(dt%2==0){
     setcolor(10);
     outtextxy(midx,midy-19,":");
     outtextxy(midx-90,midy-10,jam);
     outtextxy(midx+90,midy-10,menit);
    }
    else{
     setcolor(10);
     outtextxy(midx,midy-19," ");
     outtextxy(midx-90,midy-10,jam);
     outtextxy(midx+90,midy-10,menit);
    }
    settextjustify(CENTER_TEXT,VCENTER_TEXT);
    settextstyle(10,HORIZ_DIR,4);
    setcolor(9);
    outtextxy(midx,midy+55,"Electrohome");
    delay(1000);
   }//end perulangan detik
   cleardevice();
  }//end perulangan menit
 }//end perulangan jam
 }//end perulangan gak habis-habis
 }//end if ulang
 getch();
 closegraph();
 return 0;
}
5. Kemudian Save Dan Tekan F11
6. Sekian Dan Terima Kasih

Related Posts

Seorang yang memiliki kepribadian yang menyendiri, tanpa mengenal dunia luar hanya melalui dunia online.
  • Facebook
  • WhatsApp
  • Instagram
  • Subscribe Our Newsletter

    Belum ada Komentar untuk "Animasi Jam Digital Dengan Dev C++"

    Posting Komentar

    Iklan Atas Artikel

    Iklan Tengah Artikel 1

    Iklan Tengah Artikel 2

    Iklan Bawah Artikel