well, im almost done with my map editor except for one pretty big thing... i am having problems with drawing on the 2d ArrayList.
i start out by declaring and instantiating the 2d arraylist.
i added a getTile(row,col) and a setTile(row,col,tile) method to make the rest of the code look cleanerprivate ArrayList<ArrayList<Integer>> tileMap; public TileMap(int rows, int columns){ for(int r=0;r<rows;r++){ tileMap.add(new ArrayList<Integer>()); for(int c=0;c<columns;c++) tileMap.get(r).add(-1); }
public void setTile(int row,int col,int number){ if(row>=0 && col>=0 && row<rows && col<columns) tileMap.get(row).set(col,number); } public int getTile(int row,int col){ return tileMap.get(row).get(col); }
then everything gets messed up when it draws. ive been trying very hard to figure it out but am having some difficulty.
public void mouseDragged(MouseEvent e){ if(getTile(e.getY()/tileSet.tileHeight(),e.getX()/tileSet.tileWidth())!=tilePane.getCurrentTile())//if not already currentTile setTile(e.getY()/tileSet.tileHeight(),e.getX()/tileSet.tileWidth(),tilePane.getCurrentTile());//make it currentTile }
the x and y cords are flipped when drawing, but i feel that everything should be working as is.