Back to Home

Turn-based strategy as a hobby

strategy · turn-based strategy · game development

Turn-based strategy as a hobby



    Hello habra How many of you did not dream of creating your own game? Is it possible to write a browser strategy without having the experience and money? Perhaps if you really want to.

    Under cat, my story is about creating a free turn-based strategy.



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

    But first things first.

    Background


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

    Then, in forum discussions, the idea was born - "what if we fasten the global map with the economy to the game?"
    Strategy on the global map, tactical battles in the VTB. Units available to the parties are dictated by the front. Didn’t have time to send reinforcements? - fight with what you have! Cool! The end of the monotony!

    It remains only to persuade the developers. But the result of the 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 also be implemented in the browser, then “Behind Enemy Lines” will have to be minimally modified, just adding an API.

    Browser part, without hesitation, proudly took over. After some of my best practices, we agreed to discuss the future life of the project, as all the masters “chatted”.

    Having a scanty programming experience behind me, in my free time I nevertheless began my journey.
    About two years have passed since then.

    Development


    Codeigniter was chosen as the framework, I ruled several other projects on it, and I had some experience. It was decided to write the client part in JS, more precisely in jQuery, because flash I did not know even more.

    Next, you had 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 google gave its result - weewar.com . Here it is, what you need!

    The map of Europe was chosen as the basis and began to analyze html. There were several layers on the vivar. The bottom one is the pictures of territories, the middle one is the units, the uppermost one is the area tags with the exact outline of the hex. 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: territory and troops. But in this case, there was a problem clicking on the wrong cell. After all, the divas ran into each other:


    How did I solve this problem? No way. Practice has shown that it is completely inconsequential. All clicks in 99% of cases are made to the center of the hex or higher. If there are future complaints, I’ll 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 a search for paths. And you need to not just find the way, but display all kinds of ways where the unit can move.

    As usual, a bicycle was first built, then a “wave algorithm” was suddenly discovered, and on its basis everything was well assembled to a working state. Then it had to be ported to php, because any js calculations are easily faked. I copied it, threw away everything unnecessary, because on the server you just need to check the validity of the movement from point A to point B. It works.

    Another interesting task is to get rid of page reloading. Everything turned out to be quite simple here. Record all game actions in the log, ajax fetch fresh logs using long polling, animation on the map of the received 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 on the vivar there were no animations and it was almost impossible to understand what your enemy was doing, whom he moved to and attacked.

    Another “know-how” compared to weewar is to display 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, clicking on the eye in the log, sees the animation repeat.
    image

    When this prototypeIt was shown, I did not receive any distinct answer from BestWay. But absolutely not upset. I had an excellent programming experience and a fast-paced decision to make the game independent. Like weewar, but better.

    What happened next, in addition to programming, can be safely considered a game design work.
    The setting was abandoned - World War II.
    I came up with formulas for calculating the attack, the characteristics of 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 defense from enemy equipment, but -2 from infantry, which was quite logical and was important for gameplay. On the vivar, the forest simply gave the tank -2 defense.

    So slowly and sadly, after half a year, the alpha version was born, where it was already possible to play and even in places it was interesting. Spent money on the purchase of a domain and hosting, the project was deflated, and the first games began to play with friends. It looked then as .

    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 online projects for their presence, in order to at least approximately understand how they are written. Scrolling a few, I felt bored. If you are already a little familiar with the game, then the documentation is easy to read. But for a beginner - this is the "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, games were played on a hole-worn map of Europe, another one with weewar. It quickly got tired. It was clear that a map editor was indispensable.
    In about a month, I wrote such an editorwhich the players were very happy about. On the first day of its existence, 5 new maps appeared in the project. To date, there are about 40 maps.

    I really wanted to make a beautiful rendering of the possible paths.
    But he ran into browser performance. For implementation, it is necessary to impose a third layer with a translucent white hexa JS. And on the middle map it is about 1000 new divs . Firefox, opera - pretty quickly coped with the task. Chrome needed a few seconds. Well, the culprit of the "triumph" - IE. Even the ninth version added divas of seconds 5. I had to refuse. I think of a more productive scheme.

    So, for several months, almost every day, something was done in the project. Bugs were fixed, new features were screwed. Units were added. Just the other day, the interface was radically updated, and a new nation was added - the USA. A complete change history is available in the What's New? Section.

    Over 2 months of the project’s life, almost 150 Russian-speaking users registered, 300 games were played, and 75 thousand entries appeared in the action log.
    Probably not bad, given that not a penny was spent on advertising, and the project was presented at only a few Russian-language forums.

    What's next?


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

    At the moment I am collecting "hard-earned" 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, I have not decided yet. Or maybe the orcs and elves, what the hell is not joking.

    Also in the plans are the necessary features, such as the fog of war or the reservation of equipment. More details can be found on the website in the "Under construction" section.

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

    Wargex

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

    PS Thank you so much alexDarkand Armin for help with this article.

    Read Next