示例#1
0
 public static boolean click(float screenX, float screenY) {
   int tile = MapEditorOptions.getSelectedTile();
   if (tile == -1) {
     return true;
   }
   int col = (int) Math.floor(screenX / tileWidth);
   int row = (int) Math.floor(screenY / tileHeight);
   if (col >= 0 && col < map[0].length && row >= 0 && row < map.length)
     map[row][col] = MapEditorOptions.getSelectedTile();
   return true;
 }
示例#2
0
 public static boolean longPress(float x, float y) {
   int tile = MapEditorOptions.getSelectedTile();
   if (tile == -1) {
     return true;
   }
   int col = (int) Math.floor(x / tileWidth);
   int row = (int) Math.floor(y / tileHeight);
   if (col >= 0 && col < map[0].length && row >= 0 && row < map.length) {
     longClicked = true;
     iniRow = row;
     iniCol = col;
   }
   return true;
 }
示例#3
0
 public static void touchUp() {
   longClicked = false;
   if (iniRow != -1 && iniCol != -1 && lastRow != -1 && lastCol != -1) {
     int iRow = Math.min(iniRow, lastRow);
     int iCol = Math.min(iniCol, lastCol);
     int eRow = Math.max(iniRow, lastRow);
     int eCol = Math.max(iniCol, lastCol);
     for (int i = iRow; i <= eRow; ++i) {
       for (int j = iCol; j <= eCol; ++j) {
         map[i][j] = MapEditorOptions.getSelectedTile();
       }
     }
   }
   iniRow = lastRow = iniCol = lastCol = -1;
 }
示例#4
0
 public void render() {
   for (int i = 0; i < map.length; ++i) {
     for (int j = 0; j < map[0].length; ++j) {
       MyGame.batch.draw(tiles[map[i][j]], j * tileWidth, i * tileHeight, tileWidth, tileHeight);
     }
   }
   if (iniRow != -1 && iniCol != -1 && lastRow != -1 && lastCol != -1) {
     int iRow = Math.min(iniRow, lastRow);
     int iCol = Math.min(iniCol, lastCol);
     int eRow = Math.max(iniRow, lastRow);
     int eCol = Math.max(iniCol, lastCol);
     for (int i = iRow; i <= eRow; ++i) {
       for (int j = iCol; j <= eCol; ++j) {
         MyGame.batch.draw(
             tiles[MapEditorOptions.getSelectedTile()],
             j * tileWidth,
             i * tileHeight,
             tileWidth,
             tileHeight);
       }
     }
   }
 }