小编DK1*_*K10的帖子

鼠标移动opengl

我正在使用纯 OpenGL(无外部工具)创建一个用 C++ 编写的台球游戏,但我可以使用 GLUT。我画了一个台球杆,我想跟随鼠标光标,但我不知道如何做到这一点。

我知道如何使用键盘输入来移动物体,例如相机位置或绘制对象,但我不确定如何使用鼠标输入来移动对象。

这是我试图通过鼠标输入移动的提示:

void cue () {
  glBegin;
  glTranslatef(-10,5,0); 
  glRotatef(90,0,1,0); 
  glutSolidCone(0.25, 15, 20, 20);
  glEnd();
}
Run Code Online (Sandbox Code Playgroud)

c++ opengl mouse glut

3
推荐指数
1
解决办法
2万
查看次数

移动代码c ++

我正在使用DirectX在C++中制作游戏.我有一个基本的AI绘制.我希望AI在一个正方形中移动,例如:

  • AI向上移动Z轴直到达到25,
  • 然后AI沿X轴移动25,
  • 然后沿着Z轴下降25,
  • 然后沿X轴返回,直到它完成一个方形的完整运动.

这是我到目前为止所拥有的; 这使得AI在Z轴上向上移动25,然后在Z轴上向下移动25次.

if (ghost_moves_forward == true)
{
    ghost_Z -= ghost_movement;
}
else if (ghost_moves_forward == false)
{
    ghost_Z += ghost_movement;
}


if (ghost_Z >= 25)
{
    ghost_moves_forward = true;
}
if (ghost_Z <= -25)
{
    ghost_moves_forward = false;
}
Run Code Online (Sandbox Code Playgroud)

先感谢您.


编辑:

float ghost_X = 0; //make the AI move along the x axis
float ghost_Z = 0; // makes the AI move along the Z axis
int ghost_movement = 1; // speed the AI moves …
Run Code Online (Sandbox Code Playgroud)

c++ directx artificial-intelligence

0
推荐指数
1
解决办法
1767
查看次数

标签 统计

c++ ×2

artificial-intelligence ×1

directx ×1

glut ×1

mouse ×1

opengl ×1