2016-02-16 03:42:12 -05:00
|
|
|
package diveengine2d;
|
|
|
|
|
|
|
|
|
|
public class RigidBody extends DiveScript{
|
|
|
|
|
|
2016-02-23 08:02:06 -05:00
|
|
|
public double dx, dy, drot;
|
|
|
|
|
public double friction;
|
2016-02-16 04:04:05 -05:00
|
|
|
|
2016-02-16 03:42:12 -05:00
|
|
|
public void update() {
|
2016-02-23 08:02:06 -05:00
|
|
|
entity.x += dx * Time.deltaTime;
|
|
|
|
|
entity.y += dy * Time.deltaTime;
|
|
|
|
|
entity.rotation += drot * Time.deltaTime;
|
|
|
|
|
double friction = 1 - ((1 - this.friction) * Time.deltaTime);
|
2016-02-16 04:48:35 -05:00
|
|
|
dx *= friction;
|
|
|
|
|
dy *= friction;
|
|
|
|
|
drot *= friction;
|
2016-02-16 03:42:12 -05:00
|
|
|
}
|
|
|
|
|
}
|