stuff yo
parent
e289f1a5ff
commit
70b234f156
|
|
@ -65,10 +65,12 @@ public class Engine extends Canvas {
|
||||||
bs = getBufferStrategy();
|
bs = getBufferStrategy();
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
updateScene();
|
updateScene();
|
||||||
repaint();
|
repaint();
|
||||||
|
int elapsed = (int)(System.currentTimeMillis() - startTime);
|
||||||
try{
|
try{
|
||||||
Thread.sleep(17);
|
Thread.sleep(16 - elapsed);
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,15 @@ package diveengine2d;
|
||||||
|
|
||||||
public class RigidBody extends DiveScript{
|
public class RigidBody extends DiveScript{
|
||||||
|
|
||||||
|
public float dx, dy, drot;
|
||||||
|
public float friction = 0.99f;
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
entity.x += dx;
|
||||||
|
entity.y += dy;
|
||||||
|
entity.rotation += drot;
|
||||||
|
dx *= .3;
|
||||||
|
dy *= .3;
|
||||||
|
drot *= .3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue