mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-11 18:39:16 +07:00
Refactored some entity code to use new Hitbox code
This commit is contained in:
parent
e96538b387
commit
c55a47ff57
@ -79,7 +79,7 @@ project(":core") {
|
|||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.github.anuken:ucore:6e2a3ed6e6'
|
compile 'com.github.anuken:ucore:01b71b6dbd'
|
||||||
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||||
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ public class Renderer extends RendererModule{
|
|||||||
|
|
||||||
if(Tmp.r1.setSize(camera.viewportWidth, camera.viewportHeight)
|
if(Tmp.r1.setSize(camera.viewportWidth, camera.viewportHeight)
|
||||||
.setCenter(camera.position.x, camera.position.y)
|
.setCenter(camera.position.x, camera.position.y)
|
||||||
.overlaps(Tmp.r2.setSize(enemy.hitsize).setCenter(enemy.x + enemy.hitoffsetx, enemy.y + enemy.hitoffsety))){
|
.overlaps(enemy.hitbox.getRect(enemy.x, enemy.y))){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@ public class Player extends DestructibleEntity{
|
|||||||
private float speed = 1f;
|
private float speed = 1f;
|
||||||
|
|
||||||
public Player(){
|
public Player(){
|
||||||
hitsize = 5;
|
hitbox.setSize(5);
|
||||||
|
hitboxTile.setSize(4f);
|
||||||
|
|
||||||
maxhealth = 100;
|
maxhealth = 100;
|
||||||
heal();
|
heal();
|
||||||
@ -83,7 +84,7 @@ public class Player extends DestructibleEntity{
|
|||||||
|
|
||||||
vector.limit(speed);
|
vector.limit(speed);
|
||||||
|
|
||||||
move(vector.x*Timers.delta(), vector.y*Timers.delta(), 4);
|
move(vector.x*Timers.delta(), vector.y*Timers.delta());
|
||||||
|
|
||||||
if(!shooting){
|
if(!shooting){
|
||||||
direction.add(vector.scl(Timers.delta()));
|
direction.add(vector.scl(Timers.delta()));
|
||||||
|
@ -43,7 +43,8 @@ public class Enemy extends DestructibleEntity{
|
|||||||
public Enemy(int spawn){
|
public Enemy(int spawn){
|
||||||
this.spawn = spawn;
|
this.spawn = spawn;
|
||||||
|
|
||||||
hitsize = 5;
|
hitbox.setSize(5f);
|
||||||
|
hitboxTile.setSize(4f);
|
||||||
|
|
||||||
maxhealth = 60;
|
maxhealth = 60;
|
||||||
heal();
|
heal();
|
||||||
@ -57,7 +58,7 @@ public class Enemy extends DestructibleEntity{
|
|||||||
Vector2 vec = Pathfind.find(this);
|
Vector2 vec = Pathfind.find(this);
|
||||||
vec.sub(x, y).setLength(speed);
|
vec.sub(x, y).setLength(speed);
|
||||||
|
|
||||||
move(vec.x*Timers.delta(), vec.y*Timers.delta(), Vars.tilesize-4);
|
move(vec.x*Timers.delta(), vec.y*Timers.delta());
|
||||||
|
|
||||||
if(Timers.get(this, 15)){
|
if(Timers.get(this, 15)){
|
||||||
target = World.findTileTarget(x, y, null, range, false);
|
target = World.findTileTarget(x, y, null, range, false);
|
||||||
|
@ -11,9 +11,9 @@ public class RapidEnemy extends Enemy{
|
|||||||
bullet = BulletType.smallfast;
|
bullet = BulletType.smallfast;
|
||||||
rotatespeed = 30f;
|
rotatespeed = 30f;
|
||||||
maxhealth = 260;
|
maxhealth = 260;
|
||||||
hitsize = 8;
|
|
||||||
speed = 0.27f;
|
speed = 0.27f;
|
||||||
heal();
|
heal();
|
||||||
|
hitbox.setSize(8f);
|
||||||
|
|
||||||
range = 70;
|
range = 70;
|
||||||
}
|
}
|
||||||
|
@ -247,10 +247,9 @@ public class World{
|
|||||||
Tmp.r2.setCenter(offset.x + x * Vars.tilesize, offset.y + y * Vars.tilesize);
|
Tmp.r2.setCenter(offset.x + x * Vars.tilesize, offset.y + y * Vars.tilesize);
|
||||||
|
|
||||||
for(SolidEntity e : Entities.getNearby(x * tilesize, y * tilesize, tilesize * 2f)){
|
for(SolidEntity e : Entities.getNearby(x * tilesize, y * tilesize, tilesize * 2f)){
|
||||||
Rectangle.tmp.setSize(e.hitsize);
|
Rectangle rect = e.hitbox.getRect(e.x, e.y);
|
||||||
Rectangle.tmp.setCenter(e.x, e.y);
|
|
||||||
|
|
||||||
if(Tmp.r2.overlaps(Rectangle.tmp)){
|
if(Tmp.r2.overlaps(rect)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user