我罗斯方块汇报(1)
这个作业属于哪个课程 | 2020年面向对象程序设计 |
---|---|
作业要求 | 我罗斯方块汇报(1) |
作业目标 | 汇报自己这个阶段的开发进度。(完成了哪几个模块),讲述自己遇到的问题和尝试解决的方法和最后的结果(解决与否),制作一篇开发日记,例子如此,描述自己开发某一个模块的过程。 |
作业正文 | 如下 |
GitHub仓库 | 仓库地址 |
参考文献 | C实现俄罗斯方块 |
新手向C++俄罗斯方块教程 | |
设计者 | 031902124|谢翛然 |
031902114|林冠禧 | |
031902133|乐礼相 |
开发进度
完成了渲染类和方块类的初步设计,还未进行调试
开发日志
主要的问题
现在只是完成初步的设计,没有进行过单独的调试,函数调用的接口有可能存在不匹配或者无法调用的问题
方块的操作还存在不少问题,例如消除后如何刷新,方块的移动速度,方块的随机生成方向问题(可能直接刷新在头顶突然卡住)
关于刷新问题,什么时候刷新,时间的获得以及继续之类
Code部分
class Draw {
private:
int currentTime;
public:
Draw() {
for (int i = 0; i < 62; i++) {
cout << "*";
}
cout << endl;
for (int i = 0; i < 20; i++) {
cout << "**";
for (int j = 0; j < 28; j++) {
cout << " ";
}
cout << "**";
for (int j = 0; j < 28; j++) {
cout << " ";
}
cout << "**" << endl;
}
for (int i = 0; i < 62; i++) {
cout << "*";
}
cout << endl;
//获取并打印时间
currentTime = time.getTime;
goXY(70, 0); cout << "Time :" << currentTime;
};//绘制初始界面以及边框
void drawPlayer1();//绘制玩家1界面
{
goXY(3, 24);
cout << "Name: " << Plaer1.name << endl;
cout << "Score: " << Player1.score << endl;
}
void drawPlayer2()//绘制玩家2界面
{
goXY(30, 24);
cout << "Name: " << Plaer1.name << endl;
cout << "Score: " << Player1.score << endl;
}
void showTime()//展示游戏时间
{
currentTime = time.getTime;
goXY(70, 0); cout << "Time :" << currentTime;
}
};
int block00[4][4] = { { 10,0,0,0 },{ 1,1,1,1 },{ 0,0,0,0 },{ 0,0,0,0 } };
int block01[4][4] = { { 11,0,1,0 },{ 0,0,1,0 },{ 0,0,1,0 },{ 0,0,1,0 } };
int block02[4][4] = { { 12,0,0,0 },{ 0,0,0,0 },{ 1,1,1,0 },{ 0,1,0,0 } };
int block03[4][4] = { { 13,0,0,0 },{ 0,1,0,0 },{ 1,1,0,0 },{ 0,1,0,0 } };
int block04[4][4] = { { 14,0,0,0 },{ 0,0,0,0 },{ 0,1,0,0 },{ 1,1,1,0 } };
int block05[4][4] = { { 15,0,0,0 },{ 0,1,0,0 },{ 0,1,1,0 },{ 0,1,0,0 } };
int block06[4][4] = { { 16,0,0,0 },{ 0,0,0,0 },{ 1,1,1,0 },{ 1,0,0,0 } };
int block07[4][4] = { { 17,0,0,0 },{ 1,1,0,0 },{ 0,1,0,0 },{ 0,1,0,0 } };
int block08[4][4] = { { 18,0,0,0 },{ 0,0,0,0 },{ 0,0,1,0 },{ 1,1,1,0 } };
int block09[4][4] = { { 19,0,0,0 },{ 0,1,0,0 },{ 0,1,0,0 },{ 0,1,1,0 } };
int block10[4][4] = { { 20,0,0,0 },{ 0,0,0,0 },{ 1,1,1,0 },{ 0,0,1,0 } };
int block11[4][4] = { { 21,0,0,0 },{ 0,1,0,0 },{ 0,1,0,0 },{ 1,1,0,0 } };
int block12[4][4] = { { 22,0,0,0 },{ 0,0,0,0 },{ 1,0,0,0 },{ 1,1,1,0 } };
int block13[4][4] = { { 23,0,0,0 },{ 0,1,1,0 },{ 0,1,0,0 },{ 0,1,0,0 } };
int block14[4][4] = { { 24,0,0,0 },{ 0,0,0,0 },{ 0,1,1,0 },{ 1,1,0,0 } };
int block15[4][4] = { { 25,0,0,0 },{ 1,0,0,0 },{ 1,1,0,0 },{ 0,1,0,0 } };
int block16[4][4] = { { 26,0,0,0 },{ 0,0,0,0 },{ 1,1,0,0 },{ 0,1,1,0 } };
int block17[4][4] = { { 27,0,0,0 },{ 0,0,1,0 },{ 0,1,1,0 },{ 0,1,0,0 } };
int block18[4][4] = { { 28,0,0,0 },{ 0,0,0,0 },{ 1,1,0,0 },{ 1,1,0,0 } };//¶¨Òå19ÖÖ·½¿é
class Block {
private:
int x, y;
int color;
int kind;
int direction;
public:
void roundBlock(HANDLE hOut, int block[4][4])
{
clearBlock(hOut, block, 5, 15);
switch (rand() % 19)//¸ù¾ÝËæ»úÊýÀ´Éú³É·½¿é
{
case 0:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block00[i][j];
}
}
break;
case 1:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block01[i][j];
}
}
break;
case 2:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block02[i][j];
}
}
break;
case 3:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block03[i][j];
}
}
break;
case 4:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block04[i][j];
}
}
break;
case 5:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block05[i][j];
}
}
break;
case 6:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block06[i][j];
}
}
break;
case 7:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block07[i][j];
}
}
break;
case 8:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block08[i][j];
}
}
break;
case 9:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block09[i][j];
}
}
break;
case 10:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block10[i][j];
}
}
break;
case 11:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block11[i][j];
}
}
break;
case 12:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block12[i][j];
}
}
break;
case 13:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block13[i][j];
}
}
break;
case 14:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block14[i][j];
}
}
break;
case 15:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block15[i][j];
}
}
break;
case 16:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block16[i][j];
}
}
break;
case 17:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block17[i][j];
}
}
break;
case 18:
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
block[i][j] = block18[i][j];
}
}
break;
default:
break;
}
printBlock(hOut, block, 5, 15);//´òÓ¡·½¿é
}
int getX()//·µ»Øx×ø±ê
{return x;}
int getY()//·µ»Øy×ø±ê
{return y;}
int getKind();//·µ»Øש¿éÖÖÀà
int changeDirection();//¸Ä±äש¿é³¯Ïò
int setXY(int x, int y);//¸Ä±ä·½¿é×ø±ê
};