The story of the bike

    imageSometimes programmers invent their own “bicycles”, but is it really bad, especially if the creation is indistinguishable from the original and the author gets invaluable experience?

    This story began a little over a year ago with the advent of my wife's modern smartphone. She asked to find the Solitaire Solitaire, the same as it was once on desktop Windows. After reviewing a dozen programs, I was unpleasantly surprised - almost everywhere there was an inconvenient control, controversial pictures of cards, a sea of ​​extra bells and whistles like 250 solitaire games in one, setting photos on a shirt and blackjack with harlots. As a result, they chose one of the more or less suitable options and forgot about it for a while.
    A year passed and I began to write programs for mobile. At the same time, the cross-platform issue, debugging in-app purchases, and preparing content for different platforms became an edge. There was an idea to make a Tetris pen or another calculator for testing, but nevertheless, as a “bicycle”, I chose the “Scarf”. The ideological core of the project was the most accurate repetition of the old, good solitaire from a set of Windows games.


    imageThe first problem arose with graphics: the Internet is full of map drawings, many of them are free, but almost all are pretty artsy, look weird on mobile screens, and just don't look like old cards from cards.dll. Maps for Windows were drawn pixel by pixel by the talented designer Susan Ker in 1989, in 16 color mode. If you wish, they are easy to find on the network, but you can hardly use them without IP violations. The cards used in some games of the Linux world turned out to be much more interesting - they were distributed under the GPL license, although they looked a bit strange, with black and white senior cards (figures). The author of these cards was Comrade. Oxymoron, whose sitethe pictures themselves and the script for their assembly lie. He drew his own numbers and icons of suits, and took the figures from an unknown source, but quite similar to the original. I modified the script a bit so that it saved maps in PNG, added transparency, and at the same time painted the senior maps manually. For the ace of spades icon, its own stylized picture was drawn, similar to the original resembling a Celtic pattern. She also became the icon of the program.

    For the shirt, the most pleasant (in my opinion) picture was chosen with a beach and a palm tree with manual drawing. It turned out very recognizable - the look in the picture does not linger, although if you look closely, the difference is obvious.


    imageAs it turned out, the gameplay in the “Scarf” is not so simple due to scoring, a timer, issuing one / three cards, and along with the Vegas mode. For example, a game for money with the issuance of one card (that is, without the ability to turn the deck over) is noticeably different from the standard one: its goal is to transfer as many cards as possible to aces and collect more than $ 42 to exit the minus and start the next game, if the solitaire did not work out. In the game, on the account, transferring the card from the deck “down”, and then to the Aces gives 15 points, while immediately to the Aces - only 10. Naturally, this is documented very conditionally, so I had to drive the original game into wine and conduct a full-fledged review .

    The code

    I wrote the business logic of the program in pure Java 1.6, without using third-party libraries, Android, Swing, etc. For Android, this part is assembled as a separate library and connected to the GUI project without any problems, but for other OS I decided to go a non-standard way and Do not port to the forehead into other languages. After some file processing, the Sharpen projectI was able to convert this code to pure C #, which paved the way for implementation under iOS using MonoTouch, and in the future for Windows Phone 7/8. The simplest unit tests showed that the logic of work has not changed, the broadcast was successful. In the MonoTouch environment, I implemented the GUI display without any nuances, debugged the game on the emulator and iPod Touch and sent it to the iTunes Store for approval. I implemented the program settings using external binding to KGN.InAppSettings , stumbling over some little things like the lack of thumb support for external libraries.


    imageAfter a week of testing at Apple, my “Classic Kerchief” appeared on the iTunes Store. I expected criticism of the graphics or possible licensing disputes, but on the first day all the reviews were unambiguous: the game crashes immediately at launch. I removed the game from the store and began to study problems. My friends started the game perfectly, the emulator and iPod Touch 4g did not show any glitches either. It took several days and the help of members of the forum to find the first serious bug: in the regional iOS standards for Europe and Ukraine, the decimal separator “dot” is indicated, and in Russia it is already a “comma”. Accordingly, the conversion of float to string worked on some devices and crashed on others. Within a week after being sent to the app, it turned out that the game also crashed when launched in landscape mode. On iPod and iPhone, all programs start in portrait orientation, therefore it is found only on the iPad, which I did not have. It took another week to reapprove, during which the fast game finally disappeared from the "New" category and successfully drowned outside the Top 1000. In addition, the transparent background icon, which was perfectly accepted in the Android Market, was obscenely processed by Apple scripts and was frankly not pretty.

    High definition

    imageBy the time the project worked fine, the icons were replaced, etc., I had a new iPad, where I found that the resolution of the cards was clearly not enough for the 9.7 "screen, and on the Retina Display the" jumping cards "were frankly slow. it took a couple of days with the lags, for which I managed to thoroughly intermarry with Core Animation, but I had to hire a designer to improve the resolution. The result of his work was numbers, letters and high-resolution suits, the most similar in style to the original. I enlarged the figures using Photo Zoom Pro not to lose out ntichnost pixel graphics. It turned out not ideal, but still quite well.

    A lot of effort was spent on this work, so it was logical to release a separate HD version, and at the same time add an in-game purchase to the regular version. With the implementation of In-App Purchases under MonoTouch, it was not easy, but to make it look organic, I decided to get rid of KGN.InAppSettings and make a single interface for settings and purchases. I won’t describe technical details here, but I gathered a lot of them, including Monkey’s work on creating your own Settings identical to system ones, struggle with the lack of documentation for StoreKit for Mono, various bugs with debugging of purchases, etc.


    The game did not become a masterpiece, did not hit the tops, and it is unlikely that it will pay for the development costs and the work of the designer, but now I have on my devices (including the smartphone from which it all started) the “Scarf”, which is very similar to the original, which became native since the time of Windows 3.1. The experience of writing portable code in Java and porting it to C # turned out to be simply invaluable - a similar method my team ported several large Android projects to iOS, and due to debugging on a small game, it turned out to be a good idea to study the MonoTouch underwater rake and iOS development in general, and write at the same time some useful libraries. Maybe someone will laugh at this story, but as for me, the “bicycle” came out very fit, and the time was spent not in vain.

    Post scriptum

    I specifically avoided going into the details of porting and working with MonoTouch, because each of them deserves a separate topic. Sooner or later I will gather my strength and lay out my class for In-Game Settings, the purchase manager, etc. on the court of the public.
    I don’t post links to the project, so as not to be considered advertising.
    If anyone needs an updated map generation script, write to, it is a derivative work from the GPL project, so I’ll post it without any problems.

    Also popular now: