📜 ⬆️ ⬇️

As in the Magic Electrotechnical practice in Java has passed and a little about Lumia 710

It so happened that I became the winner of the contest from Microsoft and received the Nokia Lumia 710 as a prize. After all my sites were tested for compatibility with mobile IE, I thought that it would be nice to test the smartphone itself in real conditions and write a review. The school year was over, and there was an exciting summer practice in Java, during which I wanted to test the smartphone ... But as a result, more time was spent on programming the game than reviewing the new smartphone.



Disclaimer


This text will tell my story from my position. It is recommended to read for distraction from serious cases and as tablets of realism for applicants.

Interlude


The practice was supposed to take a period from June 30 to July 7: a course of lectures and the implementation of practical tasks. I am already working with Java and was going to practice a little systematizing my knowledge voluntarily-compulsory during practice. I planned to describe each of the days of practice, how the smartphone showed itself. After the third day I was planning to upgrade my smartphone to 7.8, but life has made its own adjustments ...

The first day


It began for me a little later than for the rest. And just wanted to remember the development on Android in the evening. But as they say, a delay of less than an academic hour is not a delay.
I was met by a familiar audience and a lot of students who are already eating the benefits of Java.
Photos from the scene
(Picture taken at Lumia 710)

Results of the first lecture

Of course, the first day of classes after the rest (session) did not carry fundamental knowledge. We were briefly told about the history of the emergence of Java, applications; reminded the main paradigms of the PLO and features of the syntax of the language. In short, the first day you can safely call "Introduction to Java and the next Hello World". At the same time, we were told that we would conduct practical exercises under the supervision of practicing graduate students, whom we would be presented on Wednesday.
Life is cruel: there cannot be much good: the lecture is over in three hours, instead of the expected five. But of course, I did not waste this three hours ... (minus fifteen minutes late and fifteen minutes break).
First impressions from Lumia

Getting to know Lumiya didn't go as smoothly as I would have liked. I used to see devices on WP only in pictures, but I was hoping that the experience of several android phones and simbian would help me. I logged in to Lumiya for a long time, but everything that I did with it up to this point is only played in the FlappyBird clone.

What is the device I was pleased at the lecture? First of all, I entered Yandex. Mail through a standard application. The device is adapted for the Russian consumer, and it was possible to indicate that mail on Yandex (apparently depriving itself of the pleasure of entering a POP3 server) easily coping with authorization (guess what, you need to enter your Yandex login or e-mail address in the "user name" field) I was forced to contemplate for about fifteen minutes the inscription "mail synchronization is in progress." To the credit of the developers, the letters in the last two weeks really loaded onto the device. Once on the "connection" (as I thought), it is time to judge the Marketplace in more detail. Do you know what they write about Market? It seems to have everything, but there is nothing. I installed a couple of time-killers (Doodle Jump clone and Portal Ball puzzle) and VK messenger. With the popularization of html5, it so happened that the number of standalone applications on my devices decreased, but I tried to run through the list of applications I needed. With a limited WP7 API, I don’t have to hope for applications like Llama , but I found the SSH terminal with ease, but the BT terminal ... ( well, you know )
Mini-total

And here it is possible to disperse: the smartphone was discharged to 20% (in three hours of active use), I didn’t hear anything new about Java, scored 10 points in FlappyBat and offended the girl with silence due to the fact that after Android with its push notifications, checking mail once an hour does not suit my active lifestyle a little. Masha, forgive me for my silence, I really did not know how the mail on WP works .

A little surfing did not cause disgust: the sites open, JS is running and almost does not freeze. The quality of communication (by the way, MarketPlace has all kinds of SpeedTest) at the level of all my previous devices: thick walls and the number of active mobile Internet users make themselves felt: the pages are loaded, but downloading applications and videos will make you sad.
Lyrical digression

After class, I went to visit my sister. Passing through the hall, I noticed stands for applicants and I caught my eye ...
Flyer with brief information on the direction of Software Engineering
(Picture taken at Lumia 710)

It turns out that I have to become a high-class specialist who knows a lot of things. I hope that the subjects related to the above, will begin with the third year. I was very pleased with the information about who the graduates of the field work with (there is simply no undergraduate program engineering at LETI just a couple of years and there are no graduates as such).
A little bit about the cards

