I am using pygame
I want my program to read an image file that only has black on it and whenever the character moves over a part that has black on it, he stops moving, any ideas on how to get started?
The black image is not to be shown.

Recommended Answers

All 2 Replies

So what you mean is that you have a sort of 'map' saved as an image as either black or white - white being spaces available to move to, and black being blocked sections (obstacles)?

If so, my idea would be to use the Python Imaging Library (PIL) in order to read the RGB or color data of the image and store it. Then, whenever the player moves, compare the location they would then be at to the data from the map image. Disallow the move if it would go into one of the 'black' areas of the map image's data.

There are probably other ways of doing this, but this is what first popped into my mind. Hope it's a good start!

Yeah thanks that exactlly what I meant, I also want another seperate image for the background that has nothing to do with the movement of the player, it's just for show, but I know how to use that. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.