Developing a Soccer Mobile Game-Part 2

Developing a soccer video game has been more fun that I thought it would be. It has also been harder than I expected. Aside from coding, the part of development that has taken the longest is creating the animations. I have done my best to create several animations that mimic a player movement on the field. As of today, I have created 21 animations and counting.

This month I focused on developing a messaging system for the AI. As the video below shows, the players can now communicate among themselves and be alerted whenever a player is passing the ball.


Implementing a messaging mechanism is crucial for an AI system. One thing to note is that the messages are not carried out by the object itself, but by the current state of the object. Doing so makes improves the robustness of your game. For example, let's say that Player A is dribbling, and player B finds a good open position to receive a pass. Player B can send a message to Player A requesting a pass. The dribbling state determines if it should pass the ball or not. Now imagine that Player A is in an idle state and does not have control of the ball, and by mistake, Player B sends a message to Player A requesting a pass. The Idle state of Player A will completely ignore the request since it has no way how to handle such message. Thus, implementing a messaging system that works directly with the "states" of the object prevents access to null pointers and unforeseen bugs.

Moreover, implementing a State Pattern instead of a simple state machine have been critical. The modularity characteristics of a State Pattern Design makes adding new "states" simple and a clean process. I strongly suggest that if you need to implement a state machine, to implement it using State Design Patterns instead of using the common "switch" statements.

Harold Serrano

Computer Graphics Enthusiast. Currently developing a 3D Game Engine.