29 lines
792 B
Java
29 lines
792 B
Java
/**
|
|
* TODO: Item wird gedropt und fliegt kurz weiter, verlangsamt aber.
|
|
* Wenn der Spieler sich nähert gleitet das Item mit wachsender
|
|
* Geschwindigkeit auf den Spieler zu, wird quasi "angezogen"
|
|
* @author vanitas,
|
|
*
|
|
*/
|
|
public class Item extends MovingObject
|
|
{
|
|
private float friction = 0.95f;
|
|
|
|
public Item()
|
|
{
|
|
this.setShape(new Shape(Shape.S_ITEM));
|
|
}
|
|
|
|
/**
|
|
* This doesn't accelerate the Item, but it slows it down till it stops.
|
|
*/
|
|
@Override
|
|
public void accelerate() //This Method is overwritten to let the Item
|
|
{ //glide with decreasing speed, untill it stops
|
|
if(this.getSpeedX()>0.001) this.speedX = this.getSpeedX()*friction;
|
|
else this.setSpeedX(0f);
|
|
if(this.getSpeedY()>0.001) this.speedY = this.getSpeedY()*friction;
|
|
else this.setSpeedY(0f);
|
|
}
|
|
}
|