在WIN32控制台下画出棋盘(字符输出)

作者:Wupei  |  发表时间:  |  所属分类:C++

最初在使用C++编小游戏时,写出的界面的很难看,于是找到了个理想化的办法,就是输出特殊字符,而达到表格的效果

效果如下面两个图:


中国象棋win32控制台版输出演示
黑白棋WIN32控制台版输出演示
代码如下:

#include <iostream>
using namespace std;

int main()
{

	cout << "   ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐" << endl;
	cout << "   │□│⒈│⒉│⒊│⒋│⒌│⒍│⒎│⒏│⒐│" << endl;
	cout << "   ├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤" << endl;
	cout << "   │⒈│車│馬│相│仕│將│仕│相│馬│車│" << endl;
	cout << "   ├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤" << endl;
	cout << "   │⒉│ │ │ │ │ │ │ │ │ │" << endl;
	cout << "   ├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤" << endl;
	cout << "   │⒊│ │砲│ │ │ │ │ │砲│ │" << endl;
	cout << "   ├─┼─┼─┼┈┼─┼─┼─┼─┼─┼─┤" << endl;
	cout << "   │⒋│卒│ ┊卒┊ │卒│ │卒│ │卒│" << endl;
	cout << "   ├─┼─┼─┼┈┼─┼─┼─┼─┼─┼─┤" << endl;
	cout << "   │⒌│ │ │ │ │ │ │ │ │ │" << endl;
	cout << "   ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤" << endl;
	cout << "   │                   │" << endl;
	cout << "   │                   │" << endl;
	cout << "   │                   │" << endl;
	cout << "   ├─┬─┬─┬─┬─┬─┬─┬─┬─┬─┤" << endl;
	cout << "   │⒍│ │ │ │ │ │ │ │ │ │" << endl;
	cout << "   ├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤" << endl;
	cout << "   │⒎│兵│ │兵│ │兵│ │兵│ │兵│" << endl;
	cout << "   ├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤" << endl;
	cout << "   │⒏│ │炮│ │ │ │ │ │炮│ │" << endl;
	cout << "   ├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤" << endl;
	cout << "   │⒐│ │ │ │ │ │ │ │ │ │" << endl;
	cout << "   ├─┼─┼─┼─┼─┼─┼─┼─┼─┼─┤" << endl;
	cout << "   │⒑│车│马│象│士│将│士│象│马│车│" << endl;
	cout << "   └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘" << endl;

	return 0;
}

同理可实现其他方格效果的输出

Trackback from your site.

请在这里留言: