|
楼主 |
发表于 2006-1-21 09:48:00
|
显示全部楼层
Re: 如何实现类似剑侠情缘系列的平滑滚动?
演示的主循环代码如下:
void GameRun()
{
const int DELAY = 16;
static double DelayTick = DELAY * freq / 1000;
static int x = 0, y = 0;
static double now, old;
LARGE_INTEGER time;
QueryPerformanceCounter(&time);
now = (double)time.QuadPart;
if (now - old < DelayTick)
{
return;
}
old = now;
GetGraphics()->ClearScreenMMX(0);
GetGraphics()->DrawBitmapMMX(x, y, bg, SCREENBUFFER);
GetGraphics()->DrawBitmapMMX(x - 640, y, bg, SCREENBUFFER);
GetGraphics()->DrawBitmapMMX(x + 640, y, bg, SCREENBUFFER);
GetGraphics()->UpdateScreen();
GetGraphics()->resent();
if (GetAsyncKeyState(VK_LEFT))
{
x -= 2;
if (x < -640)
x = 0;
}
if (GetAsyncKeyState(VK_RIGHT))
{
x += 2;
if (x > 640)
x = 0;
}
}
能详细指点一下吗?谢谢! |
|