- Home /
Creating a grid for word-puzzle game?
Which would be the best way to create a grid like that? I am a programmer but I'm not very experienced with game-programming.
Each cell would need to store a letter value, which would be randomly generated! Any ideas? This is what I had in mind, but I couldn't even show it on screen! Code: http://pastebin.com/JbmTDaax
Thanks in advance!
Answer by Salmjak · Nov 28, 2014 at 07:32 PM
Why do you use a Vector3 instead of a vector2?
Couldn't you just use a two dimensional array like string[x, y] for positioning and let the string be the letter to draw? Then loop through string[x, y] like you currently do and have and have an array string[] for the alphabet. Then you just do something like Random.Range(0, string[].count) and assign it to string[x, y]?
Also, when drawing the GUI.Box, use the x,y-coordinates from string[x,y] to determine position (top, left) and with the text string[x,y]?
Hello Salmjak! You are totally right and, based on your speech, I changed a few things and re-thought the game's structure to better suit my idea. I made an array of GameObjects and made sure to loop them, creating a whole grid. Thank you very much for your time and comment! :)