OpenGL,我如何在到达目标后禁用glutSpecialFunc
OpenGL, How do I disable glutSpecialFunc after I reach a target?
我们正在OpenGL中制作一个迷宫式的程序,我们允许用户使用箭头键在屏幕上移动目的地。当用户使用箭头键到达目的地时,我想禁止用户再使用键盘。有没有办法让我做一些glutSpecialFunc.disable?以下是我想在if语句中禁用的地方:
void myKeyboard(int keys, int x, int y){
switch(keys){ ...
}
if(location == G.source){
cout<<"nYou have completed the game";
drawShortestPath();
/* Enter disable code here */
}
}
当玩家到达目标/目的地时,您可以简单地切换一个布尔值,并在myKeyboard()
函数中检查该布尔值。
bool game_done = false;
void myKeyboard(int keys, int x, int y) {
if (!game_done) {
switch(keys) {
// ... the rest of your code ...
}
}
}
然后,当玩家到达目标/目的地时,简单地说game_done = true;
您可以将其称为lock_keyboard
,而不是调用布尔值game_done
,这可能在总体上更有意义。
然后,如果您想再次"激活"键盘,只需再次切换布尔值(将其设置为false)
相关文章:
- 如何(从固定列表中)选择一个数字序列,该序列将与目标数字相加
- C++A*算法并不总是在路径中具有目标节点
- 基于树莓pi的tensorflow lite量化ssd目标检测
- 为测试目标创建具有不同源文件夹的文件
- 使用源向量作为目标
- 是否可以用C++/WinRT将windows 10.0.14393作为目标
- 在 CMake 中为每个目标设置编译器/链接器标志
- qmake:检测目标位宽(32 位或 64 位)
- 如何在 CMake 中对目标依赖项进行分组?
- 我的目标是编写一个程序来计算和存储字符串在字符数组中出现的位置
- 如何为包含头文件的目标编写生成文件?
- 线性优化目标函数中的绝对值
- 制作文件:没有规则来制定目标:如何设置正确的规则?
- 字符串函数在目标C++上运行时C++返回空
- 如何定义自定义生成配置类型,其中通常是.exe的目标改为 DLL
- 请求最简单的 OpenMP 目标 GPU 示例
- LLVM 编译:目标的配方 '../lib/IR/Release+Asserts/Intrinsics.gen.tmp' failed
- 当目标指针不是基类的类型时,为什么允许dynamic_cast为多态类生成 null 指针?
- 我应该如何在没有变量的情况下将相同的参数传递给 CMAKE 中的多个目标?
- CMake 错误 - 目标 foo INTERFACE_SOURCES属性包含在源目录中以前缀为前缀的路径