So heres the glitch:
The player runs right through the zombie. Then after a few seconds it responds to the collision. That looks terrible for one, and also you could still shoot after you were obviously dead. It only happens when you walk directly towards the zombie though. Otherwise its quite responsive.
I’m using the slick rectangles along with the slick intersects.
So whats the problem. What am I doing wrong? Is it a bunch of lag?
I don’t know what is making it do this but I do know that it’s not going to work.
Code:
Player:
...
public Rectangle getBounds() {
return new Rectangle((int)x, (int)y, main.getWidth(), main.getHeight());
}
...
Zombie:
...
public void update(int delta) {
collision();
main.update(delta);
if(right) {
x += .13;
}else{
x -= .13;
}
}
public void collision() {
if(getBounds().intersects(p.getBounds())) {
System.exit(0); //This is not final
}
}
public Rectangle getBounds() {
return new Rectangle((int)x, (int)y, main.getWidth(), main.getHeight());
}
...
Edit: And if anyone cares… I’m using Eclipse KEPLER with the Dark UI mod.