For a video game project using tile-mapping, I wrote a script checking that every tile (16x16) in a picture are unique (let's call this picture "tileset").
But I have a problem:
My script seems unable to detect if 2 tiles are equal when there are transparent areas, it even can't detect that 2 empty tiles are equals.
I did the following:
#!/usr/bin/env python from gimpfu import * import pygtk pygtk.require("2.0") import gtk # messBox function, not from me def messBox(message, GTKtype, modal): if modal == 0: flag = gtk.DIALOG_DESTROY_WITH_PARENT else: flag = gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT msgBox = gtk.MessageDialog(None, flag, GTKtype, gtk.BUTTONS_OK, message) ret = msgBox.run() msgBox.destroy() def python_tileChk(calque): msg = "" # retrieve 1st tile to check with the others for x in range(0, calque.width, 16): for y in range(0, calque.height, 16): tile1 = calque.get_pixel_rgn(x,y,16,16)[x : x+16, y : y+16] # retrieve 2nd tile to check with the 1st for a in range(0, calque.width, 16): for b in range(0, calque.height, 16): # discard tile checking with itself if ((x != a) and (y != B)/>): tile2 = calque.get_pixel_rgn(a,b,16,16)[a : a+16, b : b+16] # check if the 2 tiles are equals if(tile1 == tile2): msg = msg + "Warning: Tile(" + str(x) + ", " + str(y) + ") and (" + str(a) + ", " + str(B)/> + ") are equal !" if msg == (""): msg = "All tiles ok" messBox(msg, gtk.MESSAGE_INFO, 1) return
No clue what's wrong here, I'll apreciate any help.
PS: I'm not used to develop with python much, and even less under gimp environment.
This post has been edited by Deedolith: 21 March 2012 - 07:35 PM