C++实现俄罗斯方块

该博客介绍了如何用C++编程实现经典游戏俄罗斯方块,包括基础的方块类定义、旋转、移动以及游戏主循环等关键功能。示例中展示了如何创建不同形状的方块、游戏墙视图以及游戏工作者类,用于控制游戏流程。
摘要由CSDN通过智能技术生成

#include
#include
#include<Windows.h>
#include<conio.h>
using namespace std;
class Point // Gride
{
private:
int row; // x;
int col; // y;
public:
Point(int r = 0, int c = 0) :row®, col© {}
~Point() = default;
Point(const Point&) = default;
Point& operator=(const Point&) = default;

int& Row() { return row; }
const int& Row() const { return row; }

int& Col() { return col; }
const int& Col() const { return col; }

};

class Brich // M
{
public:
static const int BrichTypeNum = 7;
static const int ColorNum = 7;
static const int GrideNum = 4;
static const int RotateNum = 4;
public:
enum ColorType
{
EMPTY = 0, RED = 1, YELLOW = 2, BLUS = 3,
//’ ’ ‘A’ ‘B’ ‘C’
GREEN = 4, PURPLE = 5, ORANGE = 6, GRAY = 7, BLACK = 8
// ‘D’ ‘E’ ‘F’ ‘G’ ‘#’
};
enum RotateState
{
INITIAL = 0, RR_ONE = 1, RR_TWO = 2, RR_THREE = 3
};

protected:
vector gride; // Brich
ColorType color;
RotateState state;
public:
Brich(const ColorType& c) : color©, state(RotateState::INITIAL)
{
gride.resize(4);
}
Brich(const Brich&) = default;
Brich& operator=(const Brich&) = default; // delete
virtual ~Brich() = default;

vector<Point>& Gride() { return gride; }
const vector<Point>& Gride()const { return gride; }

ColorType& Color() { return color; }
const ColorType& Color() const { return color; }

RotateState& State() { return state; }
const RotateState& Stat
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值