游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2230|回复: 1

关于龙书的问题

[复制链接]

12

主题

23

帖子

164

积分

注册会员

Rank: 2

积分
164
发表于 2012-12-4 17:32:00 | 显示全部楼层 |阅读模式
bool Display(float timeDelta)
{
if( Device )
{
//
// Update the scene: update camera position.
//

static float angle  = (3.0f * D3DX_PI) / 2.0f;
static float height = 2.0f;

if( ::GetAsyncKeyState(VK_LEFT) & 0x8000f )
angle -= 0.5f * timeDelta;

if( ::GetAsyncKeyState(VK_RIGHT) & 0x8000f )
angle += 0.5f * timeDelta;

if( ::GetAsyncKeyState(VK_UP) & 0x8000f )
height += 5.0f * timeDelta;

if( ::GetAsyncKeyState(VK_DOWN) & 0x8000f )
height -= 5.0f * timeDelta;

D3DXVECTOR3 position( cosf(angle) * 3.0f, height, sinf(angle) * 3.0f );
D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
D3DXMATRIX V;
D3DXMatrixLookAtLH(&V, &position, &target, &up);

Device->SetTransform(D3DTS_VIEW, &V);

//
// Draw the scene:
//

Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
Device->BeginScene();

Device->SetMaterial(&d3d::WHITE_MTRL);
Device->SetTexture(0, Tex);

Box->draw(0, 0, 0);

Device->EndScene();
Device-&gtresent(0, 0, 0, 0);
}
return true;
}

我尝试将 angle -= 0.5f * timeDelta; 改成 angle -= 0.5f * 0.03; 按住左键不动就物体转的飞快,加上timeDelta转的就正常了,这是为什么?

33

主题

159

帖子

272

积分

中级会员

Rank: 3Rank: 3

积分
272
QQ
发表于 2012-12-5 18:36:00 | 显示全部楼层

Re:关于龙书的问题

- -!
vs是可以断点调试的(不要小看breakpoint ,写android/ndk 的程序是没有断点的,太可怕了)
你在
angle -= 0.5f * timeDelta
这句上加个钉,叫程序停下来看看你就知道了,估计你这程序,如果不开垂直同步,direct的FPS怎么都在2000+,也就是timedelta 最多0.0005,你给个0.03,喵的,你太看的起它了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-7-25 21:57

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表