打砖块(未完成)

#include<iostream>
#include<cstdio>
#include<windows.h>
#include<conio.h>
using namespace std;
const int N=5,M=10;
char ma[N+5][M+5],ctl;
void hdcs()
{
	CONSOLE_CURSOR_INFO info={1,0};
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&info);
}
void print(int x,int y)
{
	COORD pos;
	pos.X=y;
	pos.Y=x;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
	putchar(ma[x][y]);
}
void setma(char c,int x,int y)
{
	ma[x][y]=c;
	print(x,y);
}
void mkmap()
{
	for(int i=0;i<=N+1;i++)
	{
		ma[i][M+1]=ma[i][0]='#';
		print(i,M+1),print(i,0);
	}
	for(int i=0;i<=M+1;i++)
	{
		ma[N+1][i]='#';
		print(N+1,i);
	}
}
class Wall
{
	int x,y;
	public:
	Wall()
	{
		x=N,y=M/2;
		ma[x][y]='_';
		print(x,y);
	}
	void set(int p)
	{
		if(ma[x][y+p]=='#') return;
		setma(' ',x,y);
		y+=p;
		setma('_',x,y);
	}
}wall;/**/
class Ball
{
	int x,y,dir;
	int d[4][2]={{-1,1},{-1,-1},{1,1},{1,-1}};
	public:
	Ball()
	{
		x=N-1,y=M/2;
		dir=1;
		setma('.',x,y);
	}
	void move()
	{
		int xx=x+d[dir][0],yy=y+d[dir][1];
		if(yy>M||yy<1) dir^=1;
		if(xx<0||xx>N) dir=(dir+2)%4;
		if(ma[xx][y]=='*') dir^=1,setma(' ',xx,y);
		if(ma[x][yy]=='*') dir=(2+dir)%4,setma(' ',x,yy);
		if(ma[xx][yy]=='*') dir^=1,setma(' ',xx,yy);
		setma(' ',x,y);
		x+=d[dir][0],y+=d[dir][1];
		setma('.',x,y);
	}
}ball;
int main()
{
	mkmap();
	hdcs();
	while(1)
	{
		ctl=getch();
		if(ctl=='a') wall.set(-1);
		if(ctl=='d') wall.set(1);
		/*Sleep(100);
		ball.move();*/
	}
	return 0;
} 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值