- Implemented collision tests to verify overlap and movement logic for collision bodies. - Enhanced entity dispatch entry tests to cover initialization, group ID management, and process handling. - Expanded file system tests to include crash diagnostics and ensure proper game data root detection. - Created isometric controls tests to validate movement requests and screen projection calculations. - Added map renderer tests to check fixed map loading and rendering functionality. - Introduced map sorter tests to confirm correct rendering order for various items.
72 lines
No EOL
2.7 KiB
C++
72 lines
No EOL
2.7 KiB
C++
#include "remorse/collision.h"
|
|
|
|
#include <cassert>
|
|
|
|
int main()
|
|
{
|
|
const remorse::CollisionBody actor{{100, 100, 0}, 96, 96, 80};
|
|
const remorse::CollisionBody wall{{300, 100, 0}, 64, 96, 128};
|
|
assert(!remorse::collisionBodiesOverlap(actor, wall));
|
|
assert(remorse::canMoveCollisionBody(actor, {200, 100, 0}, {wall}));
|
|
assert(!remorse::canMoveCollisionBody(actor, {260, 100, 0}, {wall}));
|
|
assert(!remorse::canMoveCollisionBody(actor, {400, 100, 0}, {wall}));
|
|
|
|
const remorse::CollisionBody floorBelow{{300, 100, -20}, 64, 96, 20};
|
|
const remorse::CollisionBody overhead{{300, 100, 80}, 64, 96, 32};
|
|
assert(!remorse::collisionBodiesOverlap(actor, floorBelow));
|
|
assert(!remorse::collisionBodiesOverlap(actor, overhead));
|
|
|
|
const remorse::CollisionBody initiallyOverlapping{{250, 100, 0}, 96, 96, 80};
|
|
assert(remorse::canMoveCollisionBody(initiallyOverlapping, {200, 100, 0}, {wall}));
|
|
assert(!remorse::canMoveCollisionBody(initiallyOverlapping, {400, 100, 0}, {wall}));
|
|
|
|
remorse::ShapeTypeInfo actorInfo;
|
|
actorInfo.x = 3;
|
|
actorInfo.y = 3;
|
|
actorInfo.z = 10;
|
|
actorInfo.flags = 0x2;
|
|
const remorse::CollisionBody authoredActor = remorse::makeCollisionBody({100, 100, 0}, actorInfo);
|
|
assert(authoredActor.extentX == 96);
|
|
assert(authoredActor.extentY == 96);
|
|
assert(authoredActor.extentZ == 80);
|
|
|
|
remorse::ShapeTypeInfo obstacleInfo;
|
|
obstacleInfo.x = 2;
|
|
obstacleInfo.y = 4;
|
|
obstacleInfo.z = 8;
|
|
const remorse::CollisionBody flipped = remorse::makeCollisionBody({300, 300, 0}, obstacleInfo, true);
|
|
assert(flipped.extentX == 128);
|
|
assert(flipped.extentY == 64);
|
|
|
|
remorse::FixedMap map;
|
|
remorse::FixedMapEntry solid;
|
|
solid.x = 500;
|
|
solid.y = 600;
|
|
solid.shape = 1;
|
|
map.entries.push_back(solid);
|
|
remorse::FixedMapEntry globParent;
|
|
globParent.x = 0x480;
|
|
globParent.y = 0x640;
|
|
globParent.shape = 2;
|
|
globParent.quality = 7;
|
|
map.entries.push_back(globParent);
|
|
|
|
std::vector<remorse::ShapeTypeInfo> shapeTypes(4);
|
|
shapeTypes[1] = obstacleInfo;
|
|
shapeTypes[1].flags = 0x2;
|
|
shapeTypes[2].family = 3;
|
|
shapeTypes[2].flags = 0x2;
|
|
shapeTypes[3] = obstacleInfo;
|
|
shapeTypes[3].flags = 0x2;
|
|
|
|
remorse::GlobObject glob;
|
|
glob.index = 7;
|
|
glob.entries.push_back(remorse::GlobObjectEntry{2, 3, 4, 3, 0});
|
|
const auto bodies = remorse::collectMapCollisionBodies(map, shapeTypes, {glob});
|
|
assert(bodies.size() == 2);
|
|
assert(bodies[0].location.x == 500 && bodies[0].location.y == 600);
|
|
assert(bodies[1].location.x == (0x480 & ~0x3ff) + 2 * 4 + 2);
|
|
assert(bodies[1].location.y == (0x640 & ~0x3ff) + 3 * 4 + 2);
|
|
assert(bodies[1].location.z == 4);
|
|
return 0;
|
|
} |