C++ 编写中国象棋 棋子图片格式调用的问题
C++编写中国象棋游戏。调用绘图函数Ellipse()和TextOut()绘制棋子。但是在英文VS2008上因为语言的关系无法显示!如何把棋子更改为调用图片?请指教voi...
C++ 编写中国象棋游戏 。
调用绘图函数Ellipse()和TextOut()绘制棋子。
但是在英文VS2008上因为语言的关系无法显示! 如何把棋子更改为调用图片?请指教
void Graphics(int x,int y,int RorB,LPCTSTR ChessmanName)
{
HFONT hf_Red;//Schrift
hf_Red=CreateFont(32,0,0,0,FW_HEAVY,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"红体");
HPEN hPen; //Pensil
hPen=CreatePen(PS_SOLID,2,RGB(30,30,30));
SelectObject(hdc,hPen);
SetBkColor(hdc,RGB(255,255,255));
if(RorB==1)
{
SetTextColor(hdc,RGB(255,0,0));
}
else
{
SetTextColor(hdc,RGB(0,0,0));
}
// PAINTSTRUCT ps;
// hdc=BeginPaint(hWnd, &ps);
Ellipse(hdc,xArray[x][y]-23,yArray[x][y]-23,xArray[x][y]+23,yArray[x][y]+23);
SelectObject(hdc,hf_Red);
TextOut(hdc,xArray[x][y]-14,yArray[x][y]-16,ChessmanName,strlen(ChessmanName));
// EndPaint(hWnd, &ps);
}
void DynamicChessman(int x,int y)
{
int RorB; //Schrift Farbe
int FontSize=30,EllipseSize=23; //FontSize Schrift Groesse,EllipseSize Spielstein Groesse
if(InfoArray[x][y]<10)
RorB=1;
else
RorB=0;
HFONT hf_Red;//schrift
hf_Red=CreateFont(32,0,0,0,FW_HEAVY,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"红体");
HPEN hPen; //malen
hPen=CreatePen(PS_SOLID,2,RGB(30,30,30)); //pinsel
SelectObject(hdc,hPen);
LPCTSTR ChessmanName;
switch(InfoArray[x][y])
{
//malen Rot Spielstein
case 7:
ChessmanName=“兵”
break;
;
case 6:
ChessmanName="炮";
break;
;
case 5:
ChessmanName="帅";
break;
;
case 4:
ChessmanName="仕";
break;
;
case 3:
ChessmanName="相";
break;
;
case 2:
ChessmanName="马";
break;
;
case 1:
ChessmanName="车";
break;
;
//malen SchwarzSpielstein
case 17:
ChessmanName="卒";
break;
;
case 16:
ChessmanName="炮";
break;
;
case 15:
ChessmanName="将";
break;
;
case 14:
ChessmanName="士";
break;
;
case 13:
ChessmanName="象";
break;
;
case 12:
ChessmanName="马";
break;
;
case 11:
ChessmanName="车";
break;
;
default:
break;
}
if(RorB==1)
{
SetTextColor(hdc,RGB(255,0,0));
}
else
{
SetTextColor(hdc,RGB(0,0,0));
}
for(;EllipseSize<=28;EllipseSize++,FontSize+=2)
{
Ellipse(hdc,xArray[x][y]-EllipseSize,yArray[x][y]-EllipseSize,xArray[x][y]+EllipseSize,yArray[x][y]+EllipseSize);
hf_Red=CreateFont(FontSize,0,0,0,FW_HEAVY,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"红体");
SelectObject(hdc,hf_Red);
TextOut(hdc,xArray[x][y]-EllipseSize+10,yArray[x][y]-EllipseSize+8,ChessmanName,strlen(ChessmanName));
Sleep(1000);
}
}
LoadBitmap(hInst,(LPCTSTR)IDB_RED_JU)
我尝试调用 我对双缓冲不是很理解 展开
调用绘图函数Ellipse()和TextOut()绘制棋子。
但是在英文VS2008上因为语言的关系无法显示! 如何把棋子更改为调用图片?请指教
void Graphics(int x,int y,int RorB,LPCTSTR ChessmanName)
{
HFONT hf_Red;//Schrift
hf_Red=CreateFont(32,0,0,0,FW_HEAVY,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"红体");
HPEN hPen; //Pensil
hPen=CreatePen(PS_SOLID,2,RGB(30,30,30));
SelectObject(hdc,hPen);
SetBkColor(hdc,RGB(255,255,255));
if(RorB==1)
{
SetTextColor(hdc,RGB(255,0,0));
}
else
{
SetTextColor(hdc,RGB(0,0,0));
}
// PAINTSTRUCT ps;
// hdc=BeginPaint(hWnd, &ps);
Ellipse(hdc,xArray[x][y]-23,yArray[x][y]-23,xArray[x][y]+23,yArray[x][y]+23);
SelectObject(hdc,hf_Red);
TextOut(hdc,xArray[x][y]-14,yArray[x][y]-16,ChessmanName,strlen(ChessmanName));
// EndPaint(hWnd, &ps);
}
void DynamicChessman(int x,int y)
{
int RorB; //Schrift Farbe
int FontSize=30,EllipseSize=23; //FontSize Schrift Groesse,EllipseSize Spielstein Groesse
if(InfoArray[x][y]<10)
RorB=1;
else
RorB=0;
HFONT hf_Red;//schrift
hf_Red=CreateFont(32,0,0,0,FW_HEAVY,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"红体");
HPEN hPen; //malen
hPen=CreatePen(PS_SOLID,2,RGB(30,30,30)); //pinsel
SelectObject(hdc,hPen);
LPCTSTR ChessmanName;
switch(InfoArray[x][y])
{
//malen Rot Spielstein
case 7:
ChessmanName=“兵”
break;
;
case 6:
ChessmanName="炮";
break;
;
case 5:
ChessmanName="帅";
break;
;
case 4:
ChessmanName="仕";
break;
;
case 3:
ChessmanName="相";
break;
;
case 2:
ChessmanName="马";
break;
;
case 1:
ChessmanName="车";
break;
;
//malen SchwarzSpielstein
case 17:
ChessmanName="卒";
break;
;
case 16:
ChessmanName="炮";
break;
;
case 15:
ChessmanName="将";
break;
;
case 14:
ChessmanName="士";
break;
;
case 13:
ChessmanName="象";
break;
;
case 12:
ChessmanName="马";
break;
;
case 11:
ChessmanName="车";
break;
;
default:
break;
}
if(RorB==1)
{
SetTextColor(hdc,RGB(255,0,0));
}
else
{
SetTextColor(hdc,RGB(0,0,0));
}
for(;EllipseSize<=28;EllipseSize++,FontSize+=2)
{
Ellipse(hdc,xArray[x][y]-EllipseSize,yArray[x][y]-EllipseSize,xArray[x][y]+EllipseSize,yArray[x][y]+EllipseSize);
hf_Red=CreateFont(FontSize,0,0,0,FW_HEAVY,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"红体");
SelectObject(hdc,hf_Red);
TextOut(hdc,xArray[x][y]-EllipseSize+10,yArray[x][y]-EllipseSize+8,ChessmanName,strlen(ChessmanName));
Sleep(1000);
}
}
LoadBitmap(hInst,(LPCTSTR)IDB_RED_JU)
我尝试调用 我对双缓冲不是很理解 展开
展开全部
根据位置贴上响应的位图就可以了。最好是用双缓冲. 参考MSDN bitblt函数。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询