@Override
    public void update(float delta) {
        handleInput();
        Vector2D[] vertices = this.bounds.getVertices();
        Rectangle r = (Rectangle)this.bounds;
        if(vertices[0].x<limits.getPosition().x){
            this.setPosition(new Vector2D(limits.getPosition().x + r.getWidth()/2,this.getPosition().y)); 
            //this.velocity.thisBounceNormal(new Vector2D(1,0));
            this.velocity.thisScale(0.1f);
        }
        if(vertices[1].x>limits.getPosition().x+limits.getWidth()){
            this.setPosition(new Vector2D(limits.getPosition().x +limits.getWidth()-r.getWidth()/2,this.getPosition().y));        
            //this.velocity.thisBounceNormal(new Vector2D(-1,0));
            this.velocity.thisScale(0.1f);
        }
        if(vertices[0].y <limits.getPosition().y){
            this.setPosition(new Vector2D(this.getPosition().x,limits.getPosition().y + r.getHeight()/2)); 
            //this.velocity.thisBounceNormal(new Vector2D(0,1));
            this.velocity.thisScale(0.1f);
        }
        if(vertices[2].y>limits.getPosition().y+limits.getHeight()){
            this.setPosition(new Vector2D(this.getPosition().x,limits.getPosition().y+limits.getHeight() - r.getHeight()/2));        
            //this.velocity.thisBounceNormal(new Vector2D(0,-1));
            this.velocity.thisScale(0.1f);
        }
        
        this.setPosition(this.getPosition().add(velocity.scale(delta)));       
        this.velocity.thisScale((float)Math.pow(0.7f, delta));
        if(velocity.length()>maxSpeed){
            velocity = velocity.normalize().scale(maxSpeed);
        }
    }