Hitbox fixes
This commit is contained in:
@@ -3,6 +3,7 @@ package mindustry.entities;
|
|||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
|
import arc.util.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
@@ -58,13 +59,12 @@ public class EntityCollisions{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void moveDelta(Hitboxc entity, float deltax, float deltay, boolean x, SolidPred solidCheck){
|
public void moveDelta(Hitboxc entity, float deltax, float deltay, boolean x, SolidPred solidCheck){
|
||||||
Rect rect = r1;
|
entity.hitboxTile(r1);
|
||||||
entity.hitboxTile(rect);
|
|
||||||
entity.hitboxTile(r2);
|
entity.hitboxTile(r2);
|
||||||
rect.x += deltax;
|
r1.x += deltax;
|
||||||
rect.y += deltay;
|
r1.y += deltay;
|
||||||
|
|
||||||
int tilex = Math.round((rect.x + rect.width / 2) / tilesize), tiley = Math.round((rect.y + rect.height / 2) / tilesize);
|
int tilex = Math.round((r1.x + r1.width / 2) / tilesize), tiley = Math.round((r1.y + r1.height / 2) / tilesize);
|
||||||
|
|
||||||
for(int dx = -r; dx <= r; dx++){
|
for(int dx = -r; dx <= r; dx++){
|
||||||
for(int dy = -r; dy <= r; dy++){
|
for(int dy = -r; dy <= r; dy++){
|
||||||
@@ -72,17 +72,16 @@ public class EntityCollisions{
|
|||||||
if(solidCheck.solid(wx, wy)){
|
if(solidCheck.solid(wx, wy)){
|
||||||
tmp.setSize(tilesize).setCenter(wx * tilesize, wy * tilesize);
|
tmp.setSize(tilesize).setCenter(wx * tilesize, wy * tilesize);
|
||||||
|
|
||||||
if(tmp.overlaps(rect)){
|
if(tmp.overlaps(r1)){
|
||||||
Vec2 v = Geometry.overlap(rect, tmp, x);
|
Vec2 v = Geometry.overlap(r1, tmp, x);
|
||||||
rect.x += v.x;
|
if(x) r1.x += v.x;
|
||||||
rect.y += v.y;
|
if(!x) r1.y += v.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.x(entity.getX() + rect.x - r2.x);
|
entity.trns(r1.x - r2.x, r1.y - r2.y);
|
||||||
entity.y(entity.getY() + rect.y - r2.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean overlapsTile(Rect rect){
|
public boolean overlapsTile(Rect rect){
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ abstract class HitboxComp implements Posc, QuadTreeObject{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void hitboxTile(Rect rect){
|
public void hitboxTile(Rect rect){
|
||||||
float scale = 0.6f;
|
float scale = 0.66f;
|
||||||
rect.setCentered(x, y, hitSize * scale, hitSize * scale);
|
rect.setCentered(x, y, hitSize * scale, hitSize * scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user