Original Post
I want to create realistic gravity(using newton's 2nd law formula)..but there seems to be a problem with timer...
#include<allegro.h>
#include<winalleg.h>
BITMAP *buffer;
int main()
{
int v=100; //vertical speed
int y; //the y variable
allegro_init();
install_keyboard();
//set_color_depth(32);
set_gfx_mode( GFX_AUTODETECT, 800, 600, 0, 0);
acquire_screen();
buffer = create_bitmap(800, 600);
for(int i=0;i<=800;i++) //ground plane basically
putpixel(buffer,i,500,makecol(200,200,200));
float time=GetTickCount()/1000; //time stuff
float time1;
while(!key[KEY_ESC])
{
clear_to_color(buffer, makecol( 0, 0, 0));
for(int i=0;i<=800;i++)
putpixel(buffer,i,500,makecol(20,20,20));
time1=(GetTickCount()/1000)-time;
y = 500 - (v*time1) + (5*(time1*time1)); //NEWTONS SECOND LAW y=ut-1/2gt^2
putpixel(buffer,400,y,makecol(200,200,200));
blit(buffer, screen, 0, 0, 0, 0, 800, 600);
}
release_screen();
return 0;
}
END_OF_MAIN();