add hero walk graphics, objects atlas packing and refactor components to be records
258
assets/graphics/objects.atlas
Normal 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
|
After Width: | Height: | Size: 127 KiB |
@@ -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
@@ -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"/>
|
||||
|
Before Width: | Height: | Size: 141 KiB |
|
Before Width: | Height: | Size: 149 KiB |
BIN
assets_raw/objects/hero/walk_down_00.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
assets_raw/objects/hero/walk_down_01.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
assets_raw/objects/hero/walk_down_02.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
assets_raw/objects/hero/walk_down_03.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
assets_raw/objects/hero/walk_down_04.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
assets_raw/objects/hero/walk_down_05.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
assets_raw/objects/hero/walk_down_06.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
assets_raw/objects/hero/walk_down_07.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
assets_raw/objects/hero/walk_down_08.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
assets_raw/objects/hero/walk_left_00.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
assets_raw/objects/hero/walk_left_01.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
assets_raw/objects/hero/walk_left_02.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
assets_raw/objects/hero/walk_left_03.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
assets_raw/objects/hero/walk_left_04.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
assets_raw/objects/hero/walk_left_05.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
assets_raw/objects/hero/walk_left_06.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
assets_raw/objects/hero/walk_left_07.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
assets_raw/objects/hero/walk_left_08.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
assets_raw/objects/hero/walk_right_00.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
assets_raw/objects/hero/walk_right_01.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
assets_raw/objects/hero/walk_right_02.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
assets_raw/objects/hero/walk_right_03.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
assets_raw/objects/hero/walk_right_04.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
assets_raw/objects/hero/walk_right_05.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
assets_raw/objects/hero/walk_right_06.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
assets_raw/objects/hero/walk_right_07.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
assets_raw/objects/hero/walk_right_08.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
assets_raw/objects/hero/walk_up_00.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
assets_raw/objects/hero/walk_up_01.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
assets_raw/objects/hero/walk_up_02.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
assets_raw/objects/hero/walk_up_03.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
assets_raw/objects/hero/walk_up_04.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
assets_raw/objects/hero/walk_up_05.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
assets_raw/objects/hero/walk_up_06.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
assets_raw/objects/hero/walk_up_07.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
assets_raw/objects/hero/walk_up_08.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
36
assets_raw/objects/pack.json
Normal 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": [""]
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
@@ -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!");
|
||||
}
|
||||
}
|
||||
|
||||