How do I implement a group of strings that starts randomly, but is bound by relevance upon selection?

Posted by Freakishly on Stack Overflow See other posts from Stack Overflow or by Freakishly
Published on 2011-01-08T22:46:58Z Indexed on 2011/01/08 22:54 UTC
Read the original article Hit count: 223

Okay the title may be a little confusing, but here's what I'm trying to do :) I have a game in XNA where every tap from the user draws a moving circle on the screen. The circle has a tag, say 'dogs' displayed on it. So imagine multiple taps on the screen, and we have all these circles of various colors and sizes moving around the screen with different (but constant) velocities. Each circle with different tags: 'dogs', 'cats' and so on...

Clicking on empty space generates a new circle at that point. Clicking on one of the circles "selects" it, turning it into a greeen shade and slowing its velocity down to a fraction of what it was. Clicking on it again "unselects" it, and restores its original color and velocity (trajectory does not change).

With each circle comes a tag, and as of now I'm populating these tags randomly from a string array (which means there's a chance tags will repeat). I would like the tags for newly created circles to be relevant to previous "selected" tags. So when I click on 'dogs', I would like 'German Shepherd' but I would also like 'dog parks' and 'lemurs' assuming dogs get along well with lemurs.

What would be the best way to approach this problem. In my head I have a massive many-to-many mapping, but I can't seem to translate it to code. Thanks for looking.


FYI I'm using the sample project from here: http://mobile.tutsplus.com/tutorials/windows/introduction-to-xna-on-windows-phone-7/

© Stack Overflow or respective owner

Related posts about string

Related posts about string-manipulation