Skip to content

Overview

So far we have seen how to work with data, structure logic using sequence and control flow statements, organise our code in functions and procedures, and structure data with structs and enums. Though this material we have seen how important it is to be able to break down our code into manageable chunks.

One challenge we are facing in the fly catch game has been the ability to separate out the logic that handles user input and updates the game. This logic needs to update values in the game data. In other parts of the code we have been able to share values using parameters, but in this case we haven’t been able to do this as the parameters receive a copy of the data and any changes we make to it would not affect the values in the calling code.

In this chapter we will see new mechanics that allow us to give access to values declared in our code. Using this feature we can start to set up relationships between entities, and use these ideas to pass parameters that allow the called code to update the value within the passed variable.