The way to my sister was not long, and I tried to use standard maps. To the credit of the manufacturers of the GPS chip, where I - the device identified immediately, but the standard maps grieved me. Street names written in transliteration - seriously?
But it was still too early to be discouraged: at my services are widely advertised Nokia Maps. The names of the streets are already in Russian, but public transportation still needs to be found (this is a “layer”), and from the transport itself only the metro and trams. How to set the route to the point, I did not understand, and clicking on a point on the map caused the application to crash.
But after all, Gandalf in the form of the Marketplace and the Rohyrr cavalry, represented by Yandex.Maps, hasten to my aid. It seems that everything is fine, except that there is no “walking route” and, therefore, public transport.
I had to shove my topographical cretinism and craving for geolocation far away, just by taking the subway, and not abruptly cut off by a minibus. While I was getting (about forty minutes) the device was finally discharged from surfing.
Nice couple in the subway
(Picture taken at Lumia 710)
Less than a working day of active use: very unusual after Android, which pulled out two days.

Second day


On the second day, we were told about classes and interfaces, listed primitive types, base classes and the most useful libraries, taught how to handle exceptions, and explain what GC is. It seems that I knew all this, but it was really interesting to listen. No one even distracted from the lecturer.
Photos from the scene
(Picture taken at Lumia 710)

And during the break, a window was discovered. That is not a window, but an open door to the roof. Well, what student does not photograph on the roof? By the way, I didn’t take a picture, but my classmates were attacked by a crazy cormorant there.
Photos from the roof of the university
(Picture taken NOT on Lumia 710)

After the lecture, there was a surprise for all of us: there will be no more theoretical lessons, and in ten minutes you need to meet with a graduate student and decide on practical tasks.
Can you poorly tell the whole basis of Java in five hours? Of course, books and references were given for home reading, but ... Although if you think about it, "The general principles of all languages ​​are the same, a real programmer needs 4-5 days to master a new language."
Meeting with a graduate student was an ordinary acquaintance: they determined the level of knowledge, called the names and email of the headman.
The practice turned out to be divided into two parts: the implementation of the work already done in Java and the development of a new project in the team, using Git to synchronize the code and Redmine for setting the tasks.
Soon all the rules were laid out in the VC, and the headman kindly added links for those who have not come across Java before.
Screenshot from VK

Interlude


It just so happened that I was in the team of experienced students: one is already working as a java programmer, and the second one passed the last academic year laboratory on Algorithms and Data Structures exclusively in Java, and I have already come across this language.

Third day


And now the first act began: the deadlines are set, the brigades are determined, and the photoshop masters are already photoshop
Screenshot from VK

And in my team, meanwhile, passions are raging. What should we program such? What do we do to make the game, we decided immediately and almost unanimously. But what game?

The discussion was long, but in the end we decided to do a mini-old school-hardcore-rpg. I have compiled even a small list of the advantages of this idea.

On that and decided. But then the problems started ...

Interlude


It just so happened that each of us had our own programming style. Someone did not tolerate wasting space, (operator brackets, when only one condition is for weaklings), but you, if there is no space before the operator bracket. I hate a large number of classes, and someone was ready to create a package to put in it the “main parent class”, at the same time using ONLY setters in constructors. Trying to look at things sensibly, I understood that the educational project with a probability of 99% will remain so: no progress after graduation, a minimum of code reuse. But, when you have been working on one project for a year already, you will be ready to exclaim “just first you need to write a framework”, because “well, how to write a game without a framework”. Fortunately, the world has come: we write, as everyone knows, then we cooperate and do not utter the word "framework" aloud.

Day four


While my classmates were engaged in the first task, I was absorbed with the idea to show that writing the basis for the game is not so difficult. Moreover, the entire code sample was given on Habré .
In fact, I slept all day, and began to work only in the evening.
For a couple of hours I prepared a demo:

List of classes and a screenshot of the demo

The demo of my team was a little inspired. But, of course, they did not like the code: after all, I wrote a sketch. I had to convince for a long time that the FireBall should not be a successor of the class Unit. I finished at night, and in the morning I had already passed the first task (algorithm in Java). I had to remake the RPG demo for finding the path with the wave algorithm.

Fifth day


It began for me somewhat late and original. Programming at night is good, but only if you set the alarm not on the Nokia Lumia 710. I overslept the meeting with the graduate student, fortunately, you could take the work remotely, but for now ...
He woke me to a knock on the door: my team decided that it was not possible to work at the university, you can do it in a dormitory, and came straight to my room.

The work went on a certain intersection of interests: I prefer to create classes as needed, and the guys began to create a system of classes for reserve. Fortunately, the fact that I fell asleep again slightly reduced my displeasure.
When I woke up again, we faced a group of problems:

With food, we figured out quickly: good, in St. Petersburg such services in bulk.
Life hacking
If you make friends with the DPS near your home, then there is a chance to get food for free.

