The graphics ever made my day
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
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.
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
ICQ: 130925152
Email: e.j.folkertsma@student.utwente.nl
ICQ: 130925152Email: e.j.folkertsma@student.utwente.nl
November 15, 2001 10:41 AM
http://www-cs-students.stanford.edu/~amitp/Articles/Hexagon1.html
there are tutorials about it on this site (gamedev.net)... check out the "resources" section, and scroll down it looking for this topic.
--- krez (krezisback@aol.com)
--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement