Custom WebGL2 ECS Game Engine supporting a Multi-Character 2D MMO
8 months ago, I started a very large project to finalize my CS degree. This project was composed of two parts, a 2D WebGL2 engine following an Entity Component System, and an MMO which utilizes the engine. I'm posting to share my experiences with building the engine, and offer it for developers looking to write games in JavaScript.
This project began in April, with current engine design finishing around September. The game began development in July, and is still ongoing. The engine will continue expansion as the game needs it for now. There's a lot to talk about so I'll break this post into two sections.
Seed Game Engine
The Seed Game Engine was intended to be a game engine to work with an experimental decentralized network written by a friend, but there was an unsolvable security issue. Anyways, the name stuck. The goal of the engine is to let developers create native web games which require no plugins and run fast in the browser. Unfortunately this isn't fully obtainable yet, as WebGL2 is only available in Chrome and Firefox browsers at this time.
The Seed Engine follows a similar pattern to Unity development, but is much more lightweight (fancy way of saying lacking some features). See below for a quick core usage example:
-
Developers may create scenes, and add viewports to them to process rendering.
-
From here, SceneObjects may be added to the scene. SceneObjects start with a single Transform component to represent the SceneObject's location.
-
More components may be added to the SceneObject, where they are managed by the SceneObject.
-
Renderable components register directly with a RenderManager for faster render update calls.
This is a core explanation on how things work, but more features can be found in the documentation or in the code. Unfortunately, there is no collision system in place, as there was no need for one in the MMO. If anyone feels like writing a quad tree send a pull request :D
Do you want to use the Seed Game Engine?
If you are interested in trying out the engine to make a quick web game, you can easily install the engine as a dependancy with npm. Better yet, I have made a boilerplate project to help you jump right in. It includes an html file with a canvas file, and a basic scene and object structure ready for you to build on.
Guilds of Gods MMO
Guilds of Gods (GOG) (screenshot) is an MMO which takes concepts from RuneScape Classic, but aims to take on more of a management style play. I'm talking about the game to express the capabilities of the Engine.
GOG allows the player to unlock and control up to 5 adventurers simultaneously. Each character has their own inventory, stats and equipment, but each share one storage. Construction is a skill intended to take a lot of the workload of the player by allowing semi-autonomous actions. It's in late pre-alpha testing at GuildsOfGods.com right now, looking to move into alpha in the coming few weeks. This will clear test accounts, and will be the only account reset. Check out r/GuildsOfGods if you want to see more about the game and development process.
The game screen is composed of 15 tile layers. 5 to the environment and ground objects, 9 to draw the character body and equipment with animation support, and one to draw health bars and other icons. All tile layers contain 2 textures, one for the sprite sheet, and another one to acquire the ID of the sprite at that location on the layer. If more entities appear on the screen, there is no speed difference.
All text rendering follows the same pattern, using the same shader program to grab columns of letters to build properly spaced glyphs. The result, a lightweight render loop, running the whole game with about 90% idle time on a mid 2014 2.2Ghz i7 Macbook.
Of course, there's still a lot planned for the game.
-
The map is small and has little to tell. There are plans to expand to a much larger map with multiple cities with quests and mini quests.
-
Converting the game to apk and standalone for other platforms. The game is playable on Chrome, Firefox, and Samsung mobile browsers.
-
Expanding content. Adding new tiers of items and specialty items, more engaging enemies, better PvP weapons. Introduce the antagonist, the Emperor.
All game interactions follow an action-step system. Any possible action within the game is tied to an interface which must be active to perform. If the action is successfully triggered, lists of steps first assigned to the action are executed for the enacting entity. Steps can control the flow of the action depending on their assigned outcomes, and actions can execute other actions.
Other Info:
The GitHub Pull Request History are all bulleted lists of what each engine update contained.
A prototype Android app for the GOG core concepts.
If you want to hear more about the thought process which went into early stages of the engine and a GOG prototype, my Steemit page contains posts on these.
Posted Dec 6, 2018, 1:34 AM UTC · edited