Login layout
This layout is virtually identical to the previous chat room tutorial login layout. It simply serves to allow the user to enter a username in to a text box. The username is stored in a global variable and used to log in to the signalling server on the next layout.
Game layout
The Game layout has the objects for each player so the actions of other players in the same room can be seen and responded to. The layout also contains a simple chat feature with a text box along the bottom of the screen. Each player is represented by a Peer object with an associated PeerName text object (appearing as a label above them with their name and stats), an AimSpot object (showing where they are aiming with the mouse), and a PeerLaser which appears when they are firing. These objects are all in a container together. This is very useful for being able to have all the objects created and destroyed together, and automatically picked together in events so they act as single unit.
The layout also has three layers: "Game", where the peers appear; "Lasers", where player aim spots and lasers are placed so they always appear above peers; and "Info", where name labels and the log appear above everything else.
The events for this layout deal with everything the previous pong and chat examples did, since it also has a built-in chat room. However on top of that, it also deals with:
- syncing more data and variables
- sending more detailed peer inputs to the host and using input prediction locally
- performing hit testing with lag compensation when host
This is a relatively complex example, with a total of 81 events. We'll begin looking at these events on the next page.