Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to make a game which involves drawing a map. I drew out such a map, with coordinates, in a pixel art program:

enter image description here

Now I would like to get all the coordinate points of the black squares. I would like to manually redraw the black squares into a program somewhere that will spit back out a list of all their coordinates.

share|improve this question
    
The pixel positions are the coordinates, aren't they? Are you asking how to load a map from an image file? –  Sean Middleditch Oct 23 '13 at 23:13
    
No, I'm asking if there's some program where I can draw a bunch of points, and then have a list of coordinates printed out. I don't want to look at the map and have to count the location of each black square. –  slimetree Oct 23 '13 at 23:18

1 Answer 1

You can write a script or simple program by loading up the image (using PyImage or SDL or the like), loop over all pixels in the image, and print out those which are black (or any other color requested).

Something like this pseudo-code:

main(path, color):
 image = LoadImage(path)
 for y in 0 to image.height:
   for x in 0 to image.width:
     if image.GetPixelAt(x, y) == color:
       print x, y
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.