⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cube.cpp

📁 简单的windows api编程实现的俄罗斯方块 希望对初学visual c的您有帮助 高手就不用看了
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			if (test == true){
				
				pointPt->x += 2;
				pointPt = pointPt->next;
				pointPt->x += 1;
				pointPt->y += 1;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x--;
				pointPt->y++;

				direction = 1;
			}
			
		}
		else{
			test = true;
			pointPt = head;
			if (status[pointPt->y][pointPt->x - 2] == 1){
				test = false;
			}
			else if (status[pointPt->y][pointPt->x - 1] == 1){
				test = false;
			}

			if (test == true){
				
				pointPt->x -= 2;
				pointPt = pointPt->next;
				pointPt->x --;
				pointPt->y --;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x ++;
				pointPt->y --;

				direction = 0;

			}
			
		}
		break;

	case 3:
		if (direction == 0){
			test = true;
			pointPt = head;
			if (status[pointPt->y][pointPt->x - 2]){
				test = false;
			}
			else if(status[pointPt->y + 2][pointPt->x - 1]){
				test = false;
			}

			if (test == true){
				pointPt->x -= 2;
				pointPt = pointPt->next;
				pointPt->x --;
				pointPt->y ++;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x ++;
				pointPt->y ++;

				direction = 1;
			}


		}
		else{
			test = true;
			pointPt = head;
			if (status[pointPt->y][pointPt->x + 2] == 1){
				test = false;
			}
			else if(status[pointPt->y + 2][pointPt->x + 1]){
				test = false;
			}

			if (test == true){
				pointPt->x += 2;
				pointPt = pointPt->next;
				pointPt->x ++;
				pointPt->y --;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x --;
				pointPt->y --;

				direction = 0;
			}
		}
		break;

	case 4:
		if (direction == 0){
			pointPt = head;
			test = true;
			if (status[pointPt->y+1][pointPt->x+1]==1 || status[pointPt->y-1][pointPt->x+1]==1 || status[pointPt->y-1][pointPt->x+2]==1){
				test = false;
			}
			if (test == true){
				pointPt->x ++;
				pointPt->y ++;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x --;
				pointPt->y --;
				pointPt = pointPt->next;
				pointPt->y -=2;

				direction = 1;
			}
		}
		else if(direction == 1){
			pointPt = head;
			test = true;
			if (status[pointPt->y-2][pointPt->x-1]==1 || status[pointPt->y-1][pointPt->x-1]==1 || status[pointPt->y-1][pointPt->x+1]==1){
				test = false;
			}
			if (test == true){
				pointPt->x++;
				pointPt->y--;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x--;
				pointPt->y++;
				pointPt = pointPt->next;
				pointPt->x -= 2;
				
				direction = 2;
			}
		}
		else if (direction == 2){
			pointPt = head;
			test = true;
			if (status[pointPt->y-1][pointPt->x-1]==1 || status[pointPt->y+1][pointPt->x-1]==1 || status[pointPt->y+1][pointPt->x-2]==1){
				test = false;
			}
			if (test == true){
				pointPt->x--;
				pointPt->y--;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x++;
				pointPt->y++;
				pointPt = pointPt->next;
				pointPt->y+=2;

				direction = 3;
			}
		}
		else{
			pointPt = head;
			test = true;
			if (status[pointPt->y+1][pointPt->x-1]==1 || status[pointPt->y+1][pointPt->x+1]==1 || status[pointPt->y+2][pointPt->x+1]){
				test = false;
			}

			if (test == true){
				pointPt->x--;
				pointPt->y++;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x++;
				pointPt->y--;
				pointPt = pointPt->next;
				pointPt->x +=2;

				direction = 0;
			}
		}

		break;
		
	case 5:
		if (direction == 0){
			pointPt = head;
			test = true;
			if (status[pointPt->y-1][pointPt->x-1]==1 || status[pointPt->y+1][pointPt->x-1]==1 || status[pointPt->y+1][pointPt->x]){
				test = false;
			}

			if (test == true){
				pointPt->x--;
				pointPt->y--;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x++;
				pointPt->y++;
				pointPt = pointPt->next;
				pointPt->x += 2;

				direction = 1;
			}
		}
		else if (direction == 1){
			pointPt = head;
			test = true;
			if (status[pointPt->y+1][pointPt->x-1]==1 || status[pointPt->y+1][pointPt->x+1]==1 || status[pointPt->y][pointPt->x+1]==1){
				test = false;
			}
			if (test == true){
				pointPt->x--;
				pointPt->y++;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x++;
				pointPt->y--;
				pointPt = pointPt->next;
				pointPt->y -= 2;

				direction = 2;
			}
		}
		else if (direction == 2){
			pointPt = head;
			test = true;
			if (status[pointPt->y-1][pointPt->x]==1 || status[pointPt->y-1][pointPt->x+1]==1 || status[pointPt->y+1][pointPt->x+1]==1){
				test = false;
			}

			if (test == true){
				pointPt->x++;
				pointPt->y++;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x--;
				pointPt->y--;
				pointPt = pointPt->next;
				pointPt->x -= 2;

				direction = 3;
			}
		}
		else{
			pointPt = head;
			test = true;
			if (status[pointPt->y-1][pointPt->x-1]==1 || status[pointPt->y-1][pointPt->x+1]==1 || status[pointPt->y][pointPt->x-1]){
				test = false;
			}

			if (test == true){
				pointPt->x++;
				pointPt->y--;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x--;
				pointPt->y++;
				pointPt = pointPt->next;
				pointPt->y += 2;

				direction = 0;
			}
		}
		break;

	case 6:
		if (direction == 0)
		{
			pointPt = head;
			test = true;
			if (status[pointPt->y-1][pointPt->x+1]==1){
				test = false;
			}

			if (test == true){
				pointPt->x++;
				pointPt->y++;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x--;
				pointPt->y--;
				pointPt = pointPt->next;
				pointPt->x++;
				pointPt->y--;

				direction = 1;
			}
		}
		else if (direction == 1){
			pointPt = head;
			test = true;
			if (status[pointPt->y-1][pointPt->x-1]==1){
				test = false;
			}

			if (test == true){
				pointPt->x++;
				pointPt->y--;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x--;
				pointPt->y++;
				pointPt = pointPt->next;
				pointPt->x--;
				pointPt->y--;

				direction = 2;
			}
		}
		else if (direction == 2){
			pointPt = head;
			test = true;
			if (status[pointPt->y+1][pointPt->x-1]){
				test = false;
			}

			if (test == true){
				pointPt->x--;
				pointPt->y--;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x++;
				pointPt->y++;
				pointPt = pointPt->next;
				pointPt->x--;
				pointPt->y++;

				direction = 3;
			}
		}
		else{
			pointPt = head;
			test = true;
			if (status[pointPt->y+1][pointPt->x+1]){
				test == false;
			}

			if (test == true){
				pointPt->x--;
				pointPt->y++;
				pointPt = pointPt->next;
				pointPt = pointPt->next;
				pointPt->x++;
				pointPt->y--;
				pointPt = pointPt->next;
				pointPt->x++;
				pointPt->y++;

				direction = 0;
			}
		}
		break;

	}

}

