opencv方向键响应

时间:2022-06-13 22:01:03
int mod = waitKey(100);
update = move_contrue(mod, position, step);

//原点左上,x向右 y下
bool move_contrue(int& mod, Point2i& position, int& step)
{
	if (mod == 2490368)//上
	{
		position.y -= step;
	}
	else if (mod == 2621440)//下
	{
		position.y += step;
	}
	else if (mod == 2424832)//左
	{
		position.x -= step;
	}
	else if (mod == 2555904)//右
	{
		position.x += step;
	}
	else
	{
		return false;
	}

	return true;
}