Gri*_*fin 2 windows console compatibility
嘿所以我使用pdCurses库和microsoft opperating系统工具制作了一个文本游戏.这是我的包含,并在下面查看其他探索:
#include <iostream>
#include <time.h> // or "ctime"
#include <stdio.h> // for
#include <cstdlib>
#include <Windows.h>
#include <conio.h>
#include<curses.h>
#include <algorithm>
#include <string>
#include <vector>
#include <sstream>
#include <ctime>
#include <myStopwatch.h> // for keeping times
#include <myMath.h> // numb_digits() and digit_val();
Run Code Online (Sandbox Code Playgroud)
myStopwath/Math.h包括:
#include <stdio.h>
#include <math.h>
#include <tchar.h>
Run Code Online (Sandbox Code Playgroud)
所以我在运行Windows 7的计算机上测试了游戏(其中包含一个包含.exe和pdcurses.dll的文件夹)并且效果很好,但是当在另一台具有vista或更旧版本的计算机上运行时,我的游戏会出现,但是由于所有球员的生命几乎瞬间丧失而立即结束......这怎么可能?
如果您想查看完整的源代码,请转到此链接
谢谢!
在主游戏循环中,您没有coll在传递变量之前初始化变量theScreen.check_collision().如果玩家没有危险,那么该功能不会更新此值.回到主循环,你不检查check_collision()的返回值,程序现在根据该变量中的未初始化值做出决策.欢迎来到广泛的未定义行为世界.
您在不同操作系统上看到的差异很可能是由于不同堆管理器初始化内存页面的方式.即使您的播放器存活了一段时间,在第一次碰撞后,该内存位置现在保持"X",然后永远不会被清除,并且虽然结果仍然是"未定义",但在大多数架构中,这将导致注册新的每次迭代都会发生碰撞,解释为什么你的"生命"会如此迅速地消失.
要解决此问题,您需要做两件事:
| 归档时间: |
|
| 查看次数: |
181 次 |
| 最近记录: |