package de.samdev.colorrunner.game.world.entities;

import de.samdev.colorrunner.game.world.CRGameWorld;

public abstract class GravityEntity extends MovingEntity {
	public final static float GRAVITY_FORCE = 700f;
	public final static float TERMINAL_VELOCITY = 900f;
	
	public GravityEntity(CRGameWorld _owner, float width, float height) {
		this(_owner, 0, 0, width, height);
	}
	
	public GravityEntity(CRGameWorld _owner, float x, float y, float width, float height) {
		super(_owner, x, y, width, height);
	}

	@Override
	public void update(float delta) {
		velocity.y -= GRAVITY_FORCE * delta;
			
		if (velocity.y < -TERMINAL_VELOCITY) {
			velocity.y = -TERMINAL_VELOCITY;
		}
		
		super.update(delta);
		
		if (isTouching_BOTTOM() && velocity.y < 0)
			velocity.y = 0;
	}
}
