King's Bounty III: advanced remake of the original game under DOS using Javascript/HTML5

Background and philosophical reflections


Like many of my colleagues at the programming workshop, especially those who had started to try their hand at computer technology, I have somewhere in the back of his mind is stored a set of the most warm and romantic memories of first experiences. Once, back in 1987, my father first took me to output to his work, where solemnly seated on a chair in front droning "Iskra-1030-11". Around that time I fully realized what I want to do in later life.

image

In our days, running DOSBox, you can easily plunge into the flavor of a carefree childhood, recall the wonderful children's feeling of omnipotence, dizzying interest, exciting new knowledge and skills. Now I'm 34, under me works more than a hundred people, I still write quite a lot of code — especially where the need to use sophisticated algorithms for data mining. Behind — the Arsenal of student achievement — final ACM'like the Olympics, the victory of my chess engine in ex-USSR Championships, one of the algorithms on search trees, called by my name, hundreds of thousands of lines of my code in prod, but nothing brings such joy and excitement as a return to the carefree days of childhood.

10 years ago I got an emulator of BK-0010-01 — my first home computer. Then it was hard work not to start to program under it. But this time, another wave of nostalgia still moved me on a very meaningless, an excuse which can be really that the feeling of emotional recovery that I experienced, after completing his mad enterprise — production of a remake/sequel to King's Bounty, an ancient ancestor of all games line Heroes of Might & Magic.

In General, it is an open secret that the time to single developers have passed. The vigilantes remained in the 90s, when in the absence of Internet and the huge volume of specialized literature, as well as in an atmosphere of scarcity of computing resources, another Lefty deftly made in a short time 7 hats from the skin of not killed bear. Today the work of programmers, in most cases, the collective, and the success of the developer in a much greater extent does not depend on algorithmic knowledge and technological skills, and the ability to quickly find the necessary information and communication skills (including the ability to write well-readable code corresponding to the specified requirements).

In General, the situation when one person runs the game from beginning to end (including the development of the plot, logic game interactions, creating graphics, selecting music, writing the game dialogue, direct coding) — for modern industry absolutely crazy. Boots must stitch the cobbler and pies baking the pastry, otherwise the productivity is not very high. But on the other side of the scale is high level of motivation, which in some cases allows to compensate the costs to be incurred. The development of mobile platforms and the Web has made possible a kind of flashback, in exact accordance with the law of negation of negation — many of today's successful game startups are created either singly, or micro-ops that show an amazing success thanks to netcodegroup work.

Of course, in my case, the project is purely entertainment and has no ideas about monetization, and in the case of such "underground" remake, it generally is hardly possible. The task has been greatly simplified by the fact that the lion's share of the game graphics and logic were borrowed from the original game. In this regard, it was throwing currently the project OpenKB (http://sourceforge.net/projects/openkb/), whose author did a great job on the reconstruction of the original game logic and analysis of the data formats of the original game. The manuals, written by the author of this project, as well as several other Amateur manuals found on the network, allowed the company to significantly save power.
the

Technology


From the beginning the emphasis was put on cross-platform, and because Javascript and HTML5 such Titanic efforts of developers to present more or less achieved, a special alternative in the choice of development language, in General, was not.

Of course, there are a number of languages broadcast in JS and has some advantages, but desire to create an extra layer in a small project arose. In addition, due to the prevalence of JS, you can always count on the fact that any task that need to be solved in the course of project work, someone has already decided to you, generously giving code snippets for everyone to see.

Owing to comparative simplicity of the game interface of the original game, it was decided to abandon the use of any heavy gaming frameworks. Libraries used jQuery only (in principle, it would be possible to do without it — in fact, it took only $.inArray, $.trim and work with the event triggers the browser; frankly, frightened of the possible problems of cross-browser just in relation to the events, so jQuery was still left in the project).

Graphics and music were implemented using the standard mechanisms of HTML5 (Canvas, Audio). Standard methods of the Canvas is more than enough to implement sprite graphics with a minimum of effort. Audio also provides all the needed to power the game sound effects. All required snippets are easily detected on stackoverflow with simple queries, so some experience of practical programming in a modern development ecosystem would be enough to understand all the technological nuances for a night or two.

the

Progress


The work was carried out in fits and starts for nearly a month and a half. From the beginning I gave myself half-joking vow to write 500 lines of code a day and the first time the figure even managed to observe. Of course, when it came to the availability of the first conditional functional version, the rate significantly decreased because a significant part of the time was to go on bug fixes and minor refactoring of already written code. Some decisions taken in haste in the first week of operation, has not justified itself — in particular, the results had to write a mini-library for working with dialogs, Windows, and other GUI components, although at first it seemed that you can do in this respect, very little blood.

Special attention deserves the work over the logic of saving in the game. Here I succumbed to another of his weakness — the love of data compression algorithms, so saves are Packed with built-in compression algorithm (dictionary + LZW with dynamic bit alignment). Resorting to retrospective rationalization will justify it by a desire to save space on mobile devices (unpacked save still pulls more than a hundred kilobytes), and also desire at least some fun to life cheaters.

The graphics from the original game I had once mined in the late 90's, when I wrote C version of KB, including only fighting (with extended magic and other entertainment). However the old code was lost together with the died screw back in 1999, but I roughly remembered where and what to take. Additions were completed with Pixlr and found in the network of symbols, taken for a basis. One of the pictures helped to ostravici my bride, so strictly speaking the game worked not only for me.

Music — a selection of suitable within the meaning of the free classics from the web, sound effects — record from the original game DOSBox -> Audacity or some processed free samples http://freesound.org.

From half to 3/4 time taken for coding in the project received just under 12,000 lines (except jQuery) (380 kilobytes of script). The rest — a writing game texts (they are, unlike the original game, much more in addition the game is bilingual), as well as testing.
the

Result


The mechanics of the game basically repeats the mechanics of the original game formula attack, magic, etc. match the originals. Also from the original game graphics are taken (supplemented by a small number of new objects) and a map of the first continent (with minimal changes). The plot is widened, continents 4, and 5, while the second map is greater than in the original game, size. Added a different sort of jokes, secrets, new twists. Tested all of the Chrome, FF, Edge, IE, the mobile version of IE.

I will be grateful for bugs, advice on project development and any feedback.

The address of the page with the game: http://genes1s.net/kb/game.html.
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

Monitoring PostgreSQL + php-fpm + nginx + disk using Zabbix

Templates ESKD and GOST 7.32 for Lyx 1.6.x

Customize your Google