📜 ⬆️ ⬇️

Be rosary! Be brave! Be always with Semkah!

Be a man bl ...! =)

But actually, I would like to talk about what a “hard” job is to write mobile applications on Qt ... Let’s analyze a simple example.

So. We have late April, 4 pairs of practices in a row, a mobile phone with a simbo and a few bored pranksters. And here comes to one of the heads a brilliant idea in its absurdity! “How to be if there turned out to be a few patchy little boys and there were no semok? They will not understand, if you don’t pound with them! ” Fie, business then ... We put Qt SDK , quickly we start Qt Creator and we create the new project (and the Desktop-application). We parallelize the work, while we plan three panels (menu, game, results) the dudes behind the next computer draw a brick wall and an image of the seeds - whole and unlocked. They also select a suitable soundtrack ...

How does this happen ... (Of course, I just did the screens)


')
By architecture, the application of course turns out to be the simplest, but no less fun for it. There are three classes:
QSlidingStackedWidget -       (  . , ) MainWgt -          . SemkoItem -   QGraphicsPixmapItem,     ,     . 

I don’t think about talking about the implementation of the menu and the results; it’s enough to mention that it works and keeps quite a number of servos for this or that player.

But about the game itself, we will mention a bit. In fact, it is QGraphicsView + QGraphicsScene, a timer dynamically creating new seeds, a class of separately flying seeds that monitor its fall, animating itself. reacting to events and finally tracking his coordinates in order to have time to destroy himself when leaving for the limits of visibility and a great rand. It looks quite prosaic ...

Start the game:
 void MainWgt::startGame() { if (isSound()){ moMainTheme->play(); } placeSemkoTimer->stop(); placeTimerInterval = 1000; placeSemkoTimer->setInterval(placeTimerInterval); nextLevelCount = nextLevelIncrement; semkoInterval = 30; scene->setSceneRect(0, 0, 10, 10); ui->lcdSluzgano->display(0); ui->lcdUnluzged->display ( lives ); placeSemkoTimer->start(); } 

Throw a seed by timer:
 void MainWgt::placeSemko() { SemkoItem *semko = new SemkoItem(scene, semkoInterval); connect(semko, SIGNAL(luzg()),this,SLOT(luzg())); connect(semko, SIGNAL(unluzged()),this,SLOT(unluzged())); connect(this, SIGNAL(nextLevel()),semko,SLOT(nextLevel())); connect(this, SIGNAL(gameOver(bool)),semko,SLOT(gameOver(bool))); scene->addItem(semko); } 

And we process each hit with a finger, so far only with a mouse on the seed ...
 void MainWgt::luzg() { int c = ui->lcdSluzgano->intValue() + 1; if ( c >= nextLevelCount ){ nextLevelCount += nextLevelIncrement; semkoInterval -= 3; if (semkoInterval <= semkoIntervalMin){ semkoInterval = semkoIntervalMin; } int livesAdd = ui->lcdUnluzged->intValue() + 3; ui->lcdUnluzged->display ( livesAdd ); placeTimerInterval = placeTimerInterval - placeTimerIntervalDecrement; if (placeTimerInterval <= placeTimerIntervalMin){ placeTimerInterval = placeTimerIntervalMin; } placeSemkoTimer->stop(); placeSemkoTimer->setInterval(placeTimerInterval); placeSemkoTimer->start(); emit nextLevel(); } ui->lcdSluzgano->display ( c ); } 

At this point, as we can see, we are also looking at how much seed has already been settled and whether it is time to move on to the next level (and therefore, to increase the speed of the drop and fall).

Well, what else is interesting there ... Yes, in fact, nothing special ... So, we launch, test, correct the parameters, eliminate the shortcomings, fasten the music (thanks to the Glom and Courage-Bambay band, by the way) and start to indulge ...

Menu ...


A toy…


And do not look at such an ugly LCD from the bottom, on the phone it is kavaven ...

“Uuuu b ..!” Said the crowd of idlers near the end of the third pair, looking at what happens. “Aha b ..!” - said the most impatient, - “And how can I now squat and poke the mouse. looking at the monitor? It's awkward! ”

“Garbage war, the main maneuvers!” - the main developer mumbled (I mean) and resolutely switched to porting ... Oh, how difficult and long it was ... Already 15 minutes =).
Scheme:
1) We stick the device in PC Suite mode
2) We put on it Qt, using for this purpose the Ovi Suite installed on the PC

3) Add a new version of the assembly of our application in the creator

4) Select Release version and click start


Actually everything, it remains to wait until the program is assembled and the launch menu of our application happily appears on the smartphone display.

So. What is the result? For a couple of hours with Qt, you can quickly rivet quite playable figovinu, ready to work under all desktop platforms and also easy to start from the development environment on the device. Remarkably, in Maemo and in the Android port, everything starts in the same way as simbian, without any extra tambourine dances. Easy? I think yes. Exquisite? Sure! =)

On the project itself:
Page
Repository
Version for Symbian 9.4 . To install the kenchno, you must first install Qt .

By the way, yes ... Everything was done in pure C ++, without using QML. And yet it turned out quickly and fun. I would very much like Qt to become a more popular platform, probably after the release of 5.0 it will be so ...

UPD:

Let's say a friendly thank you comrade obramko for the wonderful toy port on Android ...

Screenshot:
image

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


All Articles