Newer
Older
JumpingGame / src / main / java / views / Sprite.java
package views;

import entities.Pair;

public class Sprite {

    private Texture texture;
    private Image2D img;
    private Pair<Double> positionValue;
    private double scaleValue;

    public Sprite(String path) {
        this.positionValue = new Pair<>(0d, 0d);
        texture = new Texture("player", path);
        img = new Image2D(texture);
    }

    public double getScaleValue() {
        return this.scaleValue;
    }

    public Pair<Double> getPositionValue() {
        return this.positionValue;
    }

    public void setPositionValue(Pair<Double> positionValue) {
        this.positionValue = positionValue;
    }

    public void setScaleValue(double scaleValue) {
        this.scaleValue = scaleValue;
    }

    public void draw() {
        img.setScale(scaleValue);
        img.setPosition(positionValue);
        img.draw();
    }

    public void delete() {
        texture.delete();
    }
}