Permalink
Browse files

Do some other shit, predictive nonsense on collider

  • Loading branch information...
jthra037 committed Nov 30, 2017
1 parent 62aef2b commit 7a14f44d416f85b1a13a6f11ec42b9e9a9200a03
@@ -1,5 +1,7 @@
package alpha.nosleep.game.framework;
import alpha.nosleep.neonrush.Ball;
import static alpha.nosleep.game.framework.Collider.ColliderFormat.circle;
/**
@@ -9,13 +11,15 @@
public class CircleCollider extends Collider {
private int radius = 5;
private ITuple offset = new ITuple(0,0);
private Object object;
//public final ColliderFormat format = circle;
public CircleCollider(int radius)
public CircleCollider(int radius, Object object)
{
this.radius = radius;
format = circle;
this.object = object;
}
public CircleCollider(int radius, ITuple offset)
@@ -92,10 +96,12 @@ private boolean circleCircleCollision(Object other, CircleCollider otherCollider
private boolean rectCircleCollision(Object other, BoxCollider otherCollider, ITuple pos)
{
float left = other.getPosition().x - radius;
float right = other.getPosition().x + otherCollider.getSize().x + radius;
float top = other.getPosition().y - radius;
float bottom = other.getPosition().y + otherCollider.getSize().y + radius;
Ball thisBall = (Ball) object;
float left = other.getPosition().x - radius - thisBall.getVelocity().x;
float right = other.getPosition().x + otherCollider.getSize().x + radius + thisBall.getVelocity().x;
float top = other.getPosition().y - radius - thisBall.getVelocity().y;
float bottom = other.getPosition().y + otherCollider.getSize().y + radius + thisBall.getVelocity().y;
return left <= pos.x &&
pos.x <= right&&
@@ -29,7 +29,7 @@ public Ball(World world, int radius)
this.world = world;
localCoord = new ITuple(world.g.getWidth() / 2, world.g.getHeight() / 2);
collider = new CircleCollider(radius);
collider = new CircleCollider(radius, this);
world.register(this);
}
@@ -69,10 +69,11 @@ public void move(float deltaTime)
}
else
{
dx = Fn * (accel.y) * speedScalar;
/*dx = Fn * (accel.y) * speedScalar;
dy = Fn * (accel.x) * speedScalar;
setVelocity(new FTuple(dx, dy));
setVelocity(new FTuple(dx, dy));*/
velocity = lastvelocity;
notColliding = true;
}

0 comments on commit 7a14f44

Please sign in to comment.