📜 ⬆️ ⬇️

Turn-based strategy as a hobby



Hi, habra people! Who of you dreamed of creating your own game? Is it possible to write a browser strategy without having experience and money at the same time? Perhaps, if you really want this.

Under the cut is my story of creating a free turn-based strategy.
')


What is the game like ? In a nutshell - the network analogue of the good old "Panzer General".

But first things first.

Prehistory


Some time ago I played and modified the “Behind Enemy” series of games. The series is excellent, and I think the tank fights there are the progenitors of World of Tanks. But for several years, the network game is terribly tired, even with mods. The reason for this was monotonous gameplay: the same maps, the same stream of units,
all players always saved up credits for a more powerful tank or infantry squad, and each unit list was strictly fixed.
Thus, some equipment completely disappeared from the battles, and the latter were monotonous and predictable. Were looking for ways in the mods to customize the purchase menu, so that the player at least randomly received his unit list and fought, not to mention specializations. But alas, the engine did not allow it.

At the same time, the idea of ​​a forum was born in the forum discussions - “what if the global map is attached to the game with the economy?”.
Global map strategy, tactical battles in VTV. The units available to the sides are dictated by the front. Didn't have time to send reinforcements? - fight the fact that there is! Cool! The end of monotony!

It remains only to persuade the developers. But the result of a conversation with them, I think, is obvious to everyone - it is not known whether it will pay off.

I am a little familiar with the BestWay team, and we came to the conclusion that the strategy can be implemented in the browser, then “To the rear of the enemy” will have to be minimally finalized just by adding the API.

The browser part, without hesitation, proudly took over. We agreed after some of my developments to discuss the future life of the project, because all the masters “chat”.

Having a poor programming experience, in my spare time I started my journey.
Since then, it took about two years.

Development


I chose Codeigniter as a framework, on it I ruled several foreign projects, and there was some experience. It was decided to write the client part on JS, more precisely on jQuery, because I did not even know flash anymore.

Next, it was necessary to understand how it all should look. Of the games of this genre, I saw only "Total war" and "Caribbean crisis", but they were all standalone. Long googling gave its result - weewar.com . Here it is, what you need!

The map of Europe was chosen as a basis and began to analyze html. There were several layers on the vivar. Bottom - pictures of territories, middle - units, the uppermost - tags area with exact contour hexes. At the same time, the entire html code weighed more than 500 kb.

I decided to simplify the scheme and limit myself to two layers: the territory and the troops. But in this case there was a problem of clicking on the wrong cell. After all, the divas ran into each other:


How did I solve this problem? No Practice has shown that it is completely irrelevant. All clicks in 99% of the cases are made in the center of hexes or higher. If in the future there will be complaints, I will check the coordinates of the click.
The map is drawn, in the eyes of happiness. Moving on.

And then everything went like clockwork, until the moment when it was necessary to implement the search for ways. And you need not just to find a path, but to display all sorts of where the unit can move.

As usual, the bike was first built, then the “wave algorithm” was suddenly discovered, and based on it, everything was well assembled into a working state. Next, it was necessary to port to php, because any js calculations are easily forged. Rewrote, threw away all unnecessary, because the server only needs to check the validity of the movement from point A to point B. It works.

Another interesting task is to get rid of the page reload. It was all quite simple. Record all game actions in the log, sampling Ajax fresh logs using long polling, animation on the map of the data. As a result, in two different browsers I saw the same actions performed in the third. And it was very cool, considering that even at Vivara there were no animations and it was almost impossible to understand what your enemy is doing, whom he moved and where he attacked.

Another “know-how” compared to weewar - displaying the action log and the ability to view the replay. Well, who will be comfortable reading player1 move unit 23,5 -> 24,6 ?
A couple of dozen lines of code, and the user, by clicking on the eye in the log, sees the replay of the animation.
image

When this prototype was shown, I did not get any clear answer from BestWay. But not at all upset. Behind him was an excellent programming experience and a quick decision to finish the game as an independent one. Like weewar, but better.

What happened next, in addition to programming, can be safely considered game design work.
The setting was left - World War II.
There were formulas for calculating the attack, the characteristics of the units ... My next pride is the different bonuses of the territories, for the interaction of different types of troops. For example, a tank in the forest received +2 to defense against enemy vehicles, but -2 from infantry, which was quite logical and important for the gameplay. At vivare, the forest simply gave the tank a -2 to defense.

So slowly and sadly, after half a year, the alpha version was born, where it was already possible to play and even in some places it was interesting. “Blood money” was spent on domain purchase and hosting, the project was rolled out, and the first games began to be played with friends. It looked like that then.

Project life


In the first weeks the number of registered users was very small. No one understood where he got and what to do. I needed a good manual, and I began to look at online projects for their presence, so that at least approximately understand how they are written. Scrolling through a few, I became bored. If you are already a little familiar with the game, then the documentation is easy to read. But for a beginner, this is a “forest.” I came to the conclusion that you need interactive training. Minimum text, maximum action. After its implementation, life began to improve.

Day after day, the games were played on a map of Europe wiped up to the holes, even one with weewar. It quickly got tired. It was clear that without a map editor can not do.
For about a month, he wrote such an editor , to whom the players were very pleased. On the first day of its existence, 5 new maps appeared in the project. To date, about 40 cards.

I really wanted to make a beautiful drawing possible ways.
But rested in browser performance. For implementation, it is necessary for JS to impose a third layer with a translucent white hex. And on the middle map it's about 1000 new divs . Firefox, opera - quickly coped with the task. Chrome needed a few seconds. But the culprit of the "celebration" - IE. Even the ninth version added divas of seconds 5. I had to refuse. I think over more productive scheme.

So, for several months, almost every day something was done in the project. Fixed bugs, screwed new features. Added units. Just recently, the interface was drastically updated, and a new nation was added - the USA. The full change history is available in the “What's New?” Section.

During the 2 months of the project’s life, nearly 150 Russian-speaking users registered, 300 games were played, and 75,000 entries appeared in the action log.
Probably not bad, considering that not a penny was spent on advertising, and the project was presented in just a few Russian-speaking forums.

What's next?


Someone glues models, someone plays airsoft, my hobby is my strategy.

At the moment, I am collecting "blood" for a good artist, because many units and objects in the game are from other games.

In the future I plan to implement several more settings, for example, the Middle Ages or the modern war, until I decided. And maybe the orcs with elves, what the hell is not joking.

Also in the plans of the necessary features, such as fog of war or booking technology. More details can be found on the website in the "Under Development" section.

The project is still running on a regular hosting, so I give the link immediately to the training. It completely on JS, does not force MySql. I hope, habraeffekt will be merciful.

Wargex

Thank you for your attention and good luck on virtual fronts!

PS Thank you so much alexDark and Armin for help with the article.

Source: https://habr.com/ru/post/128106/


All Articles