i am trying to make a chess game but when i click on the object it doesnt get selected , i have attached the code of a black pawn , but it is malfunctioning , i cant find the problem
int a; MouseInfo mouse; public void act() { if(((board)getWorld()).blackturn) { if(Greenfoot.mouseClicked(this)) { move(); } } } public void move() { mouse = Greenfoot.getMouseInfo(); if(mouse!=null) { a = Greenfoot.getMouseInfo().getButton(); if(mouse.getY()==getY()-1 && mouse.getX()==getX() && b1==1) { if(!checkblack(mouse.getX(), mouse.getY())) { setLocation(mouse.getX(), mouse.getY()); a=0; //((board)getWorld()).changeTurn(); } } if(getY()-2==4 && mouse.getY()==4 && mouse.getX()==getX() && b1==1) { if(!checkblack(mouse.getX(), mouse.getY())) { setLocation(mouse.getX(), mouse.getY()); a=0; //((board)getWorld()).changeTurn(); } } if(mouse.getX()==getX()+1 || mouse.getX()==getX()-1 && mouse.getY()==getY()-1) { if(checkwhite(mouse.getX(), mouse.getY())) { setLocation(mouse.getX(), mouse.getY()); a=0; killWhite(); //((board)getWorld()).changeTurn(); } } } } public boolean checkblack(int x,int y) { List ab = getWorld().getObjectsAt(x, y, black.class); if(ab!=null) return true; else return false; } public boolean checkwhite(int x,int y) { List ab = getWorld().getObjectsAt(x, y, white.class); if(ab!=null) return true; else return false; } public void killWhite() { List ab = getWorld().getObjectsAt(getX(), getY(), white.class); getWorld().removeObjects(ab); }