RampTile.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package me.hammerle.supersnuvi.tiles;
  2. import me.hammerle.supersnuvi.gamelogic.Level;
  3. import me.hammerle.supersnuvi.util.Utils;
  4. public class RampTile extends BaseTile
  5. {
  6. private final float lx1;
  7. private final float ly1;
  8. private final float lx2;
  9. private final float ly2;
  10. public RampTile(float tMinX, float fMinY, float tMaxX, float tMaxY, float x1, float y1, float x2, float y2)
  11. {
  12. super(tMinX, fMinY, tMaxX, tMaxY);
  13. lx1 = x1;
  14. ly1 = y1;
  15. lx2 = x2;
  16. ly2 = y2;
  17. }
  18. @Override
  19. public boolean shouldAiUseCollisionBox(int x, int y, Level l)
  20. {
  21. return false;
  22. }
  23. @Override
  24. public boolean isMoveColliding(float minX, float minY, float maxX, float maxY, int x, int y, Level l)
  25. {
  26. float x1 = Utils.toCoord(x) + lx1;
  27. float y1 = Utils.toCoord(y) + ly1;
  28. float x2 = Utils.toCoord(x) + lx2;
  29. float y2 = Utils.toCoord(y) + ly2;
  30. return Utils.intersect(x1, y1, x2, y2, minX, minY, maxX, minY) ||
  31. Utils.intersect(x1, y1, x2, y2, maxX, minY, maxX, maxY) ||
  32. Utils.intersect(x1, y1, x2, y2, maxX, maxY, minX, maxY) ||
  33. Utils.intersect(x1, y1, x2, y2, minX, maxY, minX, minY);
  34. }
  35. }