I am trying my hand at android game development. I want to start with a simple 2D board game. What is the best way to draw a game board like the one in the image attacked below. The blue circles are points where the players can place objects.
-
\$\begingroup\$ Do you ask for a technology (canvas, OpenGL...) or a way to store and render it? \$\endgroup\$– BálintCommented Mar 21, 2017 at 7:27
-
\$\begingroup\$ The most optimum way to store and render \$\endgroup\$– Kinley TsheringCommented Mar 21, 2017 at 8:07
1 Answer
You should use a graph.
A graph is a set of connected nodes. In your case each node should have a position (vector), and an ID.
Outside the grapg you should store the connections. E.g. in your gfaph there are 5 nodes with the position (0;0), (0;1), (1;0), (1;1) and (0.5,0.5) and the IDs 0, 1 2, 3, and 4 respectively. Then your connection set would be
0-1, 0-3, 0-4, 1-4, 3-4, 2-1, 2-3, 2-5
Make sure they aren't duplicated.
You take every connection, get each IDs and their corresponding nodes, and using their positions, you draw a line.
-
\$\begingroup\$ [NOTE] Might come handy to some people. To store the connections of nodes, look at adjacency matrix and/or list \$\endgroup\$ Commented Mar 30, 2017 at 12:02