The following are the code to approximate the motion of falling object. However the Object does not move...
I have shown the "time" and the "distance" at the top right of the screen. The time is run, but the distance stop at 0....
Can anyone help me to correct it?
(i am using Visual Studio2008)
#include "DarkGDk.h"
const int RefreshRate = 60;
const int Acceleration = 0.98;
void DarkGDK()
{
int ball1x, ball1y, ball2x, ball2y;
int time = 0;
float distance;
void setup();
int maxY = dbScreenHeight() - 50;
ball2y = 100;
ball2x = dbScreenWidth() / 2 +50;
ball1y = 0;
ball1x = dbScreenWidth() / 2 -50;
dbSyncOn();
dbSyncRate(RefreshRate);
while (LoopGDK())
{
dbCLS();
const DWORD RED = dbRGB(255,0,0);
const DWORD BLACK = dbRGB(0,0,0);
dbInk(RED,BLACK);
dbBox( ball1x, ball1y, ball2x, ball2y);
dbPrint(dbStr(time));
if (ball2y < maxY)
{
distance = 0.5 * Acceleration * time * time;
ball1y = distance;
ball2y += distance;
dbPrint(dbStr(distance));
dbLine(0,ball1y,100,ball1y);
time++;
}
else
{
ball2y = maxY;
ball1y = maxY - 100;
}
dbSync();
}
}
Thankyou@@!