Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!

Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I get the (x, y) coords for A colour?  RSS feed

August Korvell
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am trying to get the coordinates for a specificcolour in a picture.

private void loadLevelFromFile() {
try {
this.image =;
this.width = image.getWidth();
this.height = image.getHeight();
tiles = new byte[width * height];

} catch (IOException e) {

private void loadTiles() {
int[] tileColours = this.image.getRGB(0, 0, width, height, null, 0,
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
tileCheck: for (Tile t : Tile.tiles) {
if(t != null && t.getLevelColour() == tileColours[x+y*width]){
this.tiles[x+y*width] = t.getId();
break tileCheck;
I have these functions to get it, but I do not know how I can get them in another class.

I need it to spawn a entity on a spcific colour on my level map.

I hope you can help :)
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!