📜 ⬆️ ⬇️

Experience creating a game for smartphones

Introduction


Most leaders in the field of mobile platforms are trying in every way to attract developers to their camp. To do this, they offer various APIs and SDKs to create their own applications, which, according to their assurances, should bring good profits, if not in financial terms, then at least in the form of experience gained.

Check whether this is so, it was decided on their own experience.

Idea



The main criterion for the new application (game) was its novelty in the market. After spending some time thinking, a puzzle came out of my school age. Its essence is simple - you must visit all the cells of the field 10 by 10, making a move with a chess knight. You can start the movement from any position. Previously, this problem was solved with the help of a tetrad sheet and a pencil. But now, in the era of computer technology, it can be transferred to a more convenient form.

Having a little imagination, the puzzle was modified as follows:
')


Since I am mainly connected with Microsoft technologies, such as Silverlight or WPF, I decided to implement the game for Windows Phone . However, I also wanted to be able to easily port the application to other platforms, so JavaScript and HTML were chosen as the main tool for implementation. At the time of the start of development, there was no deep experience with these technologies, but it was very attractive for cross-platform, which, for example, Phonegap can provide with the approach used.

Implementation


About 1-2 months were spent on implementation due to employment at the main job and frequent changes to the already implemented functionality. The foundation for the application was the jQuery Mobile mobile framework, for which there are a large number of plug-ins, both for working with the animation of the user interface, and for automating other frequently occurring tasks. For example, the Flip plugin was used to animate a field cell visit, and simpledialog2 was used to display pop-up windows. The library itself allows you to quickly create markup that will be appropriately displayed on a mobile device.

The first version used only HTML and Javascript features and fully worked in the browser. True, in each browser differently =)

In addition to the rather obvious differences in the processing of markup were more fundamental. For example, it turned out that Internet Explorer does not support localstorage when opening a local file (C: \\ ...). Therefore, to work with the data warehouse, I had to use the JStorage plugin.

function stGet(name) { return $.jStorage.get(name); //     // return localStorage.getItem(name); //  localStorage } 

Another inexplicable feature was that the stGet function described above returned null for the “settings.hints” parameter and “null” (as a string) for “settings.language”. This behavior was repeated regardless of the use of the JStorage or localstorage plugin. I suspect that the problem lies in the local computer, but there was no time to check this, so I simply used the checks on both options to set default parameters when the application was first run.

Another difficulty was the desire to support the English and Russian versions at once. There are several solutions to this problem online, but they did not work properly for my task. I wanted to change the language of the entire user interface of the application by pressing a single button. At this stage, it turned out that it is quite useful to describe HTML markup not statically, but dynamically compile using JavaScript. In this case, you can also rename the controls without any problems. In this regard, once again I had to rewrite the already implemented functionality. But, as they say, “the end justifies the means” and the task set has been solved.

From the point of view of the implementation of the game itself, it is difficult to highlight some interesting points, so I will not delve into their description. The main points are the generation and rendering of a field, the processing of clicking on a cell, checking for the possibility and necessity of visiting the field, checking for victory or defeat, etc.

Windows phone


Windows Phone (WP), starting with version 8, supports HTML / JS applications and does not require the use of third-party frameworks (such as PhoneGap). To run an application on WP8, you need to open it with the help of the WebBrowser control.

In order to put the implemented game into the Windows Phone MarketPlace, it had to be supplemented with the “Rate” feature to evaluate the application and add processing to pressing the “Back” button on the device. Due to the lack of the latter opportunity, the first certification of the application in the WPStore failed.

To add the described features, a “bridge” between the WebBrowser control and the side written in JS was used. Everything is implemented quite simply:



Also for registration of the application it was required to prepare screenshots. Making them was pretty easy with the emulator included in the WP8 SDK. The name, description, search keywords were invented and other necessary procedures were done (obtaining a PEGI license, registering a bank account). What happened can be seen in the picture, and the application itself is available in MarketPlace.

Conclusion


Currently, the application is paid and contains 10 levels. In the near future I plan to make a free version with fewer levels and a link to the paid version. After that I port it for IPhone users. The application is already successfully launched on iOS, it remains to test it and figure out how to publish it in the AppStore. During the development, a huge amount of experience was “boosted”. As for the financial part, I can’t say anything yet.

PS: Since the game is paid, and this article is in some form its PR, the name and link is not indicated anywhere.

UPD: Thanks for the good advice to readers. Here is a link to the game. It works for some reason is not sustainable.
UPD2: The application has received a trial version. The link is the same.

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


All Articles