Website URL

Twitter

Skype

Location

Interests

List of tutorials:
Hello, Playground! - Introduction to Oxygen Playground with Live Experiments services used to learn easly about Oxygen engine
Simple entity movement - Introduction to input interactions and prefab instantiation, also nested entities tree
Advanced yet easy to use input handling with InputHandler component
Simple UI and multiple scenes
----------
Hi!
Today i'll start series of tutorials about making games with Oxygen Core game engine. Especially for that series i've created Oxygen Playground and Embeddable Oxygen Live Experiments services to easly create and store tutorials (feel free to play with it :D).
What is Oxygen Ecosystem? It's a bunch of tools and services that helps making games with Oxygen Core game engine.
What is Oxygen Core? It's an ECS (Entity-Component-System) game engine based on concept that your scene is a tree of actors (entities) that may have some behaviour (component) that will make him HIM (think of it as: entity is naked and stupid until you attach some components to it). It's goal is to focus on very rapid prototyping so making games with it is fast. You can check it out on Github: https://github.com/PsichiX/Oxygen (it's a NPM module used with webpack or any other bundler, but minified script bundle is also possible to use). Anyway, I want to stop talking about engine all tech stuff and reveal them one by one in every tutorial.
Okey, so first i'll show you what you'll have learn today:
Playground project: http://oxygen.experiments.psichix.io/p/BkbVmOdNz
Live experiment: http://oxygen.experiments.psichix.io/BkbVmOdNz (btw. Is there a way to embed this in post? it's embeddable view of live experiments so works like movies on websites)
Launch Playground project and first what you'll see is code editor on the left and live preview with console on the right. Okey, so already opened code file is your index.js file, which is your game entry point.
// import engine related stuff to initialize it further.
import { lazyInitialization, System, vec4 } from 'oxygen-core';
// import component so we can register it in engine.
import SomeController from './SomeController';
// effortlessly initialize Oxygen engine systems.
lazyInitialization({
// renderer will use canvas with id 'playground-screen'.
render: { screen: 'playground-screen' },
// game data will be stored under 'playground' id.
store: { id: 'playground' },
asset: {
// in prior to be able to use playground project assets, we have to use it's fetch engine.
fetchEngine: PLAYGROUND.fetchEngine,
// we don't want to cache any assets fetched into our game.
fetchOptions: { cache: 'no-store' }
}
});
// get instances of already registered engine systems.
const {
AssetSystem,
RenderSystem,
EntitySystem
} = System.systems;
// register component used by animated node (WebGL logo with 'hello' text).
// if we do not register this component, game will crash when some node will try to use it.
EntitySystem.registerComponent('SomeController', SomeController.factory);
// change renderer clear color to dark gray.
vec4.set(RenderSystem.clearColor, 0.25, 0.25, 0.25, 1);
// here we make kick-start of our game:
// - load first JSON asset with game config and list of used assets.
// - asynchronously load all assets from config list.
// - trigger event that will load and initialize scene from 'game.json' asset
// (scenes and prefabs are just JSON files that describes entities tree).
AssetSystem.load('json://config.json')
.then(configAsset => AssetSystem.loadAll(configAsset.data.assets))
.then(() => System.events.triggerLater(
'change-scene',
'scene://game.json'
));
This file, created once is mostly never changed because it's just a bootstrap code to kick-start your game.
Next click on application menu (upper left icon before title) and you'll see list of project files. Here you can open editable files or create new and delete old, also download them (but if you want to download whole project just click upper right EXPORT button and zipped project will land on your HDD). If you're curious what the rest of buttons are: RUN reloads live preview to see your changes. SAVE makes sure that your changes aren't lost and SHARE will show you a bunch of links you can use to share your project/changes with other devs (SHARE works only if you previously save project).
Okey, so what actually makes our logo and text scaling up and down? It's entity that uses SomeController component and that component makes scaling animation like that:
import { Script } from 'oxygen-core';
// create component class that extends engine Script component (extending Script
// component is a base logic component so it will save us from writing a lot of code).
export default class SomeController extends Script {
// propsTypes it's a place that you may want to describe serializable properties.
static get propsTypes() {
return {
speed: 'number' // commonly used types: number, string, any.
};
}
// this static method will be registered into EntitySystem
// and it must return new instance of requested component.
static factory() {
return new SomeController();
}
// it's good practice to initialize all instance properties in constructor.
constructor() {
super();
this.speed = 1;
this._phase = 0;
}
// onUpdate() is called on every update tick, here you put your component logic.
onUpdate(deltaTime) {
// get your instance entity.
const { entity } = this;
// move animation phase by delta time multiplied by animation speed.
this._phase += deltaTime * 0.01 * this.speed;
// calculate animated scale from animation phase.
const v = 1 + 0.5 * Math.sin(this._phase);
// apply new scale to entity.
// NOTE: in most HTML5 game engines you'll encounter few scenarios:
// - different entity types are just extension of base entity/node/actor;
// - there are no entities and components - everything is a node;
// Oxygen loves separation of entity from it's logic and prefer to make logic
// as components/behaviours attached into entity so given logic may be used
// by many entity types, not only one.
entity.setScale(v, v);
}
}
And the question you may ask right now: ok, but where is our scene tree, if it's not present in any of code above? Let's see! Open files list and click on game.json file to open it in editor.
{
"name": "root",
"components": {
"Camera2D": {
"zoomOut": 600,
"zoomMode": "keep-aspect"
},
"Sprite": {
"shader": "sprite-transparent.json",
"width": 300,
"height": 125,
"xOffset": 150,
"yOffset": 135,
"overrideBaseTexture": "logo.png"
},
"TextRenderer": {
"shader": "text-outline-transparent.json",
"font": "verdana.fnt",
"halign": "center",
"valign": "top",
"color": [1, 1, 1, 1],
"colorOutline": [0, 0, 0, 1],
"text": "Hello, Oxygen!"
},
"SomeController": {
"speed": 0.1
}
}
}
This is single entity (root) scene tree, those are mostly called "prefabs" because their simplicity makes them good for instancing complex actors on scene, but here we pretend that our logo prefab is just a scene.
As you may see above, there is entity named "root" that have 4 components: Camera2D to view our scene (actually to view this entity and it's children, so it's a good practice to keep cameras in root entities), Sprite to render WebGL logo with sprite transparent shader and logo texture, TextRenderer to draw "hello" text from bitmap font with outlined text shader, and SomeController that animates our entity with given speed - as you can see, every component do it's specified job! Generally scene and prefab JSON files are the place to balance your game, and code should be only the place where you put some logic and configure it with properties in scene/prefab asset.
Okey, so this is all for the first tutorial - feel free to change some values of components in game.json file and click RUN (or press ctrl+enter) to see what changed
And like always: i'll be very thankful for your opinion about what i did good or bad
Next tutorial: Simple entity movement

