add hero walk graphics, objects atlas packing and refactor components to be records

This commit is contained in:
Quillraven
2025-05-24 16:35:40 +02:00
parent 77f494b8a1
commit 85ba3d894d
47 changed files with 331 additions and 22 deletions

View File

@@ -0,0 +1,258 @@
objects.png
size: 512, 512
format: RGBA8888
filter: Nearest, Nearest
repeat: none
hero/walk_down
rotate: false
xy: 2, 410
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 0
hero/walk_down
rotate: false
xy: 2, 342
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 1
hero/walk_down
rotate: false
xy: 70, 410
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 2
hero/walk_down
rotate: false
xy: 2, 274
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 3
hero/walk_down
rotate: false
xy: 70, 342
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 4
hero/walk_down
rotate: false
xy: 138, 410
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 5
hero/walk_down
rotate: false
xy: 2, 206
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 6
hero/walk_down
rotate: false
xy: 70, 274
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 7
hero/walk_down
rotate: false
xy: 138, 342
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 8
hero/walk_left
rotate: false
xy: 206, 410
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 0
hero/walk_left
rotate: false
xy: 2, 138
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 1
hero/walk_left
rotate: false
xy: 70, 206
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 2
hero/walk_left
rotate: false
xy: 138, 274
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 3
hero/walk_left
rotate: false
xy: 206, 342
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 4
hero/walk_left
rotate: false
xy: 274, 410
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 5
hero/walk_left
rotate: false
xy: 2, 70
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 6
hero/walk_left
rotate: false
xy: 70, 138
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 7
hero/walk_left
rotate: false
xy: 138, 206
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 8
hero/walk_right
rotate: false
xy: 206, 274
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 0
hero/walk_right
rotate: false
xy: 274, 342
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 1
hero/walk_right
rotate: false
xy: 342, 410
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 2
hero/walk_right
rotate: false
xy: 2, 2
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 3
hero/walk_right
rotate: false
xy: 70, 70
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 4
hero/walk_right
rotate: false
xy: 138, 138
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 5
hero/walk_right
rotate: false
xy: 206, 206
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 6
hero/walk_right
rotate: false
xy: 274, 274
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 7
hero/walk_right
rotate: false
xy: 342, 342
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 8
hero/walk_up
rotate: false
xy: 410, 410
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 0
hero/walk_up
rotate: false
xy: 70, 2
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 1
hero/walk_up
rotate: false
xy: 138, 70
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 2
hero/walk_up
rotate: false
xy: 206, 138
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 3
hero/walk_up
rotate: false
xy: 274, 206
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 4
hero/walk_up
rotate: false
xy: 342, 274
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 5
hero/walk_up
rotate: false
xy: 410, 342
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 6
hero/walk_up
rotate: false
xy: 138, 2
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 7
hero/walk_up
rotate: false
xy: 206, 70
size: 64, 64
orig: 64, 64
offset: 0, 0
index: 8

BIN
assets/graphics/objects.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

View File

@@ -16,6 +16,9 @@
"y": 356.35255088317047
}
},
"objects.tsx": {
"dynamicWrapping": true
},
"tileset.tsx": {
"scaleInDock": 1,
"scaleInEditor": 1
@@ -38,5 +41,6 @@
],
"tileset.lastUsedFormat": "tsx",
"tileset.margin": 4,
"tileset.spacing": 8
"tileset.spacing": 8,
"tileset.type": 1
}

2
assets/maps/objects.tsx Normal file
View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.11.1-99-gec89c545" name="objects" tilewidth="1" tileheight="1" tilecount="0" columns="0"/>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@@ -0,0 +1,36 @@
{
"pot": true,
"paddingX": 4,
"paddingY": 4,
"bleed": true,
"edgePadding": true,
"duplicatePadding": true,
"rotation": false,
"minWidth": 16,
"minHeight": 16,
"maxWidth": 512,
"maxHeight": 512,
"square": false,
"stripWhitespaceX": false,
"stripWhitespaceY": false,
"alphaThreshold": 0,
"filterMin": "Nearest",
"filterMag": "Nearest",
"wrapX": "ClampToEdge",
"wrapY": "ClampToEdge",
"format": "RGBA8888",
"alias": false,
"outputFormat": "png",
"jpegQuality": 0.9,
"ignoreBlankImages": true,
"fast": false,
"debug": false,
"combineSubdirectories": true,
"flattenPaths": false,
"premultiplyAlpha": false,
"useIndexes": true,
"limitMemory": true,
"grid": false,
"scale": [1],
"scaleSuffix": [""]
}

View File

@@ -9,9 +9,9 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
* Component that stores the visual representation of an entity.
* Contains a texture region and a color for tinting.
*/
public class Graphic implements Component {
public record Graphic(
TextureRegion region,
Color color
) implements Component {
public static final ComponentMapper<Graphic> MAPPER = ComponentMapper.getFor(Graphic.class);
public TextureRegion region;
public final Color color = new Color(Color.WHITE);
}

View File

@@ -8,13 +8,13 @@ import com.badlogic.gdx.math.Vector2;
* Component that stores the position, z-index, and size of an entity.
* Implements Comparable to allow sorting entities by z-index and position.
*/
public class Transform implements Component, Comparable<Transform> {
public record Transform(
Vector2 position,
int z,
Vector2 size
) implements Component, Comparable<Transform> {
public static final ComponentMapper<Transform> MAPPER = ComponentMapper.getFor(Transform.class);
public final Vector2 position = new Vector2();
public int z = 0;
public final Vector2 size = new Vector2(1f, 1f);
@Override
public int compareTo(Transform other) {
if (this.z != other.z) {

View File

@@ -74,16 +74,16 @@ public class RenderSystem extends SortedIteratingSystem implements Disposable {
protected void processEntity(Entity entity, float deltaTime) {
Transform transform = Transform.MAPPER.get(entity);
Graphic graphic = Graphic.MAPPER.get(entity);
if (graphic.region == null) {
if (graphic.region() == null) {
return;
}
batch.setColor(graphic.color);
batch.setColor(graphic.color());
batch.draw(
graphic.region,
transform.position.x, transform.position.y,
transform.size.x / 2, transform.size.y / 2,
transform.size.x, transform.size.y,
graphic.region(),
transform.position().x, transform.position().y,
transform.size().x / 2, transform.size().y / 2,
transform.size().x, transform.size().y,
1, 1,
0
);

View File

@@ -1,20 +1,29 @@
package io.github.com.quillraven.util;
import com.badlogic.gdx.tools.texturepacker.TexturePacker;
import java.io.File;
/**
* Utility class to execute LibGDX's TextureAtlas packer tool.
* This tool packs multiple images into a single texture atlas.
*/
public class TexturePackerTool {
public static void main(String[] args) {
// packMap();
packObjects();
System.out.println("Texture packing completed successfully!");
}
private static void packObjects() {
String inputDir = "assets_raw/objects";
String outputDir = "assets/graphics";
String packFileName = "objects";
System.out.println("Packing textures from " + inputDir + " to " + outputDir + "/" + packFileName);
TexturePacker.process(inputDir, outputDir, packFileName);
}
private static void packMap() {
String inputDir = "assets_raw/map";
String outputDir = "assets/maps";
String packFileName = "tileset";
System.out.println("Packing textures from " + inputDir + " to " + outputDir + "/" + packFileName);
TexturePacker.process(inputDir, outputDir, packFileName);
System.out.println("Texture packing completed successfully!");
}
}