0

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.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by tomtetlaw
0

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!

0

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. :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.