rendered paste body#include <allegro.h>
BITMAP *bufor_ekranu = NULL ;
void init();
void deinit();
void rysujwykres();
void rysuj(double tablica[],int rozmiar,int sekund, double timed) ;
void zerowanie(double tablica[],int rozmiar) {
int cos=1 ;
for(int i=0;i<rozmiar;i++)
{
tablica[i]=cos ;
if(i==50) cos=0;
}
};
int main() {
int rozmiar = 100 ;
double tablica[100];
zerowanie(tablica,rozmiar) ;
int color= 16581375 ;
int color2= 16431375 ;
//int czas = 100 ;
double de = 1.0e-5 ;
double timed = 100 ;
/*
for(int i=0;i<100;i++) cout << tablica[i] <<", ";
char d ;
cin >> d ;
}*/
init();
int tab[]={ 51,75, 51,SCREEN_H-50,
SCREEN_W-75,SCREEN_H-50, SCREEN_W-75,75
};
int sekund = 10 ;
clear(bufor_ekranu) ;
rysuj(tablica,rozmiar,sekund,timed);
deinit();
return 0;
}
END_OF_MAIN()
void init() {
int depth, res;
allegro_init();
depth = desktop_color_depth();
if (depth == 0) depth = 32;
set_color_depth(depth);
res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
if (res != 0) {
allegro_message(allegro_error);
exit(-1);
}
if(!(bufor_ekranu = create_bitmap(640,480)))
{
set_gfx_mode(GFX_TEXT,0,0,0,0);
allegro_message("Zamalo pamieci potrzebnej do stworzenia bufora ekranu !\n");
allegro_exit();
}
install_timer();
install_keyboard();
install_mouse();
/* add other initializations here */
}
void deinit() {
clear_keybuf();
/* add other deinitializations here */
}
void rysujwykres() {
//clear_bitmap(screen);
int color=makecol(0, 153, 219); //16581375;
textprintf_ex(bufor_ekranu, font, 280, 20, color,
-1, "II Prawo Ficka");
textprintf_ex(bufor_ekranu, font, 20, 125, color,
-1, "1");
textprintf_ex(bufor_ekranu, font, SCREEN_W-95, SCREEN_H-35, color,
-1, "100");
fastline(bufor_ekranu, 50, 50, 50, SCREEN_H-50, color);
triangle(bufor_ekranu, 50, 50, 50-3, 50+20, 50+3, 50+20, color);
fastline(bufor_ekranu, 50, SCREEN_H-50, SCREEN_W-50, SCREEN_H-50, color);
triangle(bufor_ekranu, SCREEN_W-50, SCREEN_H-50, SCREEN_W-70, SCREEN_H-50-3,SCREEN_W-70, SCREEN_H-50+3, color);
for(int i=1;i<=100;i=i+5)
fastline(bufor_ekranu, 50+5*i, SCREEN_H-50+2, 50+5*i, SCREEN_H-50-2, color) ;
for(int i=1;i<=100;i=i+5)
fastline(bufor_ekranu, 50-2, SCREEN_H-50-3*i, 50+2, SCREEN_H-50-3*i, color) ;
}
void rysuj(double tablica[],int rozmiar,int sekund, double timed) {
double de = 1.0e-5 ;
float deltax=0.2 / 100.0 ;
float deltat=0.01 ;
float ab, bb ;
int color= 16581375 ;
int color2= 16431375 ;
int a, b;
for(double i=1;i<timed;i=i+deltat) {
tablica[0]=tablica[1];
tablica[rozmiar]=tablica[rozmiar-1];
for(int j=1;j<rozmiar;j++)
{
tablica[j]= de * deltat *((tablica[j+1]-2*tablica[j]+tablica[j-1])/(2*(deltax)*(deltax))) + tablica[j];
}
if((int)i % 5 == 0) {
clear(bufor_ekranu);
rysujwykres();
for(int i=1;i<100;i++)
{
ab= (float) (tablica[i-1] / 1) * 100 ;
bb= (float) (tablica[i] / 1) * 100 ;
a = (int) ab;
b = (int) bb;
line(bufor_ekranu, 50+5*(i-1)+1, SCREEN_H-50-((a*3)+1), 50+5*i+1, SCREEN_H-50-((b*3)+1), makecol(0,255,0)) ;
}
textprintf_ex(bufor_ekranu, font, 180, 445, makecol(0,0,255),-1, "zakoncz - enter");
if(key[KEY_ENTER]) {return;};
blit(bufor_ekranu,screen,0,0,0,0,640,480);
}
//koniec for:P
}
while(!key[KEY_ENTER]) {;};
return;
}