Added diagonal ramps
All checks were successful
Build Dusk / build-linux (push) Successful in 55s
Build Dusk / build-psp (push) Successful in 1m4s

This commit is contained in:
2025-11-19 15:40:37 -06:00
parent bd5a67676b
commit c32df89490
20 changed files with 256 additions and 173 deletions

View File

@@ -112,15 +112,19 @@ errorret_t assetChunkLoad(assetcustom_t custom) {
}
// Init the mesh
mesh_t *mesh = &chunk->meshes[i];
meshInit(
mesh,
MESH_PRIMITIVE_TRIANGLES,
modelHeader.vertexCount,
&chunk->vertices[vertexIndex]
);
if(modelHeader.vertexCount > 0) {
mesh_t *mesh = &chunk->meshes[i];
meshInit(
mesh,
MESH_PRIMITIVE_TRIANGLES,
modelHeader.vertexCount,
&chunk->vertices[vertexIndex]
);
vertexIndex += modelHeader.vertexCount;
vertexIndex += modelHeader.vertexCount;
} else {
chunk->meshes[i].vertexCount = 0;
}
}
errorOk();

View File

@@ -25,6 +25,10 @@ TILE_SHAPE_RAMP_SOUTH = 2
TILE_SHAPE_RAMP_WEST = 3
TILE_SHAPE_RAMP_EAST = 4
TILE_SHAPE_RAMP_NORTH = 5
TILE_SHAPE_RAMP_SOUTHWEST = 6
TILE_SHAPE_RAMP_SOUTHEAST = 7
TILE_SHAPE_RAMP_NORTHWEST = 8
TILE_SHAPE_RAMP_NORTHEAST = 9
RPG_CAMERA_FOV = 70
RPG_CAMERA_PIXELS_PER_UNIT = 1.0

View File

@@ -84,8 +84,30 @@ void entityWalk(entity_t *entity, const entitydir_t direction) {
// Are we walking up a ramp?
if(
tileIsRamp(tileCurrent) &&
(direction+TILE_SHAPE_RAMP_SOUTH) == tileCurrent &&
newPos.z < (MAP_CHUNK_DEPTH - 1)
(
// Can only walk UP the direction the ramp faces.
(direction+TILE_SHAPE_RAMP_SOUTH) == tileCurrent ||
// If diagonal ramp, can go up one of two ways only.
(
(
tileCurrent == TILE_SHAPE_RAMP_SOUTHEAST &&
(direction == ENTITY_DIR_SOUTH || direction == ENTITY_DIR_EAST)
) ||
(
tileCurrent == TILE_SHAPE_RAMP_SOUTHWEST &&
(direction == ENTITY_DIR_SOUTH || direction == ENTITY_DIR_WEST)
) ||
(
tileCurrent == TILE_SHAPE_RAMP_NORTHEAST &&
(direction == ENTITY_DIR_NORTH || direction == ENTITY_DIR_EAST)
) ||
(
tileCurrent == TILE_SHAPE_RAMP_NORTHWEST &&
(direction == ENTITY_DIR_NORTH || direction == ENTITY_DIR_WEST)
)
)
// Must be able to walk up.
) && newPos.z < (MAP_CHUNK_DEPTH - 1)
) {
tileNew = TILE_SHAPE_NULL;// Force check for ramp above.
worldpos_t abovePos = newPos;
@@ -104,7 +126,29 @@ void entityWalk(entity_t *entity, const entitydir_t direction) {
if(
tileBelow != TILE_SHAPE_NULL &&
tileIsRamp(tileBelow) &&
(entityDirGetOpposite(direction)+TILE_SHAPE_RAMP_SOUTH) == tileBelow
(
// This handles regular cardinal ramps
(entityDirGetOpposite(direction)+TILE_SHAPE_RAMP_SOUTH) == tileBelow ||
// This handles diagonal ramps
(
(
tileBelow == TILE_SHAPE_RAMP_SOUTHEAST &&
(direction == ENTITY_DIR_NORTH || direction == ENTITY_DIR_WEST)
) ||
(
tileBelow == TILE_SHAPE_RAMP_SOUTHWEST &&
(direction == ENTITY_DIR_NORTH || direction == ENTITY_DIR_EAST)
) ||
(
tileBelow == TILE_SHAPE_RAMP_NORTHEAST &&
(direction == ENTITY_DIR_SOUTH || direction == ENTITY_DIR_WEST)
) ||
(
tileBelow == TILE_SHAPE_RAMP_NORTHWEST &&
(direction == ENTITY_DIR_SOUTH || direction == ENTITY_DIR_EAST)
)
)
)
) {
// We will fall to this tile.
fall = true;

View File

@@ -127,6 +127,7 @@ void mapDispose() {
void mapChunkUnload(chunk_t* chunk) {
for(uint8_t i = 0; i < chunk->meshCount; i++) {
if(chunk->meshes[i].vertexCount == 0) continue;
meshDispose(&chunk->meshes[i]);
}
}
@@ -135,6 +136,7 @@ errorret_t mapChunkLoad(chunk_t* chunk) {
char_t buffer[64];
chunk->meshCount = 0;
memoryZero(chunk->meshes, sizeof(chunk->meshes));
snprintf(buffer, sizeof(buffer), "map/map/%d_%d_%d.dcf",
chunk->position.x,

View File

@@ -9,15 +9,11 @@
bool_t tileIsWalkable(const tile_t tile) {
switch(tile) {
case TILE_SHAPE_FLOOR:
case TILE_SHAPE_RAMP_NORTH:
case TILE_SHAPE_RAMP_SOUTH:
case TILE_SHAPE_RAMP_EAST:
case TILE_SHAPE_RAMP_WEST:
return true;
case TILE_SHAPE_NULL:
return false;
default:
return false;
return true;
}
}
@@ -27,6 +23,10 @@ bool_t tileIsRamp(const tile_t tile) {
case TILE_SHAPE_RAMP_SOUTH:
case TILE_SHAPE_RAMP_EAST:
case TILE_SHAPE_RAMP_WEST:
case TILE_SHAPE_RAMP_NORTHEAST:
case TILE_SHAPE_RAMP_NORTHWEST:
case TILE_SHAPE_RAMP_SOUTHEAST:
case TILE_SHAPE_RAMP_SOUTHWEST:
return true;
default:

View File

@@ -169,6 +169,7 @@ void sceneMapRenderMap() {
for(uint8_t j = 0; j < chunk->meshCount; j++) {
mesh_t *mesh = &chunk->meshes[j];
if(mesh->vertexCount == 0) continue;
textureBind(NULL);
meshDraw(mesh, -1, -1);
}