mirror of
https://github.com/MistWeatherMedia/WeatherSTAR-3000-Java.git
synced 2026-11-28 14:38:08 -08:00
Delete src/main directory
This commit is contained in:
1 parent
e1d7f70eda
commit
800569688a
42 files changed
-7693
No files matched your search
@@ -1,46 +0,0 @@
|
||||
package components;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.joml.Vector2f;
|
||||
|
||||
import renderer.Texture;
|
||||
|
||||
public class Spritesheet {
|
||||
private Texture texture;
|
||||
private List<Sprite> sprites;
|
||||
|
||||
public Spritesheet(Texture texture, int spriteWidth, int spriteHeight, int numSprites, int spacing) {
|
||||
this.sprites = new ArrayList<>();
|
||||
|
||||
this.texture = texture;
|
||||
int currentX = 0;
|
||||
int currentY = texture.getHeight() - spriteHeight;
|
||||
for (int i = 0; i < numSprites; i++) {
|
||||
float topY = (currentY + spriteHeight) / (float)texture.getHeight();;
|
||||
float rightX = (currentX + spriteWidth) / (float)texture.getWidth();
|
||||
float leftX = currentX / (float)texture.getWidth();
|
||||
float bottomY = currentY / (float)texture.getHeight();;
|
||||
|
||||
Vector2f[] texCoords = {
|
||||
new Vector2f(rightX, bottomY),
|
||||
new Vector2f(rightX, topY),
|
||||
new Vector2f(leftX, topY),
|
||||
new Vector2f(leftX, bottomY)
|
||||
};
|
||||
Sprite sprite = new Sprite(this.texture, texCoords);
|
||||
this.sprites.add(sprite);
|
||||
|
||||
currentX += spriteWidth + spacing;
|
||||
if (currentX >= texture.getWidth()) {
|
||||
currentX = 0;
|
||||
currentY -= spriteHeight + spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Sprite getSprite(int index) {
|
||||
return this.sprites.get(index);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user