Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. private void connection() {
  2. for (int i = 0; i < b.toArray().length; i++) {
  3. if(b.get(i).r.intersects(play.b.get(i).x - 5 ,play.b.get(i).y,20,20) && b.get(i).connected){
  4. b.get(i).connected = true;
  5. }
  6. }
  7. }
  8.  
  9. public abstract class block {
  10.  
  11. public int x,id;
  12. public int y;
  13. protected Image img;
  14. public boolean remove;
  15. public int rotate;
  16. public Rectangle r;
  17.  
  18. protected int bx, by;
  19.  
  20. public static boolean connected = false;
  21.  
  22. public block() {
  23. }
  24.  
  25. public abstract void tick();
  26.  
  27. public abstract void render(Graphics g);
  28.  
  29. public void createCollisionRect() {
  30. r.setBounds(x - (int) play.camx, y - (int) play.camy, 20, 20);
  31. }
  32.  
  33. public class wall extends block {
  34.  
  35. public wall(int x, int y, int rot) {
  36. this.x = x;
  37. this.y = y;
  38. this.rotate = rot;
  39. r = new Rectangle(x - (int) play.camx, y - (int) play.camy, 20, 20);
  40. id = 0;
  41. }
  42.  
  43. public void tick() {
  44. createCollisionRect();
  45.  
  46. if (Comp.mr && r.contains(new Point((Comp.mx), (Comp.my)))) {
  47. remove = true;
  48. }
  49.  
  50.  
  51.  
  52. }
  53.  
  54. public void render(Graphics g) {
  55. ImageIcon i62 = new ImageIcon("res/tiles/wall.png");
  56. img = i62.getImage();
  57. g.drawImage(img, x - (int) play.camx, y - (int) play.camy, null);
  58.  
  59. if(connected){
  60. g.setColor(Color.red);
  61. g.drawRect(x -(int)play.camx, y - play.camy, 20,20);
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement