- Home /
Crossword game - How to start a word on a random location of players choice
Hello,
I am working on beginners type of crossword game. The problem I encountered is that this crossword game will not follow the normal pre-defined pattern as normal crossword games. The player must be able to randomly select the start point on the crossword grid. I know this sounds strange but that is the way I need to design this particular game. I have tried numerous ways with my lack of knowledge but can not find a workable way. First the player will get a question. The answer to this question say is "work". He/she then need to select the start point(random) on the grid for the length of the word, in this case 4 letters(4 blocks). Color them say yellow. When the player then click a button to confirm the word it should place the 4 letter word in the 4 yellow selected blocks. If yo can please advice or give me directions on how to achieve this part then I can continue with the development. Thanks in advance Regards
It is a bit unclear how you would like it to work, what are the specific requirements. For example, can the player place the word anywhere where there are 4 free cells, or does the length of the free cells need to match the length of the word?
But based on what I've understood, one way to achieve this is to use InputFields
. You can place a number of them in the shape of your crossword puzzle, set them non-interactable (also changing their tinting) and limit the number of characters to 1, then create script that changes the color of the Image
component on them to yellow when selected. This would be the first step in what you want to achieve.
Some example code:
public class CellSelect : $$anonymous$$onoBehaviour {
private Image backgroundImage;
private bool isSelected;
private void Awake () {
backgroundImage = GetComponent<Image>();
}
public void SetSelected (bool value) {
isSelected = value;
backgroundImage.color = isSelected ? Color.yellow : Color.white;
}
}
This would be called from the script that handles the user clicking on a crossword cell, the script being on the same game object as the InputField
.
You say, the player selects a start point. All the cells for all letters are marked. How do you get the direction? How are the fields positioned? Like a chess board? Are there fields that cannot be filled?
Your answer
Follow this Question
Related Questions
Placing trees randomly across a large terrain 1 Answer
How do I optimize size of my unity word puzzle game? 3 Answers
how to have object fall using random speed 0 Answers
Find tagged children within a specific, dynamically loaded in Prefab gameObject 0 Answers
Random String from list of string without repeated letters 2 Answers