Hello, my name is
Alexander Zelenin and I am a web developer. For the past six months, he has been developing a multiplayer space browser strategy. At the moment, we are already at the stage of closed beta testing (available for those who have invested) and have launched the company on a bumstarter.

In this post I want to tell about the process of developing a game from scratch by two people.
')
Table of contents
- Prerequisites
- Choosing a platform and interaction tools
- Start of development
- Resource balance
- Military balance
- Upload to live servers and update
- 5 months later
- Technical part
- Answers on questions
- Total
Prerequisites
After the new year I was in search of an interesting project. In my free time I was reading joyreactor, and came across an interesting game that one guy spent with the audience of the entire site, under the nickname AlanWake. The game was a comic with options for development, for which visitors voted + their options in the comments. The winning version was developed. After a couple of issues, "fan" versions of this universe appeared, and in the end everything went out of control. By the seventh issue, the author himself was confused about what was happening, because there was no control, and the fans wanted the additional stories to be taken into account as well.
In the eighth edition of "The channel is closed."
For just a couple of weeks, the game has collected more than four thousand subscribers. I wrote to the author with a proposal to develop a full-fledged game and see what will come of it.
Choosing a platform and interaction tools
We had a choice: a browser, a mobile application, Steam (or any other platform) game.
After weighing all the pros and cons, the choice fell on the browser version: it works on most devices about the same, then the game can be converted into an application (both mobile and desktop), and a minimum number of actions are required to start the game.
As a tool for interaction with each other, we chose
realtimeboard - an online board on which you can write text, post pictures, draw and conveniently connect all this with each other. Files are synchronized through the folder in the
dropbox .
The game began to gain structure.

We quickly decided on the requirements and format of the game.
We discussed a lot of similar games, trying to highlight the best, removing unpleasant moments.
Requirements:
- This is a PvE game.
- The game is cyclical (cycle about a year). During this time, players either win or lose (all)
- The game should go smoothly, that would be time to draw comics between events.
- The game should not require constant presence and raising the alarm clock, while providing content to those who want more.
- Donations should not significantly affect the gameplay, decorative priority
- Additional accounts do not give advantages
- The game should like ourselves
Start of development
For a couple of days, a prototype was made for a
node with
bootstrap , in which there was an opportunity to register, build mines and enjoy the influx of resources. When it became clear that we were moving in the right direction, I decided that I would develop everything on a new meteor for me (as it turned out later, for good reason), arguing that even if there are problems with the game, then at least there will be good knowledge of new technology.
He unfolded his work environment, set a meteor and began writing.
I immediately liked the meteor:
- Sweep one team
- Many ready-made libraries are easier to connect than ever (in other words, the node is not very difficult)
- Automatic updating of pages when content changes (even images)
- Byutifier / charcoal code, depending on the environment
- Debugging funds
- The ability to write to the database from the browser console (disabled for production)
- Breaking the code into Client, Server and General.
- "Reactivity". Instant display of changes in the database for all clients.
I did not like the last at first, because I prefer more control, but as it turned out, I just did not finish reading the documentation, and everything is fine tuned.
Of the minuses I can only note its impossibility of working with ring links. You can, of course, say that any task can be solved without them ... yes, you can. But this is exactly the same as saying that goto is always bad (for most programmers it is bad, because they do not know how to use, yes. It was already in a number of articles here.).
Resource balance
After some time, it's time to calculate the balance. With the "term" of the game, we decided immediately, so that this time was taken as a basis. Maximum in a year the user should already have “everything”. In principle, the cap can be achieved much faster, but in general, the calculation was for ordinary users.
To calculate the cost of buildings, they were written out in a table, they were given the maximum level of the value “from the bald”. Wrote a simple exponential formula for calculating production. There were wishes on the initial and final (at the last level) production - they were taken simply from the head, as “comfortable” numbers.

