TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Hangman game

Forums > Swift

I have looked at different ways to work with character, but I am stuck on this question, can you please guide me? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .............................................

The challenge is this: make a hangman game using UIKit. As a reminder, this means choosing a random word from a list of possibilities, but presenting it to the user as a series of underscores. So, if your word was “RHYTHM” the user would see “??????”.

The user can then guess letters one at a time: if they guess a letter that it’s in the word, e.g. H, it gets revealed to make “?H??H?”; if they guess an incorrect letter, they inch closer to death. If they seven incorrect answers they lose, but if they manage to spell the full word before that they win.

3      

This is a difficult question to answer without knowing how you are attempting to approach the problem, as it could be done in a number of different ways.

In my project, I decided to make a sort of custom keyboard for the user to select letters with. It's basically just an array of buttons displayed on the screen, one for each letter of the alphabet. This is not a requirement for the project, so the way that I did it may be different from the way that you are attempting to do it.

To start, maybe you should think about (or tell us) how you would like the user to be able to select letters. From there, you can start to form ideas of how the selected letters can be stored, and used to replace the _ or ? in the hidden word.

3      

I used string character.

There are shortcomings in working with index value. Where can I find a complete tutorial for working with index value?

I searched the internet but couldn't find the whole topic

3      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.