社区
游戏开发
帖子详情
directdraw程序假死机的问题
zeronecpp
2006-02-13 09:01:20
我初学directx, 写了个简单的游戏程序, 运行的时候,同样的程序有时候没问题, 但有时候编译之后就会进入就不动了. 而且在我的机器上可以很好的运行时,在别的(已装directx runtime)机器上会假死机. 有人能解决这个问题吗? 是我的程序的问题还是别的什么问题呢?
...全文
134
6
打赏
收藏
directdraw程序假死机的问题
我初学directx, 写了个简单的游戏程序, 运行的时候,同样的程序有时候没问题, 但有时候编译之后就会进入就不动了. 而且在我的机器上可以很好的运行时,在别的(已装directx runtime)机器上会假死机. 有人能解决这个问题吗? 是我的程序的问题还是别的什么问题呢?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
Bobby136
2006-02-14
打赏
举报
回复
楼上的代码没有用到directx
你的机子的显示设置,显卡等和别人的机子不同,也有可能出问题
zeronecpp
2006-02-13
打赏
举报
回复
这是主要的类的代码,继承自一个实现初始化环境等工作的基类
CBricksGame::CBricksGame(void)
{
}
CBricksGame::~CBricksGame(void)
{
}
bool CBricksGame::FreshGrid()
{
int i;
int j;
for(i=0;i<12;i++)
{
for(j=0;j<16;j++)
{
int tmp=MapGrid[i][j];
Grid[i][j]=tmp;
}
}
return true;
}
bool CBricksGame::CreateBrick()
{
srand(GetTickCount());
shp=rand()%7;
style=rand()%4;
m_x=5;
m_y=0;
return true;
}
bool CBricksGame::ProcKey()
{
if(!GetKeyboardState(m_key_state)) return false;
if(m_key_state[DIK_ESCAPE] & 0x80)
PostQuitMessage(0);
else if(m_key_state[DIK_RIGHT] & 0x80)
{
if(!FreshGrid())return false;
if(m_x+shape[shp][style][17]<12) m_x++;
}
else if(m_key_state[DIK_LEFT]& 0x80)
{
if(!FreshGrid())return false;
if(m_x>0) m_x--;
}
else if(m_key_state[DIK_DOWN] & 0x80)
{
if(!FreshGrid())return false;
if(!ProcDown())return false;
}
else if(m_key_state[DIK_SPACE] & 0x80)
{
style=((style+1)%4);
if(!FreshGrid())return false;
}
//暂时的测试函数
else if(m_key_state[DIK_A] & 0x80)
{
if(!FreshGrid())return false;
CreateBrick();
}
return true;
}
bool CBricksGame::CleanGrid()
{
int i;
int j;
for(i=0;i<12;i++)
{
for(j=0;j<16;j++)
{
Grid[i][j]=0;
}
}
return true;
}
bool CBricksGame::DoLine()
{
if(!FreshGrid())return false;
int mark=1;
int i,j;
for(i=0;i<16;i++)
{
for(j=0;j<12;j++)
{
if(Grid[j][i]==0)
{
mark=0;
break;
}
}
if(mark==1)
{
int a,b;
for(a=i;a>0;a--)
{
for(b=0;b<12;b++)
{
Grid[b][a]=Grid[b][a-1];
}
}
}
mark=1;
}
for(i=0;i<12;i++)
{
for(j=0;j<16;j++)
{
MapGrid[i][j]=Grid[i][j];
}
}
return true;
}
bool CBricksGame::ProcDown()
{
int i,j;
int mark=0;
if(!CleanGrid())return false;
for(i=0;i<4;i++)
Grid[m_x][i+m_y+1]+=shape[shp][style][i];
for(i=4;i<8;i++)
Grid[m_x+1][i+m_y+1-4]+=shape[shp][style][i];
for(i=8;i<12;i++)
Grid[m_x+2][i+m_y+1-8]+=shape[shp][style][i];
for(i=12;i<16;i++)
Grid[m_x+3][i+m_y+1-12]+=shape[shp][style][i];
for(i=0;i<12;i++)
{
for(j=0;j<16;j++)
{
if((Grid[i][j]+MapGrid[i][j])==2||m_y+shape[shp][style][16]==16)
{
mark=1;//发生碰撞
break;
}
}
if(mark==1) break;
}
if(mark==1)
{
if(!FreshGrid())return false;
for(i=0;i<4;i++)
Grid[m_x][i+m_y]+=shape[shp][style][i];
for(i=4;i<8;i++)
Grid[m_x+1][i+m_y-4]+=shape[shp][style][i];
for(i=8;i<12;i++)
Grid[m_x+2][i+m_y-8]+=shape[shp][style][i];
for(i=12;i<16;i++)
Grid[m_x+3][i+m_y-12]+=shape[shp][style][i];
for(i=0;i<12;i++)
{
for(j=0;j<16;j++)
{
MapGrid[i][j]=Grid[i][j];
}
}
if(!DoLine())return false;
if(!CreateBrick())return false;
}
else if(mark==0&&m_y+shape[shp][style][16]<16)
{
m_y++;
if(!FreshGrid()) return false;
}
return true;
}
bool CBricksGame::DrawGrid()
{
int i;
int j;
RECT rect;
for(i=0;i<16;i++)
{
for(j=0;j<12;j++)
{
if(Grid[j][i]==1)
{
rect.right=(j+1)*m_blockwidth+m_stagex;
rect.left=j*m_blockwidth+m_stagex;
rect.top=i*m_blockwidth+m_stagey;
rect.bottom=(i+1)*m_blockwidth+m_stagey;
if(!DrawRectangle(&rect,m_blockclr))return false;
if(!DrawFrame(rect)) return false;
}
}
}
return true;
}
bool CBricksGame::DrawFrame(const RECT rect)
{
RECT frect;
bool br = false;
frect.left = rect.left;
frect.top = rect.top;
frect.right = rect.left + 1;
frect.bottom = rect.bottom;
if(!DrawRectangle(&frect,m_framelight))return false;
frect.left = rect.left;
frect.top = rect.top;
frect.right = rect.right;
frect.bottom = rect.top + 1;
if(!DrawRectangle(&frect,m_framelight))return false;
frect.left = rect.right - 1;
frect.top = rect.top;
frect.right = rect.right;
frect.bottom = rect.bottom;
if(!DrawRectangle(&frect,m_framedark))return false;
frect.left = rect.left + 1;
frect.top = rect.bottom - 1;
frect.right = rect.right;
frect.bottom = rect.bottom;
if(!DrawRectangle(&frect,m_framedark))return false;
return true;
}
bool CBricksGame::DrawBorder()
{
RECT leftborder;
RECT rightborder;
leftborder.left=m_stagex-20;
leftborder.right=m_stagex;
leftborder.top=m_stagey-20;
leftborder.bottom=600;
rightborder.left=m_stagex+240;
rightborder.right=m_stagex+260;
rightborder.top=m_stagey-20;
rightborder.bottom=600;
if(!DrawRectangle(&rightborder,m_framedark))return false;
if(!DrawRectangle(&leftborder,m_framedark))return false;
if(!DrawFrame(rightborder))return false;
if(!DrawFrame(leftborder))return false;
return true;
}
bool CBricksGame::DoBlocks(int height,int colum)
{
int i;
for(i=0;i<4;i++)
if(Grid[height][i+colum]==0) Grid[height][i+colum]+=shape[shp][style][i];
for(i=4;i<8;i++)
if(Grid[height+1][i+colum-4]==0) Grid[height+1][i+colum-4]+=shape[shp][style][i];
for(i=8;i<12;i++)
if(Grid[height+2][i+colum-8]==0)Grid[height+2][i+colum-8]+=shape[shp][style][i];
for(i=12;i<16;i++)
if(Grid[height+3][i+colum-12]==0)Grid[height+3][i+colum-12]+=shape[shp][style][i];
return true;
}
bool CBricksGame::GameInit()
{
int i,j;
for(i=0;i<12;i++)
{
for(j=0;j<16;j++)
{
Grid[i][j]=0;
MapGrid[i][j]=0;
}
Grid[i][16]=1;
MapGrid[i][16]=1;
}
m_x=2;
m_y=0;
m_blockwidth=20;
shp=0;
style=0;
m_framelight= RGBto16BitColor(255,255,255);
m_framedark= RGBto16BitColor(132,130,132);
m_background = RGBto16BitColor(0,0,0);
m_blockclr = RGBto16BitColor(0,10,250);
m_stagex=280;
m_stagey=260;
title="俄罗斯方块v0.01简陋版";
//字体
m_title_font = CreateFont
(
45,
0,
0,
0,
FW_HEAVY,
FALSE,
FALSE,
FALSE,
DEFAULT_CHARSET,
OUT_CHARACTER_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE,
"楷体"
);
m_main_font = CreateFont
(
24,
0,
0,
0,
FW_HEAVY,
FALSE,
FALSE,
FALSE,
DEFAULT_CHARSET,
OUT_CHARACTER_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE,
"MS Sans Serif"
);
return true;
}
bool CBricksGame::ProcTimer()
{
timer=(timer+1)%10;
if(timer==9)
if(!ProcDown())return false;
return true;
}
bool CBricksGame::DrawText()
{
StartGDIDrawing();
if(!DrawGDIText((LPTSTR)title.c_str(),0xff,0xff,0xff,m_title_font,10,10))return false;
if(!DrawGDIText("作者:Zéruncpp 方向键调整位置 空格键变相 ESC退出",0x99,0x99,0x99,m_main_font,70,70))return false;
EndGDIDrawing();
return true;
}
bool CBricksGame::GameProc()
{
if(!ProcKey())return false;
if(!FreshGrid()) return false;
if(!ProcTimer())return false;
if(!DoBlocks(m_x,m_y))return false;
if(!StartScene(m_background))return false;
if(!DrawText())return false;
if(!DrawBorder())return false;
if(!DrawGrid())return false;
if(!EndScene())return false;
return true;
}
寻开心
2006-02-13
打赏
举报
回复
另外一个单机全屏幕调试的技巧
http://www.source520.com/infoview/Article_22787.html
寻开心
2006-02-13
打赏
举报
回复
应该是你用的某些功能,客户的计算机不支持
建议你用远程debug来调试跟踪问题的所在
远程debug的方法在这里:
http://topic.csdn.net/t/20031205/15/2531779.html
answerear
2006-02-13
打赏
举报
回复
把源码贴出来看看
寻开心
2006-02-13
打赏
举报
回复
这样很难看出问题所在
自己debug出问题的所在,然后才提问解决问题吧
在窗口模式下,或者远程调试的情况下,把ddraw假死机的时候程序的定位点找到,然后才好分析
安装和配置 Windows Server 2022 远程访问服务
那么通过这一个课程的介绍,首先...网络策略服务的作用,并且完成网络策略服务器的安装和初始化配置 第七章:介绍
Di
rect
Access 的特点,并且完成
Di
rect
Access 不同组件的安装和配置,完成
Di
rect
Access 连接的配置
iOS 审核被拒绝
问题
汇总
iOS 审核被拒绝
问题
汇总 1. 5.1.1
问题
1. 1
问题
描述: Guideline 5.1.1 - Legal - Privacy - Data Collection and Storage We noticed that your app requests the user’s consent to access their photos but does not clarify t...
全面优化Windows2003
一、跳过磁盘检修等待时间 一旦计算机因意外原因,例如突然停电或者
死机
的话,那么计算机下次重新启动的话,系统就会花10秒钟左右的时间,来运行磁盘扫描
程序
,检查磁盘是否有错误 出现。要是你是一位惜时如金的人,肯定不会白白等待下去的。那就跟我一起来,跳过这段检查等待时间吧: 1、在开始菜单中,依次执行“
程序
”/“附件”/“命令提...
Windows 2003全面优化
一、跳过磁盘检修等待时间 一旦计算机因意外原因,例如突然停电或者
死机
的话,那么计算机下次重新启动的话,系统就会花10秒钟左右的时间,来运行磁盘扫描
程序
,检查磁盘是否有错误出现。要是你是一位惜时如金的人,肯定不会白白等待下去的。那就跟我一起来,跳过这段检查等待时间吧:1、在开始菜单中,依次执行“
程序
”/“附件”/“命令提示符”命令,将界面切换到DOS命令行状态下;2、直接输入“CHKNTFS/T ...
Win2003优化方法
一、跳过磁盘检修等待时间 一旦计算机因意外原因,例如突然停电或者
死机
的话,那么计算机下次重新启动的话,系统就会花10秒钟左右的时间,来运行磁盘扫描
程序
,检查磁盘是否有错误出现。要是你是一位惜时如金的人,肯定不会白白等待下去的。那就跟我一起来,跳过这段检查等待时间吧: 1、在开始菜单中,依次执行“
程序
”/“附件”/“命令提示符”命令,将界面切换到DOS命令行状态下; 2、直接输
游戏开发
8,303
社区成员
23,682
社区内容
发帖
与我相关
我的任务
游戏开发
游戏开发相关内容讨论专区
复制链接
扫一扫
分享
社区描述
游戏开发相关内容讨论专区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章