Saturday, November 29, 2014

Code Snippet: CPU Usage

Freebie today that is all about CPU (Central Processing Unit) usage. If you are here from BYOND and are familiar with the Server "tick_lag" variable which does the same thing as the CPU class. This snippet is untested on Android devices.

Imports

The CPU class. The OS object is something you will have to code yourself. Simple example to get current CPU usage.

Extending

A feature interested programmers could add is CPU monitoring on a background thread that has a 2 second tick. When the background thread detects the CPU past a certain threshold, like 75.0 then a event is fired alerting any listeners "Hey the CPU is about to explode!". Then you can trigger any optimizations that will lower the CPU usage.

Friday, November 14, 2014

Speak a Different Language?

Not a problem!  Implemented a translation API for anyone who can not read English.

Any dialogue used by NPCs will be translated to make your experience better.

User Interfaces will also be translated.

It can even detect your system's language and use that.  By default it will, just in case, there will be an in-game option to change it.  Will probably have the default language displayed a long with a list of supported languages by their names at start-up for you to select.

Here is a list of supported languages.  Some have letters that won't display they are marked with a *
SPANISH
FRENCH
GERMAN
ALBANIAN
*AZERBAIJANI
CATALAN
CROATIAN
CZECH
DANISH
DUTCH
ESTONIAN
FINNISH
HUNGARIAN
ITALIAN
*LATVIAN
LITHUANIAN
NORWEGIAN
POLISH
PORTUGUESE
*ROMANIAN
SLOVAK
SLOVENIAN
SWEDISH
TURKISH
* These have some letters that aren't displaying

UPDATE: Just wanted to include that I got it worked into the Conversation system.  Snippet below uses French translated from this line "Nice to meet you, my name is Billy Bob Jimmy Joe.  How are you?".
The system is not perfect and some words are not translated but it is small words like using a German translation, for some reason, the word "name" is not translated.  Small bug, not priority.  Translating is not without it's price.  The performance hit in translating text ends up being a few seconds.  Ouch!  So this will have to be masked somehow when the game demo rolls out.

Wednesday, November 12, 2014

Entity/Component System Explanation

What is a Entity and what are Components?  If you don't know what I mean when I blog about that system this post will be very informative to you.

An Entity is a game object that contains a unique id that sets it apart from other entities.  This helps the system identify an entity from other entities.  Entities contain components that are strictly data.  Entities can have as many components as necessary.  Components can be anything, health, stamina, position, velocity are a few examples.  If you wanted an Entity to be able to move you would add the Position and Velocity components to that Entity.  But adding Components is half the work.

Those Components need to have some sort of logic that controls the behavior otherwise they just take up space.  The behavior of those components is determined by a EntityProcessor.  EntityProcessors get the Component from the Entity and perform logic on it.  EntityProcessors only know of their own logic and not that of any other processor. Lets say we had a MovementProcessor to process moving Entities.  The MovementProcessor would grab the Position and Velocity components and perform movement translations on them.  The end result would be that those Entities could move within the game world.  Lets say that you wanted all Entities to come to a halt.  Simply remove or disable the MovementProcessor and then nobody could move.  That simple logic switch would affect all networked entities.  Which brings me to networking.

How does the Entity/Component system interface with networking?  I mentioned before about how Entities contain a unique id to help identify them.  It also helps identify them over the network.  Say I have two players that logged in.  I want them both to get this awesome entity I just made so I send it to them.  They both have that Entity with that id.  Now I have the server perform operations on that Entity and sends that entity id with the updates.  Those players already have that entity id and know which entity the network wants to update so it is a simple matter from there to just locate and update them.  This not only makes the networking approach easier it makes it cleaner as well.  This also applies to databases.  By using the Entity's id as a index, entities can be stored in the database and located very fast.

There are some cons to using this approach.  The more Entities you have with many Components the more memory they are going to take up.  To address this, certain performance optimizations and the use of Object Pooling can alleviate those concerns.  By having a way to store Entities somewhere besides memory you can also remove the memory problem at the expense of performance.  You either sacrifice some performance for memory or vice versa.  That is to be expected in any approach.

That is all I got thanks for reading.

Saturday, November 8, 2014

Got a Graphics Designer

Happily announcing that we have a GD! This means that we can start designing the perspective and programming the actual game itself (significant work has been done on the barebone framework). Don't expect a release date any time soon. This is going to be a remake of SS13 in a different perspective utilizing a more modern programming language. We will be using OpenGL which means we will have access to the GPU and will be able to have actual shaders for different effects.  This also ensures that we will have a graphics backend that is cross platform compatible.  Windows, Mac, Linux is planned with a Android version later down the road.  Have to get the main PC operating systems done first.

A few things to note:
  • Will be pay-to-play based on server cost.
  • Accounts!
  • Most game modes will take place on a big space station
  • Atmospherics will be more realistic, if you open a hole in the station and aren't wearing magnetic boots you will be sucked out at a high velocity, unless you are on a station with working emergency force fields.  That station feature will have to be researched/manufactured and interconnected with the station subsytems, good luck.. 8)
  • Science! Genetics! Engineering!  Eventually Robotics and whatever else we can invent.
  • Monkeys! Ferrets!(jk)  Xenomorphs was SS13's baby.  We will be having a more different form of alien that SS13 players won't be familiar with and will have to adapt to, or die..
  • A lot more that will be done that I won't spoil
The main goal will be to get some graphics out there and stress test my networking code.  It has been the biggest challenge for myself to date.  Very proud with what I have accomplished.  To summarize, an Entity/Component system that is fully network capable and efficient.  The Entity/Component system makes the game objects more dynamic and reusable.  Did I mention I have implemented Entity "templates" that allow me to save a Entity's state to a file and load it whenever?  More on that in a later post.

This remake/improved version will have an eventual release date but want to put emphasis that it won't be for a while.

That networking issue I had in the last post is solved.  Won't be going into detail on that, it would be to lengthy and take away from time from actual work.

I will be posting updates/progress as the months go by.

Link: http://ss14.boards.net/