Game Development – Nr.1 | Magic Writer

Background around the game
Magic Writer is a game where you play as a wizard relaxing on a beach when monsters all of a sudden starts attacking from the ocean. The wizard defends the people on the beach by conjuring items and throwing them at the monsters. The player conjures items by typing the items name.

The process of checking for typed items has two steps. There is a list of three active words, these are the words that the player can type to conjure.


Typing words with highlights
First step: We have a string variable (playerInput) which holds what the player has input, we also have a char variable (inputChar) holding the current input key. When the player presses a key the inputChar registers the key and it is time to check if the character fits into the active words. To do this we need to know which index we are checking in each word. We can access the index by taking the size playerInput. Lets say that the player is supposed to type the word ”Panda”. If the player has entered ”Pa” already, the size of the variable playerInput is 2 which will act as the index. So when the player presses a new key, maybe ”n”. A function checks all the active words at letter index 2 if the characters match. Index 2 in the word ”Panda” is ”n”, therefore it is a match. This leaves the word still active for typing, if the characters does not match the word gets deactivated and is not checked in the function next time.

Second step: The second step is drawing the words in the list. We loop through all words and we draw the deactivated ones with a light blue color to show that they are inactive. If the word is active we draw each letter separately in order to get different colors for each letter. So we loop through each active word and for each letter we check if the index of the letter is smaller than the size of the players input, if it is smaller the letters color is green showing that the letter is typed. Else the color is dark blue showing that the word can still be typed. So if the player has entered ”Pa” the size is still 2. This means that the first two letters in the word is drawn green and the rest dark blue.


The reason for the highlighting is for the player to see where in the word the wizard is currently conjuring. This allows the player to see how far he/she has typed and what the next letter is supposed to be.

Example of how the panda scenario will look like.

Featured image

Example of a deactivated word.

Featured image


Lämna en kommentar