Public Group

#### Archived

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

# The graphics ever made my day

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

## 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 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 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 on other sites
http://www-cs-students.stanford.edu/~amitp/Articles/Hexagon1.html

##### Share on other sites
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)

##### Share on other sites
I''m getting already in the mood to begin work on this project again!
Thanks I got valuable hints here!

Thomas

1. 1
2. 2
Rutin
22
3. 3
4. 4
5. 5
frob
12

• 17
• 9
• 31
• 16
• 9
• ### Forum Statistics

• Total Topics
632615
• Total Posts
3007441

×