Skip to main content
Removed the sentence that wasn't answering the question
Source Link
Panda Pajama
  • 13.5k
  • 4
  • 47
  • 79

If the map is loaded in through pixels, then the tile id's will be in a 2d array, so add something like this to your player class (if you have one, you might do tile-based rpgs completely differently):

public void move(int xs, int ys) {
    xo += xs;
    yo += ys;
    if(Level.tiles[xo / 32][yo / 32] == 6) {
        xo -= xs;
        yo -= ys;
    }

}
      //xs and ys is the speed that the character is travelling at
      //xo and yo is the player position
      //Level.tiles[xo][yo] is the 2d array that stores the id of the tile
      //the move method is the method that sets the player position after the xs/ys values have been set

xs and ys is the speed that the character is travelling at.

xo and yo is the player position

Level.tiles[xo][yo] is the 2d array that stores the id of the tile

the move method is the method that sets the player position after the xs/ys values have been set

If the map is loaded in through pixels, then the tile id's will be in a 2d array, so add something like this to your player class (if you have one, you might do tile-based rpgs completely differently):

public void move(int xs, int ys) {
    xo += xs;
    yo += ys;
    if(Level.tiles[xo / 32][yo / 32] == 6) {
        xo -= xs;
        yo -= ys;
    }

}
      //xs and ys is the speed that the character is travelling at
      //xo and yo is the player position
      //Level.tiles[xo][yo] is the 2d array that stores the id of the tile
      //the move method is the method that sets the player position after the xs/ys values have been set

If the map is loaded in through pixels, then the tile id's will be in a 2d array, so add something like this to your player class (if you have one, you might do tile-based rpgs completely differently):

public void move(int xs, int ys) {
    xo += xs;
    yo += ys;
    if(Level.tiles[xo / 32][yo / 32] == 6) {
        xo -= xs;
        yo -= ys;
    }

}

xs and ys is the speed that the character is travelling at.

xo and yo is the player position

Level.tiles[xo][yo] is the 2d array that stores the id of the tile

the move method is the method that sets the player position after the xs/ys values have been set

Removed the sentence that wasn't answering the question
Source Link

If the map is loaded in through pixels, then the tile id's will be in a 2d array, so add something like this to your player class (if you have one, you might do tile-based rpgs completely differently):

public void move(int xs, int ys) {
    xo += xs;
    yo += ys;
    if(Level.tiles[xo / 32][yo / 32] == 6) {
        xo -= xs;
        yo -= ys;
    }

}
      //xs and ys is the speed that the character is travelling at
      //xo and yo is the player position
      //Level.tiles[xo][yo] is the 2d array that stores the id of the tile
      //the move method is the method that sets the player position after the xs/ys values have been set

Hope this helped! Although... it probably hasn't.... im a beginner at java

If the map is loaded in through pixels, then the tile id's will be in a 2d array, so add something like this to your player class (if you have one, you might do tile-based rpgs completely differently):

public void move(int xs, int ys) {
    xo += xs;
    yo += ys;
    if(Level.tiles[xo / 32][yo / 32] == 6) {
        xo -= xs;
        yo -= ys;
    }

}
      //xs and ys is the speed that the character is travelling at
      //xo and yo is the player position
      //Level.tiles[xo][yo] is the 2d array that stores the id of the tile
      //the move method is the method that sets the player position after the xs/ys values have been set

Hope this helped! Although... it probably hasn't.... im a beginner at java

If the map is loaded in through pixels, then the tile id's will be in a 2d array, so add something like this to your player class (if you have one, you might do tile-based rpgs completely differently):

public void move(int xs, int ys) {
    xo += xs;
    yo += ys;
    if(Level.tiles[xo / 32][yo / 32] == 6) {
        xo -= xs;
        yo -= ys;
    }

}
      //xs and ys is the speed that the character is travelling at
      //xo and yo is the player position
      //Level.tiles[xo][yo] is the 2d array that stores the id of the tile
      //the move method is the method that sets the player position after the xs/ys values have been set
Source Link

If the map is loaded in through pixels, then the tile id's will be in a 2d array, so add something like this to your player class (if you have one, you might do tile-based rpgs completely differently):

public void move(int xs, int ys) {
    xo += xs;
    yo += ys;
    if(Level.tiles[xo / 32][yo / 32] == 6) {
        xo -= xs;
        yo -= ys;
    }

}
      //xs and ys is the speed that the character is travelling at
      //xo and yo is the player position
      //Level.tiles[xo][yo] is the 2d array that stores the id of the tile
      //the move method is the method that sets the player position after the xs/ys values have been set

Hope this helped! Although... it probably hasn't.... im a beginner at java