Hey Everyone,
Im just playing around with Java and Slick2D and try to create a small Physics simulation.
At the moment I just want have a simple ball falling from the top of the screen to the bottom.
I want the ball to have some kind of rebound from the ground but I have no idea how I could accomplish that.
for the moment my Shape update and fall physics look like this (Which is a Cube at the moment).
private Rectangle shape;
private float x;
private float y;
private float friction;
private float velocity;
private float acceleration;
public Cube(int length) {
this.length = length;
this.x = 0;
this.y = 0;
this.friction = 0.8f;
this.velocity = 0.0f;
this.acceleration = 0.5f;
this.shape = new Rectangle(this.x, this.y, this.length, this.length);
}
public void setY(float y) {
this.y = y;
this.shape.setY(this.y);
}
public void update(GameContainer gc, int delta) {
if (this.shape.getMaxY() < gc.getHeight()) {
this.velocity += this.acceleration * this.friction;
this.setY(this.y + this.velocity);
} else {
this.velocity = 0.0f;
this.setY(gc.getHeight() - this.length);
}
}
I could not find any good tutorials about physics on google so im trying to find some advices or hints here
Best Regards






