📄 box.cpp
字号:
#include <iostream.h>
#include <time.h>
#include "Box.h"
Box::Box()
{
init();
}
void Box::init(void)
{
location.y = 0;
location.x = (COLUMNS-4)/2;
srand((unsigned) time(NULL));
boxNo = rand()%7;
shapeNo = rand()%4;
}
void Box::left(void)
{
location.x--;
}
void Box::right(void)
{
location.x++;
}
void Box::drop(void)
{
location.y++;
}
void Box::rotate(void)
{
shapeNo =(shapeNo+1)%4;
}
BoxCode Box::getCode(void)const
{
return codeTable[boxNo][shapeNo];
}
Coord Box::getLocation(void)const
{
return location;
}
int Box::getBoxNo(void)const
{
return boxNo;
}
void Box::show()
{
cout<<"方块号:"<<boxNo<<endl;
cout<<"形态号:"<<shapeNo<<endl;
cout<<"位置:"<<location.y<<","<<location.x<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -