5 Simple DOD architecture Part 2 - board and game loop

 

This chapter covers

  • How to finish implementing our DOD architecture in Unity, an OOP engine.
  • How to reduce code complexity by using a single script to run our game loop.
  • How to set up our game scene in Unity to fit our DOD architecture and reduce code complexity.
  • How to implement the game board, where we take in input and visually display the game to the player.
  • How to implement the game loop that controls everything in our game.

In the previous chapter, we covered the engine-agnostic parts of our architecture, the Balance, GameData, and the Logic. In this chapter, we’ll cover the Board and Game, the two final parts of our architecture that turn our game into... well, a game. We’ll use Unity to implement both objects for a few reasons:

  1. It's the most popular game engine.
  2. At its core it's an OOP engine, so it serves as a great example of how to shoehorn our DOD architecture into an OOP environment.

Let’s take a look at our complete DOD architecture.

5.1 DOD architecture, continued

In Chapter 4 we showed how Game and Board fit into our architecture, as shown in Figure 5.1.

5.1.1 Game

 
 
 

5.1.2 Board

 

5.1.3 Scene hierarchy

 
 

5.1.4 Unity scenes and code complexity

 

5.2 The Board implementation

 
 
 

5.2.1 Init()

 
 

5.2.2 Show()

 
 
 
 

5.2.3 Hide()

 
 
 

5.2.4 Tick()

 
 

5.2.5 handleInput()

 
 
 
 

5.3 The Game loop implementation

 

5.3.1 Start()

 
 
 

5.3.2 StartGame()

 
 
 

5.3.3 Update()

 
 

5.3.4 GameOver()

 
 
 

5.4 Conclusion

 

5.5 Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest