Add files via upload

This commit is contained in:
JoeMolinelli authored and GitHub committed 2026-08-01 15:37:32 -04:00
1 parent 5eb6fade7f
commit 116a409b6d
43 files changed
+7836

No files matched your search

@@ -0,0 +1,73 @@
package components;
import WS3000.weatherstar3000.Component;
import WS3000.weatherstar3000.Transform;
import renderer.Texture;
import org.joml.Vector2f;
import org.joml.Vector4f;
public class SpriteRenderer extends Component {
private Vector4f color;
private Sprite sprite;
private Transform lastTransform;
private boolean isDirty;
public SpriteRenderer(Vector4f color) {
this.color = color;
this.sprite = new Sprite(null);
this.isDirty = true;
}
public SpriteRenderer(Sprite sprite) {
this.sprite = sprite;
this.color = new Vector4f(1,1,1,1);
this.isDirty = true;
}
@Override
public void start() {
this.lastTransform = gameObject.transform.copy();
}
@Override
public void update(float dt) {
if (!this.lastTransform.equals(this.gameObject.transform)) {
this.gameObject.transform.copy(lastTransform);
isDirty = true;
}
}
public Vector4f getColor() {
return this.color;
}
public Texture getTexture() {
return sprite.getTexture();
}
public Vector2f[] getTexCoords() {
return sprite.getTexCoords();
}
public void setSprite(Sprite sprite) {
this.sprite = sprite;
this.isDirty = true;
}
public void setColor(Vector4f color) {
if (!this.color.equals(color)) {
this.isDirty = true;
this.color = color;
}
}
public boolean isDirty() {
return this.isDirty;
}
public void setClean() {
this.isDirty = false;
}
}