I am trying to create a tile-based word game using swift, and I need to randomize the letters that show up on the tiles (from A-Z). I have been reading about different ways to do this, but I haven't been able to make it work for a specific variable. I currently have a variable defined:
var availableTiles: [Character]!
Since I have been working on the layouts and interface, I have only manually input letters so far just to make sure they show up properly:
func randomizeAvailableLetter() {
availableTiles = ["X", "B", "F", "H", "K", "V"]
}
As you can see, the letters that show up on the 6 tiles are just hardcoded in, but I need for these letters to be random. What would I replace the hardcoded part with in order to make the letters that show up randomized?
Aucun commentaire:
Enregistrer un commentaire