Ohayo! Description:
Currently in my free time i'm working on crysis-like 2D shooter game prototype about aliens invasion (events between Crysis 2 and Crysis 3) and specialy trained humans in new version of nanosuit (less power of Prophet suit but more soldiers gets it). It will be multiplayer arena shooter, but for now i'm focusing on singleplayer training mission gameplay, and after i complete with fixing prototype with players feedback i'll start working on the core of the game which is multiplayer arena part.
Game works smoothly on Google Chrome (game optimisation for Firefox is on future todo list) and was designed for gamepads (PlayStation and Xbox), but you can play with mouse and keyboard too. Right now aliens are very strong so gameplay is focused on tactics and hide&seek more than just running around and shooting everything you see ;P
It runs on mobile too but there is no virtual controls (it's on future todo list) so don't ask me for it now
Right now i'm asking you guys to tell me how does controls feels and how much time you had to play to destroy all 4 alien bases (big green dots on minimap, you can kill them only with 2 grenade shots per base :P). Play Online (please, use Chrome): http://soulhunter.psichix.io Tech used:
- Oxygen Core (my html5 game engine toolset based on best Unity and Godot concepts mixed with latest best html5 apis);
- ES7 with babel transpiler;
- Webpack for game bundling and live development;
I don't know what i should say more about techs, because everything that is there, it is those 3 things If you're interrested in something more about tech, and i will be happy to tell everything you ask
------
BTW. I want to publish topic/article about game engine used here - which subforum should i use to place that kind of topic?