My First iOS Game: Four Letter Words

My First iOS Game: Four Letter Words

Glen Brunke, June 16, 2024

I think that creating a video game will eventually end up a lot like writing a book. With the advent of AI to help with the coding and graphic design, it will be up to the 'author' to essentially edit and bring the project together. We are still some distance from that eventuality, so even with the use of AI, you still need to know a bit of coding and to be able to use basic design tools to get the result you want. Is it easier now? YES! The use of AI greatly speeds up the process and can even help improve the overall result versus what one person or even a small team could do just a few years ago.

An Experiment: My First iOS Game

As a sort of 'proof of concept', I am going to create my first iOS game. Why a game? I enjoy games, especially strategy and puzzle games, so that's what I'm going to create. Besides...who needs another To-Do List app? I will need to learn how to program in SwiftUI (the language of iOS) and use the XCode IDE to create the game.

Why iOS? I considered started with Andriod since it is more open source, and the tools are free. However, the current US market share of iOS for mobile suggests that if I want people to be able to play my game, I need to go with Apple. I also have an iPhone, and want to be able to play my own game once it's finished, so iOS is the winner.

I am not new to programming; I have a degree in computer science, though the iPhone didn't exist when I graduated. I've created various applications that run on webservers, worked in technology in education, helped a handful of small businesses build their web presence, and have done a fair bit of data analysis using Python. I'm sure there will be lots of challenges, but I'm confident that I will be able to learn Swift and XCode...eventually.

My iOS Journey

I plan to capture the journey of creating this game from zero iOS experience to the launch on the App Store. Below you will find how it went for me.

04-2024

I need to download XCode to a Mac, but my Macbook Air is somewhat dated and doesn't support the minimum requirements. After a bit of research, I opt to buy a new Mac Mini Desktop. The cost is about $500 and I can utilize the same monitor set up that I use for work at home. Once I have it set up, I download XCode and prepare to begin my learning journey.

One of the tricks to learning a new programming language is to first learn how and where to run your code. It's no different with SwiftUI and XCode; you click through the menu to start a new project, it spits out some files and code and with un-trained eyes, it is baffling how it's supposed to work. Off to YouTube University to do a bit of learning...

There's a lot of great content out there, plus using ChatGPT to help with additional code snippets or to help explain errors helps speed up the learning curve. Here are some of the channels that I used the most:

Swiftful Thinking
Hacking With Swift
Code With Chris


05-2024

I've been working with SwiftUI for a little while now and I've managed to learn some of the basics of how Views work and how iOS manages data. It's time to work on the game idea. I'm going to model the game off of a slider puzzle where the object is to complete a picture or put the puzzle into a particular order. The twist that I'm going to make is that the tiles will represent letters that can be formed into words. A 4X4 grid of these tiles will allow the user to create words four letters in length.



The user interface (UI) for this type of game seems pretty straight forward. I need a grid of tiles and the user can tap on a tile to try to move it. If the open space next to the tile that is tapped, then the tile slides into that open space.

I found an open source dictionary file and filtered it for only four-letter words (that sounds like a good name for this game doesn't it?). Now I can compare the tiles to the dictionary to see if a real word has been formed. After playing with this dictionary for a little while, I realize I am missing a key opportunity with this game: education. While one would expect words like 'FISH' and 'YELL' to be formed without much excitement, what about the word 'CUSK' or 'CHID'? What do those words even mean? I need to add definitions to these words, but alas my dictionary doesn't have definitions.

A quick Google search yields this discovery: Free Dictionary API. I can now look up all 2500 words in my dictionary to get their definitions. This seems tediuos, but luckily I know how to use Python and I will create a little dictionary bot to do this dirty work for me. 2500 definitions later, I have my new dictionary complete with definitions. Now when the user makes a word, they can tap on it and the definition will pop up. CUSK by the way is a cod-like fish and CHID is to speak angrily.

06-2024

The game is really coming along. Now my user data is saved with each turn, so if the application crashes or if it's just closed, the user can pick up where they left off. I still need to add a screen to clear all of this data so the user can start over if ever they become stuck or just want to have a fresh start.

I have now implemented a new feature for the game: multiple words and a "collect points" button. Now, if the user forms a word, it won't collect the points and clear the tiles automatically, the user must first press a button to do so. This allows the user to form multiple words on the same board for a chance to earn more points. I'm going to multiply the points by the number of words, so 2 words equals 2 times the points, 3 words, three times the points and so on. Credit to my wife, Jess for this suggestion.

ChatGPT was also kind enough to write a 'Confetti' class for me which displays colorful bits on the screen whenever the user collects points for completing words, a really nice touch.



07-2024

The game is ready for testing now. I deployed a version to TestFlight (Apple's Beta Testing Program) for family and friends. I expect to have a public link available soon, in the meantime, if you're interested in joining the beta group, send me a message and I'll add you (click on Contact above).

Through the testing process, some bugs have been uncovered, so the priority has been to get those fixed. I have also added a TON of words to the dictionary file for the game. It's sometimes tough to decide if a word should be added or not, for example the 'word' DERP. It's definitely used a lot, but is it a real word? I decided that it is.

08-2024

After some additional testing and bug fixing, the game is finally ready for the app store. While it feels like a major milestone, I know that there is still lots of work to do to let people know that the game is available and how it is different than others in the category. You quickly find that nearly every game in the app store is packed full of ads, micro-transactions, or other pay-to-advance tactics that gamers find so frustrating. This game is a one time purchase for 100% of the game, and users should recognize that beforehand.

Try it out yourself: Four Letter Words