Game Development Reference
In-Depth Information
scope means that you can now easily access the instance from anywhere, but in do-
ing so it's easy to increase your coupling and reduce the quality of the code. With a
little effort you can work to ensure that you pass the references required to all parts
of your game that need the references. You need to balance the trade-offs and de-
cide if you can live with the code issues that may arise in the future; however, many
games can live with that as games tend to not require a lot of module reuse. For the
purposes of this topic we will use the singleton pattern so that we can focus on the
game code and not waste time.
Now let's take a look at some of the core systems required in a bit more detail, and
determine how we will structure these systems for the sample game.
Refining the input system
One of the first things processed during an update, and one of the most important
systems for interactivity, is the input system. We need a system that allows for mul-
tiple forms of input, from keyboard and mouse to touch and gamepad. But alongside
that we need to be able to extend it to the future chapters when we add in support
for sensors.
Another thing we need to consider is if we want to let the user change the controls
and, if so, whether we want to restrict that to a selection of presets or allow them
to completely reconfigure the control set. The more freedom you provide, the more
effort on your part; however, players will thank you for the option. What you choose
here can also depend on the system you are developing for. If you are just working
with a touch screen you generally don't need to provide configurable input as there
isn't much to change; however, the more buttons that you provide the more players
will want to change their input.
For our game we're going to use an action based input system. Using this system
we define actions that link to the logic of the game, for example, MoveLeft . By
Connecting to these actions are triggers, which define the different ways our input
devices can trigger the action.
Search WWH ::




Custom Search