ent prog tiles
This commit is contained in:
@ -61,6 +61,7 @@ void entityTurn(entity_t *ent, const facingdir_t dir) {
|
||||
assertTrue(dir < FACING_DIRECTION_COUNT, "Invalid facing direction");
|
||||
|
||||
ent->direction = dir;
|
||||
ent->frame = 1 + (dir * 3);
|
||||
}
|
||||
|
||||
void entityMove(entity_t *ent, const facingdir_t dir) {
|
||||
|
@ -27,6 +27,7 @@ typedef struct {
|
||||
typedef struct _entity_t {
|
||||
uint8_t x, y;
|
||||
int8_t subX, subY;
|
||||
uint8_t frame;
|
||||
facingdir_t direction;
|
||||
entitytype_t type;
|
||||
|
||||
|
@ -28,8 +28,8 @@ void entitiesUpdate() {
|
||||
memoryCopyRangeSafe(
|
||||
&dst->position,
|
||||
&src->x,
|
||||
&src->subY + sizeof(uint8_t),
|
||||
sizeof(uint8_t) * 4
|
||||
&src->frame + sizeof(uint8_t),
|
||||
sizeof(uint8_t) * 5
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "../../../../dusk/overworld/overworlddefs.h"
|
||||
#include "../fragments/packed.glsl"
|
||||
#include "../fragments/quad.glsl"
|
||||
#include "../data/tilesets.glsl"
|
||||
|
||||
struct Entity {
|
||||
uvec4 position;
|
||||
@ -23,11 +24,10 @@ vec2 entityGetVertice(uint instanceIndex, uint indiceIndex) {
|
||||
// Get base quad vertice
|
||||
vec2 vert = quadGetVertice(indiceIndex);
|
||||
|
||||
uint entIndex = instanceIndex;
|
||||
uint x = packedGetU8(0u, entities[entIndex].position);
|
||||
uint y = packedGetU8(1u, entities[entIndex].position);
|
||||
int subX = packedGetI8(2u, entities[entIndex].position);
|
||||
int subY = packedGetI8(3u, entities[entIndex].position);
|
||||
uint x = packedGetU8(0u, entities[instanceIndex].position);
|
||||
uint y = packedGetU8(1u, entities[instanceIndex].position);
|
||||
int subX = packedGetI8(2u, entities[instanceIndex].position);
|
||||
int subY = packedGetI8(3u, entities[instanceIndex].position);
|
||||
|
||||
vert.x += float(x);
|
||||
vert.y += float(y);
|
||||
@ -38,4 +38,11 @@ vec2 entityGetVertice(uint instanceIndex, uint indiceIndex) {
|
||||
vert.y += float(subY);
|
||||
|
||||
return vert;
|
||||
}
|
||||
|
||||
vec2 entityGetUV(uint instanceIndex, uint indiceIndex) {
|
||||
uint frame = packedGetU8(4u, entities[instanceIndex].position);
|
||||
vec4 tilesetUVs = tilesetGetUVsByIndex(uint(TILESET_SLOT_ENTITIES), frame);
|
||||
vec2 uv = quadGetTextureCoordinate(indiceIndex, tilesetUVs);
|
||||
return uv;
|
||||
}
|
@ -6,7 +6,6 @@
|
||||
#include "../fragments/header.glsl"
|
||||
#include "../data/transforms.glsl"
|
||||
#include "../data/entities.glsl"
|
||||
#include "../data/tilesets.glsl"
|
||||
|
||||
// Outputs to fragment shader
|
||||
out vec2 v_TextureCoord;
|
||||
@ -15,10 +14,8 @@ void main() {
|
||||
uint instanceIndex = uint(gl_InstanceID);
|
||||
uint indiceIndex = quadGetIndiceIndex(gl_VertexID);
|
||||
|
||||
vec4 tilesetUVs = tilesetGetUVsByIndex(uint(TILESET_SLOT_ENTITIES), 1u);
|
||||
|
||||
vec2 vert = entityGetVertice(instanceIndex, indiceIndex);
|
||||
vec2 uv = quadGetTextureCoordinate(indiceIndex, tilesetUVs);
|
||||
vec2 uv = entityGetUV(instanceIndex, indiceIndex);
|
||||
|
||||
gl_Position = transforms.projection * transforms.view * vec4(vert, 0.0, 1.0);
|
||||
v_TextureCoord = uv;
|
||||
|
Reference in New Issue
Block a user