How do you make objects solid, so that you can't move into/onto them. I made it in Tiny Tank like this:
It works, but only objects in front. My method to check wether there is an object backwards is the same, only the < are > at the checking for rotation. And all who played Tiny Tank already might have recognized, that sometimes the enemies (and the player, too!) can drive through walls backwards! I have no more idea how I can check on those collisions. And for my new game I need a method that works to all sides of an objects. But how? Any ideas or help?
public boolean objectInFront(Class clss) { Actor a = getOneIntersectingObject(clss); if(a != null) { if((getX()<a.getX()) && (getY() < a.getY())) { if((getRotation()>=0 && getRotation()<=180)||getRotation()>=270) return true; } if((getX()>a.getX()) && (getY() < a.getY())) { if((getRotation()>=0 && getRotation()<=270)) return true; } if((getX()<=a.getX()) && (getY() >= a.getY())) { if((getRotation()<=90 && getRotation()>=0)||(getRotation()>=180)) return true; } if((getX()>a.getX()) && (getY() > a.getY())) { if(getRotation()>=90) return true; } if((getX()<a.getX()) && (getY() == a.getY())) if(((getRotation()>=0)&&getRotation()<=90) || (getRotation()>=270)) return true; if((getX()>a.getX()) && (getY() == a.getY())) if(getRotation()>=90 && getRotation() <= 270) return true; if((getX()==a.getX()) && (getY() < a.getY())) if(getRotation()>=0 && getRotation()<=180) return true; if((getX()==a.getX()) && (getY() > a.getY())) if(getRotation()>=180 && getRotation() <= 359) return true; } return false; }