Getting a grid with cell properties to work.
Hi guys. I'm 26 and starting to learn OOP and Java. The best way to motivate myself is writing a simple game with the concepts i'm learning. Of course, there is a lot to rewrite every time i learn something radically better than i used, but that does not fade out the fun factor.
Now i'm struggling with a hexgrid. I made a Class "Cell" and a subclass of JPanel Grid which renders an array of cells.
Cell has certain properties such as axis coordinates, (X;Y), terrain type and according to the terrain type, gets a different Color.
Grid is basically the graphical instructions to render it and include it into a JFrame. Has the method paintComponents.
Now, what i want to do in some days is to click over a cell and get it's property, such as X,Y and terrain type. Now, i should try to make an Array of JPanels (making every Cell a JPanel extension) or rendering all the cells inside a JPanel (Grid) will be just fine and if i add to the class Cell a getMouseClick (or something) will detect that the cell was actually clicked?