The first part of this serie was about the game server itself. It was not much... but hey now we proceed and write our first simple client! For the client we reuse the VisualAppState from the invader game we wrote in the previous article series about entity system. That spares us a lot of work. And kind a proofe that the VisualAppState is something like a design pattern in ES. We can as well reuse the old EntityDataState.
So ok then let's begin.
Ok then let's take the visual state from the previous article serie and add it, as well the basic invader model. Place the model into the assets Models folder like usual. For convenience reason I added the visual system to this blog post as well, so you just can copy paste it.
As well the old entity data app state ...
I did not change any thing I just copy paste it to this article.
With that prepared we can start writting the code for our game client. It looks pretty much the same like the old Main.class we had in the invader example. The only difference is how we instantiate the EntityDataState, we handover a NetworkedEntityData object. This NetworkedEntityData sets up the connection with the game server and couples the entity data with the entity data from the game server.
As well we do add the VisualAppState.
So what exactly is this NetworkedEntityData object? Not a rocket since piece of code, but some new stuff init. So first we give it a name, version, inet address and a port for the connection setup. The version must be the same like the one from the server, else the connection will be refused with an error message.
In very short, it connects to the game server and hands us back an entity data handle we then can use. That's it basically. The System.out.println I added are not really necessary but adds some convenience.
So that's it basically. Start both the server and client in the SDK just right click it and choose "Run File". And that's it so far. I will add another article to make those invaders move around.