Taking a break from hitboxes
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"activeFile": "overworld.tsx",
|
"activeFile": "map.tmj",
|
||||||
"expandedProjectPaths": [
|
"expandedProjectPaths": [
|
||||||
"templates",
|
"templates",
|
||||||
"."
|
"."
|
||||||
@ -16,8 +16,8 @@
|
|||||||
"scale": 4,
|
"scale": 4,
|
||||||
"selectedLayer": 2,
|
"selectedLayer": 2,
|
||||||
"viewCenter": {
|
"viewCenter": {
|
||||||
"x": 6625.125,
|
"x": 6599.375,
|
||||||
"y": 6667.875
|
"y": 6795.125
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"overworld.tsx": {
|
"overworld.tsx": {
|
||||||
@ -35,8 +35,8 @@
|
|||||||
"project": "map project.tiled-project",
|
"project": "map project.tiled-project",
|
||||||
"property.type": "int",
|
"property.type": "int",
|
||||||
"recentFiles": [
|
"recentFiles": [
|
||||||
"map.tmj",
|
|
||||||
"overworld.tsx",
|
"overworld.tsx",
|
||||||
|
"map.tmj",
|
||||||
"entities.tsx"
|
"entities.tsx"
|
||||||
],
|
],
|
||||||
"tileset.lastUsedFilter": "Tiled tileset files (*.tsx *.xml)",
|
"tileset.lastUsedFilter": "Tiled tileset files (*.tsx *.xml)",
|
||||||
|
11
data/map.tmj
11
data/map.tmj
@ -40,9 +40,9 @@
|
|||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 18, 19, 20, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 34, 35, 36, 1, 1],
|
||||||
"height":16,
|
"height":16,
|
||||||
"width":16,
|
"width":16,
|
||||||
"x":400,
|
"x":400,
|
||||||
@ -270,7 +270,6 @@
|
|||||||
}],
|
}],
|
||||||
"height":32,
|
"height":32,
|
||||||
"id":1,
|
"id":1,
|
||||||
"locked":true,
|
|
||||||
"name":"Base Layer",
|
"name":"Base Layer",
|
||||||
"opacity":1,
|
"opacity":1,
|
||||||
"startx":384,
|
"startx":384,
|
||||||
@ -426,8 +425,8 @@
|
|||||||
"type":"player_spawn",
|
"type":"player_spawn",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":16,
|
"width":16,
|
||||||
"x":6591.33333333333,
|
"x":6607.58333333333,
|
||||||
"y":6787
|
"y":6944.25
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id":7,
|
"id":7,
|
||||||
|
@ -91,6 +91,11 @@ void entityUpdate(entity_t *entity) {
|
|||||||
uint8_t chunkTileY = tileY % CHUNK_HEIGHT;
|
uint8_t chunkTileY = tileY % CHUNK_HEIGHT;
|
||||||
tile_t tile = chunk->tilesBase[chunkTileY * CHUNK_WIDTH + chunkTileX];
|
tile_t tile = chunk->tilesBase[chunkTileY * CHUNK_WIDTH + chunkTileX];
|
||||||
|
|
||||||
|
fixed248_t lx = fx248Mulfx248(x, FIXED248(TILE_WIDTH_HEIGHT, 0));
|
||||||
|
fixed248_t ty = fx248Mulfx248(y, FIXED248(TILE_WIDTH_HEIGHT, 0));
|
||||||
|
fixed248_t rx = fx248Addfx248(lx, FIXED248(TILE_WIDTH_HEIGHT, 0));
|
||||||
|
fixed248_t by = fx248Addfx248(ty, FIXED248(TILE_WIDTH_HEIGHT, 0));
|
||||||
|
|
||||||
// Determine tile collision type
|
// Determine tile collision type
|
||||||
collisionresult_t collision;
|
collisionresult_t collision;
|
||||||
switch(TILE_META_DATA[tile].solidType) {
|
switch(TILE_META_DATA[tile].solidType) {
|
||||||
@ -104,6 +109,47 @@ void entityUpdate(entity_t *entity) {
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TILE_SOLID_TRIANGLE_TOP_RIGHT:
|
||||||
|
collision = physicsCheckCircleTriangle(
|
||||||
|
newX, newY, selfCircR,
|
||||||
|
lx, ty,
|
||||||
|
rx, ty,
|
||||||
|
rx, by
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// case TILE_SOLID_TRIANGLE_TOP_LEFT:
|
||||||
|
// collision = physicsCheckCircleTriangle(
|
||||||
|
// newX, newY, selfCircR,
|
||||||
|
// lx, ty,
|
||||||
|
// rx, ty,
|
||||||
|
// lx, by
|
||||||
|
// );
|
||||||
|
// break;
|
||||||
|
// case TILE_SOLID_TRIANGLE_BOTTOM_RIGHT:
|
||||||
|
// collision = physicsCheckCircleTriangle(
|
||||||
|
// newX, newY, selfCircR,
|
||||||
|
// fx248Mulfx248(x, FIXED248(TILE_WIDTH_HEIGHT, 0)),
|
||||||
|
// fx248Addfx248(fx248Mulfx248(y, FIXED248(TILE_WIDTH_HEIGHT, 0)), FIXED248(TILE_WIDTH_HEIGHT, 0)),
|
||||||
|
// fx248Addfx248(fx248Mulfx248(x, FIXED248(TILE_WIDTH_HEIGHT, 0)), FIXED248(TILE_WIDTH_HEIGHT, 0)),
|
||||||
|
// fx248Addfx248(fx248Mulfx248(y, FIXED248(TILE_WIDTH_HEIGHT, 0)), FIXED248(TILE_WIDTH_HEIGHT, 0)),
|
||||||
|
// fx248Mulfx248(x, FIXED248(TILE_WIDTH_HEIGHT, 0)),
|
||||||
|
// fx248Mulfx248(y, FIXED248(TILE_WIDTH_HEIGHT, 0))
|
||||||
|
// );
|
||||||
|
// break;
|
||||||
|
|
||||||
|
// case TILE_SOLID_TRIANGLE_BOTTOM_LEFT:
|
||||||
|
// collision = physicsCheckCircleTriangle(
|
||||||
|
// newX, newY, selfCircR,
|
||||||
|
// fx248Mulfx248(x, FIXED248(TILE_WIDTH_HEIGHT, 0)),
|
||||||
|
// fx248Addfx248(fx248Mulfx248(y, FIXED248(TILE_WIDTH_HEIGHT, 0)), FIXED248(TILE_WIDTH_HEIGHT, 0)),
|
||||||
|
// fx248Addfx248(fx248Mulfx248(x, FIXED248(TILE_WIDTH_HEIGHT, 0)), FIXED248(TILE_WIDTH_HEIGHT, 0)),
|
||||||
|
// fx248Addfx248(fx248Mulfx248(y, FIXED248(TILE_WIDTH_HEIGHT, 0)), FIXED248(TILE_WIDTH_HEIGHT, 0)),
|
||||||
|
// fx248Addfx248(fx248Mulfx248(x, FIXED248(TILE_WIDTH_HEIGHT, 0)), FIXED248(TILE_WIDTH_HEIGHT, 0)),
|
||||||
|
// fx248Mulfx248(y, FIXED248(TILE_WIDTH_HEIGHT, 0))
|
||||||
|
// );
|
||||||
|
// break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -98,3 +98,14 @@ collisionresult_t physicsCheckCircleAABB(
|
|||||||
result.hit = true;
|
result.hit = true;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
collisionresult_t physicsCheckCircleTriangle(
|
||||||
|
fixed248_t circleX, fixed248_t circleY, fixed248_t circleR,
|
||||||
|
fixed248_t triX0, fixed248_t triY0,
|
||||||
|
fixed248_t triX1, fixed248_t triY1,
|
||||||
|
fixed248_t triX2, fixed248_t triY2
|
||||||
|
) {
|
||||||
|
collisionresult_t result;
|
||||||
|
result.hit = false;
|
||||||
|
return result;
|
||||||
|
}
|
@ -47,3 +47,24 @@ collisionresult_t physicsCheckCircleAABB(
|
|||||||
fixed248_t aabb, fixed248_t aabbY,
|
fixed248_t aabb, fixed248_t aabbY,
|
||||||
fixed248_t aabbWidth, fixed248_t aabbHeight
|
fixed248_t aabbWidth, fixed248_t aabbHeight
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for collision between a circle and a triangle.
|
||||||
|
*
|
||||||
|
* @param circleX X coordinate of the circle's center.
|
||||||
|
* @param circleY Y coordinate of the circle's center.
|
||||||
|
* @param circleR Radius of the circle.
|
||||||
|
* @param triX0 X coordinate of the first vertex of the triangle.
|
||||||
|
* @param triY0 Y coordinate of the first vertex of the triangle.
|
||||||
|
* @param triX1 X coordinate of the second vertex of the triangle.
|
||||||
|
* @param triY1 Y coordinate of the second vertex of the triangle.
|
||||||
|
* @param triX2 X coordinate of the third vertex of the triangle.
|
||||||
|
* @param triY2 Y coordinate of the third vertex of the triangle.
|
||||||
|
* @return A collisionresult_t structure containing collision information.
|
||||||
|
*/
|
||||||
|
collisionresult_t physicsCheckCircleTriangle(
|
||||||
|
fixed248_t circleX, fixed248_t circleY, fixed248_t circleR,
|
||||||
|
fixed248_t triX0, fixed248_t triY0,
|
||||||
|
fixed248_t triX1, fixed248_t triY1,
|
||||||
|
fixed248_t triX2, fixed248_t triY2
|
||||||
|
);
|
@ -191,3 +191,11 @@ fixed248_t fx248Max(const fixed248_t a, const fixed248_t b) {
|
|||||||
fixed248_t fx248Min(const fixed248_t a, const fixed248_t b) {
|
fixed248_t fx248Min(const fixed248_t a, const fixed248_t b) {
|
||||||
return (a < b) ? a : b;
|
return (a < b) ? a : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fixed248_t fx248Clamp(
|
||||||
|
const fixed248_t a,
|
||||||
|
const fixed248_t min,
|
||||||
|
const fixed248_t max
|
||||||
|
) {
|
||||||
|
return (a < min) ? min : (a > max) ? max : a;
|
||||||
|
}
|
@ -336,3 +336,17 @@ fixed248_t fx248Max(const fixed248_t a, const fixed248_t b);
|
|||||||
* @return The minimum of the two values.
|
* @return The minimum of the two values.
|
||||||
*/
|
*/
|
||||||
fixed248_t fx248Min(const fixed248_t a, const fixed248_t b);
|
fixed248_t fx248Min(const fixed248_t a, const fixed248_t b);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clamp a fixed248_t value between a minimum and maximum value.
|
||||||
|
*
|
||||||
|
* @param a The fixed248_t value to clamp.
|
||||||
|
* @param min The minimum value to clamp to.
|
||||||
|
* @param max The maximum value to clamp to.
|
||||||
|
* @return The clamped fixed248_t value.
|
||||||
|
*/
|
||||||
|
fixed248_t fx248Clamp(
|
||||||
|
const fixed248_t a,
|
||||||
|
const fixed248_t min,
|
||||||
|
const fixed248_t max
|
||||||
|
);
|
Reference in New Issue
Block a user