We could have overcome IntelliJ IDEA, but time was expensive. So I had to quickly set up Git and get to work.
The third point is the eternal problem for many teams, we have found a compromise, which is what you want.
Other teams also did not sit idle and flooded the graduate student with questions.
Screenshot from VK

We worked in parallel: the guys rewrote my code in their own way, and I explained some points and suggested the foundation for the future functionality.
In the process, we even had to move to a more comfortable room.
Photos from the scene

The process of adapting my code was not easy. Fortunately, the food and the common cat were supported by our forces until the evening. And the wonderful live music did not allow my desire to kill everyone to break free.

Results of the day

Closer to the night, we approached the demo that I wrote:

But they had a comfortable and flexible class system and a more or less holistic view of what we want to get.

Interlude


Now, looking at this day, I understand that we needed to write a dizdok and decide on terminology (sprites, tiles ...). Subsequently, I was slightly surprised when I learned that the “Tile class” is a cell of the map into which other objects are placed, and the “Tile enumeration” is one square picture.

Sixth day


So, as Vkontakte had a lot of distractions, and e-mail was somewhat outdated, Slack was chosen for communication within the team: instant messages, convenient mobile client, support for notifications in Chromium Based browsers, integration with Git and other services (Drobox, etc.). ).
The sixth day met me with skills (fireball and treatment) and Logger, who beautifully notified me when life changed. Skills skills, only I didn’t really like animations. I had to photoshop and google.
Skill graphics

At the same time, I picked up a new set of graphics for the environment (from RPG Macker XP) and the player (from the same place).
And then I thought: AI write for a long time, but the game needs minimal playability to demonstrate what has been gained. Yes, and you need to somehow distinguish the game from the competition. Have you seen games with the good old screen splitting, and even RPG? I have long. For starters, I just added a second player. After that, I found an error in calculating the coordinates for the render (the displacement of objects was calculated incorrectly, given that Player 1 was always in the center).
When you do something interesting time, it flows very quickly: with surprise for myself, I found that it was five in the morning. After a couple of hours, I had to go to the university for another meeting with a graduate student ...

Sixth day


On this day, no one represented our team at the university: one classmate, like me, overslept, and the second was at work. But in vain: The graduate student distributed many valuable instructions based on the work already done. Of course, the instructions were duplicated for the sleepy public.
Screenshot from VK

But, we slept well and with new forces began to work on the project.
To begin with, a camera class was added to simplify rendering. True, he did not do anything, but he was ...
But the most important was the ability to navigate through the pixels, rather than the cells of the map. Thus, we slightly "updated" the style of the game. Because of this, many methods had to be rewritten: physics, rendering, collision detection ... Of course, this caused errors. Previously, a fireball was created on a cell from a player, now it began to appear on a pixel from a player and exploded on it. A kind of elegant way to suicide. And what were the cost of colliding with yourself (moving within one cell per pixel and checking it for employment)!

Interlude


Of course, so that we are not at all sad, comrade elder repost a group of funny pictures about Java.
Screenshot from VK

Seventh day


Again we have differences. And if we simply implemented the methods of the eighth Java in a separate package so that everyone can sit with his version of the JVM, then with the vision of logic, there were problems ...
Tatter two

I have such a character that from the moment I started writing in Java, I was afraid of memory leaks, re-reading articles on Habré over and over again, if I add the “Class for Classes” dislike to this, I can understand how I reacted to custom class point. Well, the point and the point, but the place of use ... Point represented the coordinates (x, y) and was used only in one place: to determine the position of the object (including the tile) in the render. I just howled: the render happens ~ 60 times per second, one render affects ~ 6400 cells, for the render of one point a new Point was created.
60 * 6400 = 384000
A couple of hundred thousand objects per second that will be used only once. Of course, for GC this is a small hindrance, but why not just use two int, in any case, working with a bunch will be faster. The problem was resolved by the introduction of a pool of objects.
Tension three

The next stumbling block was the change in the map system.
I imagined it like this:

First, we render the background (perhaps even caching), then static objects, then static objects, then static objects that are above dynamic.
Of course, for such a system, it would be necessary to sort the objects by Y (those objects whose Y is less under those who have it more).
Small example

My classmate replaced this system with a two-dimensional array of stacks. This gave flexibility to the number of render layers (as many layers of decals as you like), but it created problems when rendering dynamic objects (how to determine what needs to be drawn under the player, and what is above?). And if you recall the realities of our project, it turns out that only one element is stored in the stack. Again, in my opinion, the load is superfluous: running on 6400 stacks only for rendering one frame, and the problem with dynamic objects was not solved ... We agreed that we would leave the stacks, but otherwise we will follow my view.
Tension four

