c'de basit bir animasyon
Bu kodları "animasyn.cpp" olarak kaydedin. Daha sonra egavga.bgi dosyasını C programının kurulu olduğu klasörde arattırıp bulun ve "animasyn.cpp" dosyasının bulunduğu klasörün içine kopyalayın. "animasyn.cpp" dosyasını C'de derleyin. C'de programı debug yapmadan önce Options\Linker\Libraries yoluyla Çıkan Pencerede Graphics Library seçeneğini aktif hale getirin. Sonra Programı Çalıştırabilirsiniz.
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
int main(void)
{
/* request auto detection*/
int gdriver=DETECT, gmode, errorcode;
int midx, midy, i, a, s, c, k;
/*initialize graphics and local variables*/
initgraph(&gdriver, &gmode, "");
/* read result of initialization*/
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred*/
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code*/
}
midx = getmaxx()-640;
midy = getmaxy()-480;
for(k=0;k<=640;k=k+10)
{
for(s=0;s<=640;s=s+10)
{
for(i=0;i<=10;i++)
{
for(a=0;a<=10;a++)
{
/*printf("%d,%d,%d",midx+a+k,midy+s+i,c);*/
putpixel(midx+a+k,midy+s+i,c);
}
}
c++;
}
}
for(k=0;k<=640;k=k+10)
{
for(s=0;s<=640;s=s+10)
{
for(i=0;i<=10;i++)
{
for(a=0;a<=10;a++)
{
putpixel(midx+a+k,midy+s+i,0);
}
}
c++;
}
}
/* clean up */
getch();
closegraph();
return 0;
}
ŞİMDİLİK BU Kadar