Archived

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

The graphics ever made my day

This topic is 5870 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

It''s been a time since trying myself in putting up some code for a game, but whenever it came to graphic questions I had to give up. Now what I had especially problems with was this: Assume working on a simple 2D strategy game that will be based on hexfields. Leave out thoughts about AI coding as it would make things too complicated for an effort to simply convert an existing boardgame into a replayable (saveable) computer version. You got your ideas on data structures but how would you query this darn hex fields? How can the mouse ''know'' which field was just clicked? Once the field would be identified the rest would be quite easy (I think...). Me and my friend tried to think of it, we argued about making up an algorithm in order to check mouse coordinates with the hexes borders - I could imagine quite this would be quite easy for squares, but breaking up the hexes into triangles and computing their borders in order to check if mouse(x,y) was beyond or not was the only way I could imagine it to be done. I''m not very well in math - all I could contribute is my experience from school''s geometry. Maybe one of you knows a hint or an easier way to solve this problem? Thomas

Share this post


Link to post
Share on other sites
I can''t think of an easy way to do it either, but why do you need to use the mouse? There may be easier methods. you could use the keyboard arrows or type in the co-ordinate and sector that you want. As for using the mouse i can''t think of any way but a complex algorithm.

Share this post


Link to post
Share on other sites
I think there is an easier solution to the problem... remember that each HEX tile is bounded by a rectangle... use that rectangle to determine which 5 tiles are possibly clicked... then convert the global mouse coordinates to local coordinates en then that those local coordinates against a blueprint of a HEX tile (maybe boolean values or the like) then you quickly know which tile the user clicked exactly

ICQ: 130925152
Email: e.j.folkertsma@student.utwente.nl

Share this post


Link to post
Share on other sites