📜 ⬆️ ⬇️

The story of the bike

image Sometimes programmers invent their own “bikes”, but is it really bad, especially if the creation is not distinguishable from the original, and the author gets invaluable experience?

This story began a little over a year ago with the appearance of a modern smartphone for my wife. She asked to find Solitaire solitaire, the same as it was once on the desktop Windows. After reviewing a dozen programs, I was unpleasantly surprised - almost everywhere there was inconvenient control, controversial pictures of the cards, a sea of ​​extra bells and whistles like 250 solitaires in one, setting up a photo 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.
Flew a year and I started writing programs for mobile. At the same time, the issue of cross-platform, in-app debugging of purchases, content preparation for different platforms became an edge. There was a thought to make a “Tetris” pen or a regular calculator for testing, but still I chose “Solitaire” as a “bicycle”. The ideological core of the project was the most accurate repetition of the old, good solitaire from the Windows game set.


Content


image The first problem arose with graphics: there are a lot of map drawings on the Internet, many of them are free, but almost all are pretty elaborate, they look strange on mobile screens, and they just don’t look like the old cards from cards.dll. Cards for Windows pixel-by-pixel were painted by talented designer Susan Care in 1989, in 16-color mode. If desired, they are easy to find on the network, but you can use it without violating IP. The maps 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 older maps (figures). The author of these cards was Comrade. Oxymoron, on the site of which the images themselves and the script of their assembly lie. He drew his own figures and icons of suits, and took figures from an unknown source, but rather similar to the original. I modified the script a bit so that it saved the maps in PNG, added transparency, and at the same time manually painted the higher maps. For the ace of spades icon, a personalized stylized picture was drawn, similar to the original, resembling a Celtic pattern. She also became the icon of the program.
')
For the shirt was chosen the most pleasant (in my opinion) picture with the beach and a palm tree with a hand-drawn. It turned out very recognizable - the look in the picture does not linger, although if you look closely, the difference is obvious.
image

Gameplay


image As it turned out, the gameplay in "Solitaire" is not so simple due to the scoring, timer, issuing one / three cards, and along with the Vegas mode. For example, playing for money with the issuance of one card (that is, without the ability to turn the deck) differs markedly from the standard one: its goal is to transfer as many cards as possible to the aces and collect more than $ 42 to get out of the minus and start the next batch. if solitaire did not work out. In the game, the transfer of the card from the deck “down” to the aces gives 15 points, while just 10 is right for the aces. Naturally, this is very conditional documented, so I had to drive the original game in wine and conduct a full-fledged search .

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 connects to the GUI project without any problems, but for other OS I decided to go non-standard way and Do not engage in porting "in the forehead" to other languages. After some file processing, the Sharpen project was able to convert this code to pure C #, which opened 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 the work has not changed, the translation was successful. In the MonoTouch environment, I implemented GUI mapping without any nuances, debugged the game on the emulator and the iPod Touch and sent it for approval on the iTunes Store. I implemented the program settings with the help of external binding to KGN.InAppSettings , stumbling over some trivialities like the lack of support for the thumb for external libraries.

Problems


image After a week of appruva at Apple, my “Classic Solitaire” appeared on the iTunes Store. I expected criticism of the graphics or possible licensing disputes, but on the very first day all the reviews were unequivocal: the game crashes immediately upon launch. I removed the game from the store and began to study the problems. My friends started the game perfectly, the emulator and iPod Touch 4g also did not show any failures. It took several days and the help of members of the forum to find the first serious bug: in the regional standards of iOS for Europe and Ukraine there is a decimal separator “period”, and in Russia this 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 appr, it turned out that the game also crashed when launched in landscape mode. On the iPod and iPhone, all programs start in portrait orientation, because it only shows up on the iPad, which I did not have. At the re-up, another week went away, for which the game finally disappeared from the “New” category and successfully sank beyond the Top 1000. In addition, the icon with a transparent background, perfectly accepted in the Android Market, was obscenely processed by Apple scripts and became frankly not pretty

High definition


image By the time the project was working properly, the icons were replaced, etc., I had a new iPad, where I found that the card resolution was frankly not enough for a 9.7 "screen, and on the Retina Display the" jumping cards "frankly slow down. Fighting It took a couple of days with lags, during 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 the numbers, letters and suits of high resolution, most similar in style to the original. 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 the HD version separately, 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 all that simple, and in order to look organic, I decided to get rid of KGN.InAppSettings and make a single interface for settings and purchases. I will not describe the technical details here, but there are a lot of them, including the monkey work of creating your own Settings, identical to the system ones, fighting the lack of documentation for StoreKit for Mono, various bugs with debugging purchases, etc.

Profit


The game did not become a masterpiece, did not hit the tops, and it is unlikely that it will pay back the cost of development and the work of the designer, but still I have on all devices (including the smartphone that started it all) there is the “Klondike”, which is the most similar to the original since the days of Windows 3.1. The experience of writing portable code in Java and porting it to C # turned out to be invaluable - several large Android projects on iOS were ported by a similar method by my team, and debugging on a small game turned out to be a good idea to learn the MonoTouch underwater rake and generally develop under iOS, and at the same time write a certain number of useful libraries. Maybe someone will laugh at this story, but as for me, the “bicycle” came out very useful, and the time was not wasted.

Post Scriptum


I specifically avoided going into the details of porting and working with MonoTouch, because each of them is worthy of a separate topic. Sooner or later I will gather my strength and put my class for the In-Game Settings, the shopping manager, etc., to the public.
I do not post links to the project so that they do not consider it as an advertisement.
If anyone needs an updated map generation script, write to scanwords@runserver.net, it is the derivative work from the GPL project, so I’ll post it without any problems.

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


All Articles