Hi,
does anyone know how to recreate the bouncy ball effect in this game (Tangerines):
http://www.kontraband.com/show/show...rating=nsfw_sfw
The most I can do at the moment is Pong-like rebounds off the wall…
Kind regards,
Hendrick
Hi,
does anyone know how to recreate the bouncy ball effect in this game (Tangerines):
http://www.kontraband.com/show/show...rating=nsfw_sfw
The most I can do at the moment is Pong-like rebounds off the wall…
Kind regards,
Hendrick
I think something like
// Ball.java
class Ball
{
public static final double GRAVITY = 6.0;
public double x, y; // position vector
public double vx, vy; // velocity vector
public Ball(double x, double y, double vx, double vy)
{
this.x = x;
this.y = y;
this.vx = vx;
this.vy = vy;
}
public move(double seconds)
{
x += seconds*vx;
y += seconds*vy;
if (somehow_collide_with_something)
{
x = collision_point_x; // that would be the same as x for floors
y = collision_point_y; // that would be the floor's height for floors
vx = reflection_of_vx_on_surface; // that would be the same as vx for floors
vy = reflection_of_vy_on_surface; // that would be -vy on floors
}
vy += seconds*GRAVITY;
}
}
or something like that (i would begin with something like the above and move forward modifying that).