After everything was entered into the table at least in some form, I began to select coefficients for cost and production, depending on how the prices and construction time (from the first to the last level) change, selecting approximately so that they require about 4 months, regardless of other factors.
As soon as the coefficients were selected, the expected development schedule was obtained. A little more twisted prices, the formula and you can implement!
I immediately tried to lay the opportunity to vary the balance, depending on the tests, i.e. increase / decrease the number of levels affecting the "smooth" development, while maintaining the initial and final values.
We have three main resources (people, metal, crystal), and two additional (honor, dirty galactic credits). Depending on the stage of the game, there is a shortage of certain resources (except for credits), but if you plan everything correctly (which some of our testers have managed), you can develop with almost no downtime.
Military balance
Our battles are divided into two types: ground and space.
In the land directly can not participate - this is a direct storyline. Troops can be sent to Earth, they join the united army of all players. The movements of this army are controlled by daily surveys of the entire server.
At the moment there are 10 types of units on each side. Each unit has attack, defense, attack priorities, and special characteristics (attacks / does not attack aerial targets, trigger abilities, etc.). For successful operations, at least minimal coordination of the server players is necessary in order to send reinforcements necessary for the next battles, depending on the type of point and the types of opponents.
Space, on the contrary, are individual for each player.
At the moment there are 4 types of ships + flagship, as well as a merchant ship.
The balance was calculated in a similar way. Those. the cost was taken as a basis, and supplied with its characteristics, adding bonuses.
Also in space did the separation of the missions. You can choose the type and level of the mission, see the approximate number of troops (as in the third heroes) and in the battle.
Oh yes. How to solve the issue of rising on an alarm clock to save the fleet? Easy. Make it so that the player’s fleet is somehow the End, and, of course, enter it into the gameplay.
Upload to live servers and update
After creating the settings file for
Meteor Up, uploading an update is just 1 command:
mup deploy
Everything. The meteor itself is loaded onto the production, updates the files, starts the necessary number of processes, restarts itself if it crashes and updates everything on the clients.
5 months later
The game is already possible to play more or less. Buildings are being built, resources are dripping, tasks are being issued, fleets are flying, an army is being built. It's time to make a statement.
It was decided to launch as a start on a boomstarter, since the audience is initially exclusively Russian speaking. A couple of weeks preparing, riveted the roller on his knee and run.

The first two days is a post about news for key audiences - a “conversion” of 1 to 5. That is, every 5 visitors to the page on the boomstarter made a contribution.
Further interesting, but, in principle, expected. Publications on various news resources, in game public, etc. - conversion is close to zero. Those. the main effect was from a prepared audience. From the rest - almost none.
A splash in five days - the release of the next comic book on the reactor.

On the current day 365 registered users. Online, on average, is kept in the region of 75-150 people.

Download exceeds 5% only at the time of the update. High jumps in consumption and response time - updating the game, is equivalent to pressing F5 all at once with resetting the cache. According to preliminary calculations, the server should be able to withstand up to 5,000 people online without failures, provided that the updates will fall on a small online.
Just yesterday, as a result of a crash, processes fell within a second and rose again, the load increased to 50%, but it did not affect the game itself, except for an empty list of participants in the chat. Those. even in a critical situation, the system is fairly stable.
Now the working board looks like this, and content management is becoming increasingly difficult.

By the way, this large part on the right is edits and suggestions from users. Although it is probably not correct to compare, because we did not place texts and descriptions on the board, but still.
Technical part
In meteor, code separation is very convenient: the client part (client), the common part (lib) and the server part (server). The common part is available in both parts of the project equally, which allows you to put into it all the main objects of the game, which are required both there and there.