This was probably our biggest disagreement while working on the project. So I represented the game cycle:
  { int a =  ();  ();    (N -  () - ); } 

For sleep flow, I used the good old Thread.Sleep (); a working group mate did not agree with this in principle: at first he wanted to do without pauses at all. Continuous execution of the gaming cycle led to a 100% load on the kernel and ~ 2000FPS on powerful machines. I managed to convince him that the FPS should be limited, and the time elapsed since its last execution should be transferred to the execution of the game logic. Unfortunately, there were problems with Sleep: the classmate's dislike for Sleep and the problem with reading keystrokes. The code was rewritten to use Wait. Only, this did not solve the problem of a full kernel load, and my classmates decided to keep the FPS at 100 frames per second. To my joy, in the end, the code was rewritten to Sleep (the glory of multithreading to handle keystrokes), the physics and render calls are divided in time and the FPS is reduced to 60.

Seventh day


A merge of the branches was carried out, the cameras were refined and, most importantly, the code relating to the renderer and movement was refactored. The errors associated with moving by pixels instead of map cells have been completely corrected.
In addition, added debug to debug the render.
Collision Debugging Screenshot

Eighth day


I decided to add more dynamics to the game, namely: traps and a new tile. To see right away, I decided to use a map generator instead of an empty one. There was no need to sleep when we discussed and made the basis of the class system ...
First of all, I created a tile class (cell of the map) with a trigger method and updated the physics to work. But then the problems started ... I had to write a class for the graphic representation of the tile picture, add a tile picture to the enum and link them into the tile factory. At that time, as before, I would have managed with the class of the wall and floor, which was just transferred images for rendering.
Do all companies use Factory for every sneeze?
And then I found out that the map generator considers the enum with tile pictures, a set of possible entities (floor, wall ...).
After a couple of hours I had a working map generator and a gun that created fireballs around the button.
Shooting was just so boring, so I wrote just AI, who was chasing the player. So I found out that the method of death works. It was very disappointing when the AI, which I wrote, shot me from a cannon without knowing it ...

Day nine


On this day, we improved the current code. For example, added a system for deleting objects with a delay. After all, after the death of the bot, there should have been a corpse, which should also disappear after a while. And removing objects from a sheet while working with a sheet is not the most pleasant thing. Oh, this ConcurrentModificationException ...

Tenth day


Finally, upon hearing my requests, a split of the screen and work with several cameras and the output of damage to the players were added.
Screenshot of the split screen

But HP did not have time to add the HP mapping.
Outline of health and mana indicator

The practice ended, and we did not have time to add anything else ...

Eleventh day


The process of putting the work was a mere formality. The graduate student had access to the repository and already had an idea of ​​what to expect from whom.
Photos from the scene
(Picture taken at Lumia 710)

The only hitch was the question of what to write in the record book: "credit" or assessment ...
Result photo
(Picture taken at Lumia 710)

We assume, and God disposes


So you can mark the summer practice and the use of Nokia. The summer practice did not go at all as I had supposed: the feverish first task, together with the not completely completed second one, left a note of dissatisfaction. I was very upset by a small amount of theoretical material, because I can learn myself outside the framework of practice. Despite very different programming styles, I am pleased with the experience of team work with group mates and teamwork on GitHub (although I’m still confused in terms of terms), Slack (very pleased with the integration with Yandex Browser) and Redmine. I used to just use notes in .txt and // TODO. Now, I understood the convenience of a system like Redmine: you can't keep everything in your head.
And Lumia? What can you say about the smartphone, which is already gray in the OS ? When I bought SE Vivaz on Symbian, I was waiting for this from a smartphone ... Now, after the notorious Vivaz and several smartphones on Android, the 710th seems like a two thousandth greeting. I hope that Windows Phone 8.1 looks more worthy of its ancestor (I know the history of WP from this article ).

Mistakes that we caught while developing the game



PS


Part of the story has been changed, and some events are moved in time for the integrity of the story.
I will gladly correct any errors if you write to me in the LAN. I will be glad to any criticism, as well as the code, and the text. I will try to answer every question. Alas, my classmates on Habré no.
Perhaps the story contains a lot of water and too much, but the goal was to show the real learning process, not a spherical WINstory. I am very sorry for the somewhat confused style of narration and the JPG in the cap of the post, the original has been deleted, and once again I’m not able to do photoshop.

Links



')

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


All Articles