//---------------------------------------------------------------------------------
cube::~cube()
{
	point *pointPt1, *pointPt2;

	for (pointPt1 = head; pointPt1 != NULL ;)
	{
		pointPt2 = pointPt1;
		pointPt1 = pointPt1->next;
		free(pointPt2);
	}
	head = NULL;

	for (pointPt1 = nextHead; pointPt1 != NULL ;)
	{
		pointPt2 = pointPt1;
		pointPt1 = pointPt1->next;
		free(pointPt2);
	}
	nextHead = NULL;
}
//---------------------------------------------------------------------------------
point* cube::getHead()
{
	return head;
}
//---------------------------------------------------------------------------------
point* cube::getNextHead()
{
	return nextHead;
}
//---------------------------------------------------------------------------------

cube::cube(cube &Cube)
{
	point *pointPt1, *pointPt2, *pointPt3;

	shape = Cube.shape;
	nextshape = Cube.nextshape;
	direction = Cube.direction;

	pointPt3 = Cube.head;

	pointPt1 = (point*)malloc(sizeof(point));
	pointPt1->x = pointPt3->x;
	pointPt1->y = pointPt3->y;
	pointPt2 = pointPt1;
	head = pointPt2;

	pointPt3 = pointPt3->next;
	pointPt1 = (point*)malloc(sizeof(point));
	pointPt1->x = pointPt3->x;
	pointPt1->y = pointPt3->y;
	pointPt1->next = NULL;
	pointPt2->next = pointPt1;
	pointPt2 = pointPt1;

	pointPt3 = pointPt3->next;
	pointPt1 = (point*)malloc(sizeof(point));
	pointPt1->x = pointPt3->x;
	pointPt1->y = pointPt3->y;
	pointPt1->next = NULL;
	pointPt2->next = pointPt1;
	pointPt2 = pointPt1;

	pointPt3 = pointPt3->next;
	pointPt1 = (point*)malloc(sizeof(point));
	pointPt1->x = pointPt3->x;
	pointPt1->y = pointPt3->y;
	pointPt1->next = NULL;
	pointPt2->next = pointPt1;
	pointPt2 = pointPt1;



	pointPt3 = Cube.nextHead;

	pointPt1 = (point*)malloc(sizeof(point));
	pointPt1->x = pointPt3->x;
	pointPt1->y = pointPt3->y;
	pointPt2 = pointPt1;
	nextHead = pointPt2;

	pointPt3 = pointPt3->next;
	pointPt1 = (point*)malloc(sizeof(point));
	pointPt1->x = pointPt3->x;
	pointPt1->y = pointPt3->y;
	pointPt1->next = NULL;
	pointPt2->next = pointPt1;
	pointPt2 = pointPt1;

	pointPt3 = pointPt3->next;
	pointPt1 = (point*)malloc(sizeof(point));
	pointPt1->x = pointPt3->x;
	pointPt1->y = pointPt3->y;
	pointPt1->next = NULL;
	pointPt2->next = pointPt1;
	pointPt2 = pointPt1;

	pointPt3 = pointPt3->next;
	pointPt1 = (point*)malloc(sizeof(point));
	pointPt1->x = pointPt3->x;
	pointPt1->y = pointPt3->y;
	pointPt1->next = NULL;
	pointPt2->next = pointPt1;
	pointPt2 = pointPt1;

}

cube::cube()
{ }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -