
Originally Posted by
krazyshank
Why are you guys using images? That's the most inefficient way to do it.
Matching using a unique color to that item is the fastest way to do it, less memory, less looping, less math
each pixel in a image as 3 bytes , image width,height 34*34*3 ==3468
each r,g,b byte for each pixel is added together, each pixel is added to each pixel
thats gives the hash, The highest number it can be is 256*3468 ==887808
then mod the hash to be in a range of 1--2000 //2000 is assumed to be the total items in the game
The point is, there is no need to iterate over every item image in the game checking each pixel to find a match, a quick hash and array index can tell you everything, performance is one hash one index into a array per inventory slot it’s very quick, hashing collision can be resolved easy enough
The colour pallet for the items is small, in most case there are no unique colours to each item.