Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Non-regular shapes

This topic is 5561 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello My problem is this. I have a game where I use a realistic map split into different countries and I need to check which country the player clicks on. The problem is that these countries aren''t regular shapes and I don''t know how to figure out whick country someone clicks on. As all these countries actually are rectangular objects with transparent pixels i thought that I could just check which countries where clicked and then take the one that didn''t have transparent pixels in it at that coordinate. When I looked at how to implement this in SDL I saw that there was no real way of doing this. So now I wonder if I have missed something or if there is a more intelligent way of doing this. And if this text makes absolutely no sense pleasea say so I and will try to clarify it. /TotteN nilsson.totte@telia.com

Share this post

Link to post
Share on other sites
Store a separate raw map of which pixels are solid and which are transparent.

Don''t try to use your rendering data for things like this, keep it separate.

It''s as simple as an array of bits or bytes in your code that you load a saved version ("selection mask") of the transparency into.

char mask[256][256];
if (mask[mouseX][mouseY]==1)
// solid
// transparent

I''ve used that and variations on many many occasions in the past.

Simon O''Connor
3D Game Programmer &
Microsoft DirectX MVP

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!