我如何将缩放合并到这个坐标系中
How can I incorporate zoom into this coordinate system?
我有一堆具有以下属性的对象:
xPos = x coordinate of position in world
yPos = y coordinate of position in world
size = size of object
我有一个函数将这些对象绘制到屏幕上。屏幕有x和y偏移量,因此用户可以平移,物体将根据需要在屏幕上下移动。这一切都很完美。现在我想添加放大和缩小的功能,但是我不知道如何对位置应用缩放。
render(int xOff, int yOff, int zoom){
int x = xPos + xOff;
int y = yPos + yOff;
s->addRenderJob(texID, x, y, size * zoom, size * zoom);
}
缩放对象的大小很简单,但我如何通过缩放来修改x和y位置,以便对象之间的距离也乘以缩放?
render(int xOff, int yOff, int zoom){
int x = xPos + xOff;
int y = yPos + yOff;
s->addRenderJob(texID, x* zoom, y* zoom, size * zoom, size * zoom);
}
如果需要,可以下载游戏引擎。研究如何处理游戏中的坐标系
halfX = SCREEN_WIDTH/2
halfY = SCREEN_HEIGHT/2
deltaX = xPos - halfX;
deltaY = yPos - halfY;
x = halfX + deltaX * zoom + xOff;
y = halfY + deltaY * zoom + yOff;
感谢VermillionAzure帮我解决了这个问题。
相关文章:
- 使用C++程序合并排序没有得到正确的输出
- 用于合并排序的合并函数
- 在声明中合并两个常量"std::set"(不是在运行时)
- 如何将一个数组值合并为一个整数c++
- 如何将不同的可执行文件合并到一个窗口框架中进行编码?像浏览器一样
- 将向量的 N 段合并到位C++
- 在C++中合并两个库
- 以迭代方式合并标准::unordered_map
- 无法合并生成操作.. 先决条件不同
- 合并排序不排序自创建数组类 c++
- 合并文本文件不同行中的重复项
- 找不到标识符合并
- 仅在大型阵列上出现合并排序分段错误
- C++ 合并字符串以'system'函数错误
- OpenGL 着色器坐标系
- 为什么在排序链表上的这种合并实现总是将两个列表都设置为 NULL,而只有一个应该设置一个列表?
- C++合并排序可视化工具
- 合并一组模板专用化
- 没有输出的合并排序我做错了什么?
- 我如何将缩放合并到这个坐标系中