CSS
For styles, I use
Stylus because I like it a lot. Firstly, it has a nice syntax, from which everything unnecessary has been removed, and secondly, it is going to css on the node, without any additional languages. Well, the finished module rebuilds and loads styles on the page on the fly. Styles are divided into relevant files, but the most "bold" main, from it is not all separated - the time for refactoring will come.
HTML
All templates are written for
Spacebars template engine built into the meteor. I don’t really like logicless template engines, and had to put up with a number of points. I believe that it should be possible to describe everything that relates exclusively to the appearance directly in the templates. For every simple comparison, you need to start a helper. Even for the usual comparison:
UI.registerHelper('eq', function (a, b) { return a === b; });
Well, apparently this is a limitation due to reactivity. But otherwise the template engine is good. It works great with scopes, it is easy to change patterns, it is also not difficult to write them.
Router
To determine the paths of the application used
iron router . Quite convenient and well-made router, allows you to hang certain actions to follow the link, quite flexibly allows you to describe the path, makes it possible to transfer the necessary data directly to the template, and not just through helpers.
Router.route('/logout', function () { Meteor.logout(); this.redirect('index'); });
Controllers
Not quite correct. Controllers here, as such, are not at the front. Helpers and events can be attached to each template. Helpers return values ​​to a template, and events are responsible for the actions in it. In principle, the router acts as a composer of the pages.
Although, of course, no one bothers to spread the logical elements in different files and convenient to group.
Game objects
There is an Item class that contains very basic data that each object has / may have: name, description, requirements, effects. Also contains basic methods such as price (), currentLevel (), meetConditions (), has (), etc.
Objects with additional / modified behavior are already inherited from it: GlobalItem, Building, Unit, EnemyUnit, Hero, Research, GlobalResearch.
Objects with the Global prefix are common to the entire server, and implement the appropriate mechanics of the total research / hero investment.
Effects system
I really like the effects system I managed to do. Each object can have one or more effects. The effects are divided into 4 types: affecting the prey, affecting the price (and time), affecting the combat characteristics, as well as special effects that are unique.
Here is an example of the description of the effect of one of the improvements:
new Game.Effect.Military({ pretext: '+', aftertext: '% ', condition: { type: 'unit', group: 'ground', special: 'infantry' }, priority: 2, affect: 'life', result: function(level) { level = level || this.currentLevel(); return level * 30; } })
You can describe the text before and after the value, describe the object to which the effect is applied according to a number of criteria (if you do not specify a single criterion, the effect affects everything that is applicable). Priority - the order in the calculation of the final value: odd priorities have fixed values, even percentages. Those. if we have an effect that gives +10 armor with a priority of 1, and then an effect that gives 30% with a priority of 2, and after it another +5 with a priority of 3, then we end up with (basic armor + 10) * 1.3 + 5.
If there are several effects with the same priority, they are first summed up, and then applied. For example, 2 effects of 10% each will give a multiplier (1 + (0.1 + 0.1)).
Special effects can affect the unique parameters of the game, for example, reducing the reloading time of hyperdrives (found only in 1 place).
Thus, we have implemented a flexible system of interaction of buildings, improvements and everything else.
You can get a list of effects applicable to the object, and work with them as you like. For example, to derive from which constituted the influx of population.
Tasks
We have divided tasks for: task line, trigger task, daily task. The coolest feature in terms of implementation is that I can become attached absolutely to any event in the game, such as to issue a task or the conditions of execution.
This was achieved in a simple way - the task has a function that returns true / false, whether the task is executed. For example:
isDone: function() { return Game.Buildings.has('residential', 'house'); }
Thus, you can hang an event even on a message in the chat, even on the entrance to the game after a rain on Thursday.
Daily tasks, for the moment, are simply a survey, with several answers, and outcomes, partly random, partly dependent on any actions previously.
Work with base
By default, the meteor comes with MongoDB. This is a very convenient document-oriented database. Easy to scale, easy to write queries, easy to modify. It stores all data in JSON, and, not having a strict structure, allows you to add / remove fields on the fly, thanks to which, in fact, no migration is required (except for cases when new fields of old records need to be filled with values).
To work with a particular collection, I started a separate class, and all that was needed was to drive through it. For example, to write off resources, just call Game.Resources.spend (price);
Answers on questions
Why browser? I thought browser games became extinct.
1) I know browser capabilities better than other platforms.
2) Works on most devices without additional modifications.
3) Ability to collect full-fledged applications in the future without much effort
You have enough 200 000 rubles to make the game?
The game is already in beta testing. These funds will be enough for us to release all the planned components.
What happens if you don’t collect the funds?
We will look for an investor.
In fact, without advertising, we have gathered a good starting audience, and this is already something worth it.
When is a full launch and what will be there?
The launch is planned in mid-October.
Buildings, improvements, general improvements, heroes, ground troops, comic troops, various types of space battles, general (all server) battles on the Earth, temporary amplifiers, personal chamber with decorations that everyone can watch, alliances, bosses, a bunch of different tasks with references to games, books, films and various events. As well as comics, the development of which affects every player.
Total
There is a long way, but there is no time for rest. A lot of things are planned, a lot must be in time for the release, which is expected in October.
Thanks for attention.