【发布时间】:2015-10-02 00:49:01
【问题描述】:
我一直在使用 Dgame 框架进行简单的模拟。
我需要移动物体与它们的速度矢量对齐。
如何使用 Dgame 做到这一点?
我看到 shape 对象有 setRotation 和 setRotationCenter。不知道如何使用这些来达到效果。我意识到默认值是围绕原点旋转。这会导致对象随时间漂移。
示例代码
struct GameObject {
Point **position;
// array of pointers to object points
Point *acceleration;
Point *velocity;
double max_speed;
double max_force;
}
shape = new Shape(Geometry.Quads,
Vertex(object.position[0].x, object.position[0].y),
Vertex(object.position[1].x, object.position[1].y),
Vertex(object.position[2].x, object.position[2].y),
Vertex(object.position[3].x, object.position[3].y))
// rotate shape to face velocity here
shape.move(object.velocity.x, object.velocity.y);
【问题讨论】:
-
这是你想做的吗? i.webfreak.org/DE8632
-
@WebFreak001 这就是我想要做的
-
我猜只是旋转而没有位置?
-
@WebFreak001 是的,只是旋转
标签: graphics 2d coordinates d 2d-games