c++ - 我如何将缩放合并到这个坐标系中?

标签 c++ math game-engine

我有一堆具有以下属性的对象:

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); }

如有需要,您可以下载游戏引擎。 研究如何处理游戏中的坐标系。

关于c++ - 我如何将缩放合并到这个坐标系中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31307561/

相关文章:

c++ - 为什么 push_back 进入 vector<vector<int>> 导致段错误?

c++ - 检查 CUDA 内核中的 device_vector 不起作用

algorithm - Eratosthenes 概率筛法

c++ - SOIL2 文件上未解析的外部符号 - 需要 opengl 调用

javascript - 如何从TexturePacker生成的JSON读取 trim Sprite 的中心?

c++ - 来自 cudaMemcpy2D 的错误数据

c++ - 获取 emacs 的访问标签缩进以添加缩进级别

algorithm - 确定浮点平方根

javascript - 二维无限循环元素数组

c++ - 实体组件系统 - 渲染方法