Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Avatar View

Alexandru Dan edited this page Aug 30, 2017 · 2 revisions

This feature is pending as the pull request #223.

The avatar view represents the custom view of the world for each of the avatars. The main use of this class is that when the view is moved, the game service knows which objects need to be created and which need to be deleted from the scene. Each player would then subscribe to a broadcast channel and listen for updates with its own personalized view.

Say the view is 4x4 cells. Cells 'in view' are marked with a 'V'.

                               |V V V V V|
                               |V V V V V|
                               |V V V V V|
                               |V_V_V_V_V|

Now suppose the user moves east. (C stands for clear and R for reveal)

                            C C C_C_C_C_C C
                            C C|C V V V V|R
                            C C|C V V V V|R
                            C C|C V V V V|R
                            C C|C_V_V_V_V|R
                            C C C C C C C C

This class calculates for every move action the cells to clear and the cells to reveal, and keeps track of the cells in view. This reduces the computations of how to change the view to only what's strictly necessary. Following with the example, after sending the game objects to create/delete in world_state, the new view would be:

                                 _ _ _ _
                               |  V V V V|V
                               |  V V V V|V
                               |  V V V V|V
                               | _V_V_V_V|V

where the original view is delimited by the | and the _.

Clone this wiki locally