Hey all Constructors. It is time for p2 of the DOL project. In this post I’m going to go over some of the preliminary elements to DOL and some theoretical target structure.
To start with I am using a personal CAPX “template” that I call GameFrameWork. For me this includes features such as
- GYFM Font loader
- DataTables with active data saving to WebStorage
- GUI Panels, Buttons with inspector based functions calls and settings
- Timer Object
- Camera Object
- Loader Screen
- Splash Screen
- Touch & Mouse Input
DOL project isn’t about covering the basics so we are not going to do that. We are going to the next step and moving into building the game and the networking.
Before starting let’s consider some structural elements to DOL. DOL structure and play will be similar to Phantasy Star On-Line. Players join groups to go adventuring, but player computers also rely on a dedicated server to maintain data authority over experience, equipment and such. Right now C2 Multiplayer Plugin only supports a single connection and one channel/room. So at the moment we have limited capability to start. Since there is no authority server right now we are going to start with open access to Scirra signalling server and in the future use Cla.io as our authentication server; unless Scirra changes to multiple connections.
For now we want to start by digging into the tasty new multi-player plugin and get the basics of communications started.
Starting Tools
- Array named as global(don’t pollute the namespace)
- Multi-player plugin…. yum yum
- EventSheet called “networking”
- TextBox for player alias
- Listbox for a ConnectionLog
- buttonGFX(GFW)
- SpriteFont for a label and a word over the login button
- + GameFrameWork(GFW)
First we are going to create a new Event Sheet called “networking” with the root Group Name called “Networking”. I add the TextBox (playerName), SpriteFont (calibri20), button and a 9Patch panel to break the white monotony all added to the MENU_PAGE layout. Visual polishing is a long way off and with that I make no claims at being a good artist (I’m not) or very good at aesthetics.
[I work heavily in OOP design for the purpose of cleaner code and general practice. I don’t like global scope variables and prefer to save those for the objects in the auto-complete. I also tend to name all my LAYOUTS IN UPPER-CASE and my event-sheets in lower-case. Just so it is easier for me to determine the difference of a LAYOUT and sheet on the tab list. ]
Client, Peer, Host, Master Host, Authority
In DOL we need to distinguish five different types of roles in the networking structure.
Client for our definition is any computer connected to centralized server for data. Most computers will be a Client in one form or another.
Peer for our definition is any one player’s computer that is connected to a server and interacts with the game world or other players. Derelict Online Client will act as a Peer program.
Host is a Peer that handles the game logic of board play. Very much like a Peer. Derelict Online Client will also act as a Host program.
Master Host is yet another Client and connects like a Peer. The Master Host however does not have an active presence like the other players with an Avatar. The Master Host handles the special Room logic for interacting with the any one section of the HUB GameWorld. This will be different CAPX programs to cover the different types of activities.
Authority is the server that handles important information such as character storage and generation of items and randomiser for the board play.
As the game develops this definition will be used to keep track of communication and understanding of the current events. Including as to what caproj (DOL player client) and capx (Master Host, Authority) are being covered in the post or section of the post.
Connecting to the Server(DOL-PC)
Before we start you should know that Scirra has great tutorials(concept, chat, realtime) on the Multiplayer Plugin. I suggest reading them and examining both the sample templates.
For now we are going to assume that authentication login/password has passed and players can connect to the game world. So no need for passwords or such items at this time.
In ES-networking we are going to start with Signalling elements. With a standard “On LayoutStart”
Supports multiplayer
Let’s make sure we can support multi-player. If we can or can’t we will log our state in the ConnectionLog.addItem(“”). If the platform cannot support WebRTC we will also disable the Networking group.
On Error
It’s always best to be ready to handle errors. Last time I used the plugin I received a JS error; which is useless in C2. However it is still a thrown error exception and we should log what there is. Also we should log any unique or required activity that we use of the MP plugin so we know what the error relates to.
Start Connection
In my GFW I use OnTouch reference in my button sprite. I have a variable that stores a a string used for function calls. So when a Touch occurs on the object the Function is called. So I have a Function in my es-mainmenu called “menu.login”. This is the default scirra server. We are going to log this to keep what is happing updated.
On Connected
This is the Multi-player plugin call back. This is called when the signalling server returns a successful connection. Either way if this succeeds or fails we will log the result. So we are adding a successful log.
For now we are going to hold our progress here. It’s a good spot because we need to choose which route in development we want to go. This is because everything above is the most basic design that is easily found in the tutorials.
- A. Prototyping. Connecting to other player hosts. This will follow the same steps as the current templates and tutorials follow.
- B. Progressive. Connecting to a room with a Master Host. This will deviate from the already establish tutorials and start diving into more interesting areas.
Regardless the next update is going to take some time. I am going to be super busy for the next few days. Good development Constructors.
One thought on “DOL – Part 2 – Getting started”