I have changed a bit of the program...and ...it does not work again...Would you please have a look?
The objective of the programme change to approximate the motion of object with acceleration and deceleration.
The odject will accelerate until travelling distance = 300,
and change to deceleration at constant rate. The object will stop at velocity = 0.
I am not sure which part is wrong....
#include "DarkGDk.h"
void DackGDK()
{
dbSetDisplayMode(700,300,dbScreenDepth());
dbSetWindowTitle("Moving Box With Acceleration and Deceleration");
const float Acceleration = 0.1;
const float Deceleration = 0.1;
const int RefreshRate = 60;
const int StartToDecelerate = 300;
int box1x, box1y, box2x, box2y;
int Time = 0;
float TravelDistance = 0;
float TravelVelocity = 0;
box2x = 25;
box2y = dbScreenHeight() /2 + 5;
box1x = 15;
box1y = dbScreenHeight() /2 - 5;
dbSyncOn();
dbSyncRate(RefreshRate);
while (LoopGDK())
{
dbCLS();
const DWORD RED = dbRGB(255,0,0);
const DWORD BLACK = dbRGB(0,0,0);
dbInk(RED,BLACK);
dbBox( box1x, box1y, box2x, box2y);
dbPrint(dbStr(TravelDistance));
dbPrint(dbStr(Time));
if (TravelDistance < StartToDecelerate)
{
TravelVelocity = Acceleration * Time;
TravelDistance = Acceleration * Time * Time /2;
box2x += TravelDistance;
box1x += TravelDistance;
Time ++;
}
else if (TravelVelocity > 0)
{
Time = 0;
TravelVelocity -= (Deceleration * Time);
TravelDistance += (TravelVelocity * Time - Deceleration * Time * Time /2);
box2x += TravelDistance;
box1x += TravelDistance;
Time ++;
}
else
{
box2x = TravelDistance;
box1x = TravelDistance;
}
dbSync();
}
}
The system has the following output:
1>------ Build started: Project: Dark GDK - Moving Object with A D, Configuration: Debug Win32 ------
1>Compiling...
1>Main.cpp
1>Linking...
1>darksdk.lib(DarkSDK.obj) : error LNK2019: unresolved external symbol "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ) referenced in function _WinMain@16
1>Debug\Dark GDK - Moving Object with A D.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\Win 7 User\Documents\Visual Studio 2008\Projects\Dark GDK - Moving Object with A D\Dark GDK - Moving Object with A D\Debug\BuildLog.htm"
1>Dark GDK - Moving Object with A D - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Thankyou@@!