Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void connection() {
- for (int i = 0; i < b.toArray().length; i++) {
- if(b.get(i).r.intersects(play.b.get(i).x - 5 ,play.b.get(i).y,20,20) && b.get(i).connected){
- b.get(i).connected = true;
- }
- }
- }
- public abstract class block {
- public int x,id;
- public int y;
- protected Image img;
- public boolean remove;
- public int rotate;
- public Rectangle r;
- protected int bx, by;
- public static boolean connected = false;
- public block() {
- }
- public abstract void tick();
- public abstract void render(Graphics g);
- public void createCollisionRect() {
- r.setBounds(x - (int) play.camx, y - (int) play.camy, 20, 20);
- }
- public class wall extends block {
- public wall(int x, int y, int rot) {
- this.x = x;
- this.y = y;
- this.rotate = rot;
- r = new Rectangle(x - (int) play.camx, y - (int) play.camy, 20, 20);
- id = 0;
- }
- public void tick() {
- createCollisionRect();
- if (Comp.mr && r.contains(new Point((Comp.mx), (Comp.my)))) {
- remove = true;
- }
- }
- public void render(Graphics g) {
- ImageIcon i62 = new ImageIcon("res/tiles/wall.png");
- img = i62.getImage();
- g.drawImage(img, x - (int) play.camx, y - (int) play.camy, null);
- if(connected){
- g.setColor(Color.red);
- g.drawRect(x -(int)play.camx, y - play.camy, 20,20);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement