Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (754) Games in Android Showcase (229) games submitted by our members Games in WIP (842) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Show Posts Pages: [1]
1  Java Game APIs & Engines / Java 2D / Re: How to store vertices positions of a hexgrid in a 2D Array? on: 2011-07-12 12:55:59
mhh here's the solution I found - I wonder if I could cleanup the code a bit and make just 1 loop instead of 2 without the j%2 statement...
The two blocks of code for j%2 change only for Vector c and f respectively the other stayed unchanged - so it it possible to improve it?
xpos = side; and ypos=0.866*side; in this manner I force the grid to be of regular hexagons.

I execute outside the for loops a purgeLines() function to delete lines that share equal start and end points coordinates - so get rid of duplicates.

As Philfrei mentioned the other approach would be to the create a hexagon object itself and then replicate over a grid, and then purge duplicates points at joining hexagons and not at the edge of grid. Never used hashmaps but is something I would really like to harness when Ill get sometime.

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61 `float side = w / (numCols);         particles = new Particle[numCols][numRows][2];         for (int i=0; i

2  Java Game APIs & Engines / Java 2D / Re: How to store vertices positions of a hexgrid in a 2D Array? on: 2011-07-12 00:07:52
Im not sure about what this lines does

 1 `  float y = (i % 2 == 0) ? (i+offsetFraction) * gridSize : i * gridSize;`

what are ? and : for? sorry Im new to programming.
3  Java Game APIs & Engines / Java 2D / Re: How to store vertices positions of a hexgrid in a 2D Array? on: 2011-07-11 18:40:39
Ok Ill show you with one pic the problem I have so maybe you can give more inputs
Now I have a shifted grid which I used for triangles, the code looks like
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17 `float side = 10;for (int i=0; i

Ok I can have unsed points although I was trying to avoid it but it seems I cannot skip with hexagons. So the situation is like in the picture below. Now once I created the grid how do I sort to create the hex tiling as in the picture? I need the indeces of the six verteces to sort all point in my grid...of course at the edge of the grid there will be some unsed (unsorted) points - those within green line in my pic.

Thanks for any help!
 4 Java Game APIs & Engines / Java 2D / Re: How to store vertices positions of a hexgrid in a 2D Array? on: 2011-07-11 17:52:03 no worries. what I would like to do is this-have different basic grid layouts (hex, quad, tria)-able to extract from the created grid every single basic  shape (so its vertices) and store it in a listI will have so different classes each one for each basic shape. For example a triangle class to be instatiated needs 3 points. Im doing this because the starting grid will be deformed according to some rules but topology will remain unchanged and so made up od "deformed" shape. Still later I want to retrieve all "pieces" of the deformed grid. Hope this is clear.Now, for quads, is straightforward, I manaed to do it for triangles...but with hexagons Im really struggling...I read many articles but still stuck. How would you sort the points?
5  Java Game APIs & Engines / Java 2D / How to store vertices positions of a hexgrid in a 2D Array? on: 2011-07-11 15:48:36
Im facing this issue. I want to create an hexgrid and be able to create in this fashion:

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15 `//grid extentsint numCols,numRows;for (int i=0; i

All methods I found to make hexgrid, first create an hex object and then replicate it over a grid thus creating duplicate verteces position ad joining edges. I want to avoid duplicating verteces position. How can I declare statements to make such a grid?

Thanks
 6 Java Game APIs & Engines / Java 2D / Planar tessellation on: 2011-07-03 19:08:10 Hi All,I need to make some planar tessellation for a small project. I need to make rectangular, rhombic (diagonal), triangular and hexagonal grids. The problem I have is that I want to find a method which doesnt duplicate points/edges. In addition, if I have a point list storing vertices of my grid I have to be able to sort that list and extract collections os sub points comprising basic shape of this tessellation - ie. 4 points identifying a square, or 3 points for triangles and 6 points for hex.Can anyone suggest a method to build this geometry easily? Eventually I'd like to implement in different shape classes beloging to the same super shape class.
 7 Discussions / Business and Project Management Discussions / Java tutorials London on: 2011-06-04 17:16:19 I am an architecture student in London and I'd like to have some private tutorials/lessons about Java programming in Eclipse - would be great to have lessons from another student with a  computer science background. I have basic knowledge of Java programming both for 2d/3d graphics (in Processing) but would like to complete a more advanced project and need help especially for developing GUI.Please send me a pvt message for further details
 Pages: [1]
 DesertCoockie (20 views) 2018-05-13 18:23:11 nelsongames (68 views) 2018-04-24 18:15:36 nelsongames (65 views) 2018-04-24 18:14:32 ivj94 (748 views) 2018-03-24 14:47:39 ivj94 (79 views) 2018-03-24 14:46:31 ivj94 (555 views) 2018-03-24 14:43:53 Solater (94 views) 2018-03-17 05:04:08 nelsongames (168 views) 2018-03-05 17:56:34 Gornova (338 views) 2018-03-02 22:15:33 buddyBro (998 views) 2018-02-28 16:59:18
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org