19. Movement and AOI Broadcast Across Grids
Published: 2023-09-26 02:12:00

### [Zinx]

[<1.Building Basic Services with Zinx Framework>](https://dev.to/aceld/1building-basic-services-with-zinx-framework-296e)
[<2. Zinx-V0.2 Simple Connection Encapsulation and Binding with Business>](https://dev.to/aceld/2-zinx-v02-simple-connection-encapsulation-and-binding-with-business-4p9g)
[<3.Design and Implementation of the Zinx Framework's Routing Module>](https://dev.to/aceld/3design-and-implementation-of-the-zinx-frameworks-routing-module-583n)
[<4.Zinx Global Configuration>](https://dev.to/aceld/4zinx-global-configuration-3jam)
[<5.Zinx Message Encapsulation Module Design and Implementation>](https://dev.to/aceld/5zinx-message-encapsulation-module-design-and-implementation-3fmc)
[<6.Design and Implementation of Zinx Multi-Router Mode>](https://dev.to/aceld/6design-and-implementation-of-zinx-multi-router-mode-19nn)
[<7. Building Zinx's Read-Write Separation Model>](https://dev.to/aceld/7-building-zinxs-read-write-separation-model-ihj)
[<8.Zinx Message Queue and Task Worker Pool Design and Implementation>](https://dev.to/aceld/8zinx-message-queue-and-task-worker-pool-design-and-implementation-12gl)
[<9. Zinx Connection Management and Property Setting>](https://dev.to/aceld/9-zinx-connection-management-and-property-setting-28ha)

### [Zinx Application - MMO Game Case Study]

[<10. Application Case Study using the Zinx Framework>](https://dev.to/aceld/10-application-case-study-using-the-zinx-framework-3ich)
[<11. MMO Online Game AOI Algorithm>](https://dev.to/aceld/11-mmo-online-game-aoi-algorithm-l7d)
[<12.Data Transmission Protocol: Protocol Buffers>](https://dev.to/aceld/12data-transmission-protocol-protocol-buffers-1jek)
[<13. MMO Game Server Application Protocol>](https://dev.to/aceld/13-mmo-game-server-application-protocol-5adl)
[<14. Building the Project and User Login>](https://dev.to/aceld/14-building-the-project-and-user-login-b7p)
[<15. World Chat System Implementation>](https://dev.to/aceld/157-world-chat-system-implementation-18li)
[<16. Online Location Information Synchronization>](https://dev.to/aceld/16-online-location-information-synchronization-3cp1)
[<17. Moving position and non-crossing grid AOI broadcasting>](https://dev.to/aceld/17-moving-position-and-non-crossing-grid-aoi-broadcasting-4nb9)
[<18. Player Logout>](https://dev.to/aceld/18-player-logout-3eln)
[<19. Movement and AOI Broadcast Across Grids>](https://dev.to/aceld/19-movement-and-aoi-broadcast-across-grids-46fe)


---
### MMO-GAME Source Code

https://github.com/aceld/zinx/tree/master/zinx_app_demo/mmo_game

---

When players are moving within the user interface without logging out, it's possible that for performance reasons, we need to handle the disappearance of players from our local client's view when they move beyond the boundaries of our AOI nine-grid. The specific process for movement and crossing grid boundaries is shown in Figure 19.1.


>  Figure 19.1


![Figure 19.1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7r2m9chh91dtrpet860.jpg)

The process of handling visibility disappearance when crossing grid boundaries may seem complex, but in reality, it is similar to the process used before without grid crossings. The key difference is that, when a player moves, we need to obtain two sets of players: one set belongs to the player's old nine-grid but not the player's new nine-grid (Player Set A), and the other set belongs to the player's new nine-grid but not the player's old nine-grid (Player Set B). Player Set A represents the players who are leaving the current player's field of view, while Player Set B represents the players who are newly entering the current player's field of view.

We can then handle the visibility disappearance process for Player Set A and the visibility appearance process for Player Set B sequentially. Finally, we send the current player's updated position information to all players within the current player's surrounding nine-grid, allowing other players' clients to see that the current player is in motion.

This section serves as an additional exercise and does not provide code explanations. Interested readers can refer to the previously developed processes and work on this task independently.


## Summary

This chapter introduced a practical project application case based on the Zinx framework. Its purpose was to cover all the interfaces of the Zinx framework that were built from scratch in previous chapters. The project case presented in this chapter is an MMO online map-based scenario that serves as a clear example of using Zinx and custom communication message protocols for server communication.

The first half of this chapter primarily covered some fundamental knowledge related to MMO game business, including concepts like the AOI (Area of Interest) point of interest algorithm. The AOI point of interest algorithm is not limited to MMO games; it can be applied to various map-based applications, such as ride-sharing, nearby people, nearby stores, running systems, and more. These algorithms can help identify associated objects within a specific radius. In this case, communication data layer protocols were implemented using the Proto Buffer serialization standard format. Proto Buffer's binary nature provides excellent performance during encoding and decoding, making it suitable for server-side business scenarios with low latency and high-performance requirements. It's also good practice to define communication protocol formats before starting a project, as this alignment allows for parallel development, ensuring that both sides of communication are clear on the details.

The project case in this chapter didn't fully develop a complete MMO game suitable for enterprise production. Instead, it focused on implementing core backend service logic, including functionalities like login, logout, movement synchronization, movement broadcasting, visibility disappearance, and appearance. For readers with a greater interest, this case can serve as a foundation to develop more advanced game systems or reference solutions for further development.

Zinx is not limited to online gaming scenarios; it can be applied to a wide range of service scenarios, such as dynamic configuration, log monitoring, device management, and instant messaging (IM) systems. Zinx essentially serves as a development board, allowing readers to gain a complete understanding of its internal constructs and code writing processes through this book. If readers wish to implement additional features or create a unique framework based on their requirements and preferences, they can easily extend or engage in DIY (Do It Yourself) development on top of the Zinx framework.


---
### MMO-GAME Source Code
https://github.com/aceld/zinx/tree/master/zinx_app_demo/mmo_game

---
### [Zinx]

[<1.Building Basic Services with Zinx Framework>](https://dev.to/aceld/1building-basic-services-with-zinx-framework-296e)
[<2. Zinx-V0.2 Simple Connection Encapsulation and Binding with Business>](https://dev.to/aceld/2-zinx-v02-simple-connection-encapsulation-and-binding-with-business-4p9g)
[<3.Design and Implementation of the Zinx Framework's Routing Module>](https://dev.to/aceld/3design-and-implementation-of-the-zinx-frameworks-routing-module-583n)
[<4.Zinx Global Configuration>](https://dev.to/aceld/4zinx-global-configuration-3jam)
[<5.Zinx Message Encapsulation Module Design and Implementation>](https://dev.to/aceld/5zinx-message-encapsulation-module-design-and-implementation-3fmc)
[<6.Design and Implementation of Zinx Multi-Router Mode>](https://dev.to/aceld/6design-and-implementation-of-zinx-multi-router-mode-19nn)
[<7. Building Zinx's Read-Write Separation Model>](https://dev.to/aceld/7-building-zinxs-read-write-separation-model-ihj)
[<8.Zinx Message Queue and Task Worker Pool Design and Implementation>](https://dev.to/aceld/8zinx-message-queue-and-task-worker-pool-design-and-implementation-12gl)
[<9. Zinx Connection Management and Property Setting>](https://dev.to/aceld/9-zinx-connection-management-and-property-setting-28ha)

### [Zinx Application - MMO Game Case Study]

[<10. Application Case Study using the Zinx Framework>](https://dev.to/aceld/10-application-case-study-using-the-zinx-framework-3ich)
[<11. MMO Online Game AOI Algorithm>](https://dev.to/aceld/11-mmo-online-game-aoi-algorithm-l7d)
[<12.Data Transmission Protocol: Protocol Buffers>](https://dev.to/aceld/12data-transmission-protocol-protocol-buffers-1jek)
[<13. MMO Game Server Application Protocol>](https://dev.to/aceld/13-mmo-game-server-application-protocol-5adl)
[<14. Building the Project and User Login>](https://dev.to/aceld/14-building-the-project-and-user-login-b7p)
[<15. World Chat System Implementation>](https://dev.to/aceld/157-world-chat-system-implementation-18li)
[<16. Online Location Information Synchronization>](https://dev.to/aceld/16-online-location-information-synchronization-3cp1)
[<17. Moving position and non-crossing grid AOI broadcasting>](https://dev.to/aceld/17-moving-position-and-non-crossing-grid-aoi-broadcasting-4nb9)
[<18. Player Logout>](https://dev.to/aceld/18-player-logout-3eln)
[<19. Movement and AOI Broadcast Across Grids>](https://dev.to/aceld/19-movement-and-aoi-broadcast-across-grids-46fe)

---
Author:
discord: https://discord.gg/xQ8Xxfyfcz
zinx:   https://github.com/aceld/zinx
github: https://github.com/aceld
aceld's home: https://yuque.com/aceld