As in the Magical Electrotechnical practice on Java passed a little about Lumia 710

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


    This text will tell my story from my perspective. It is recommended for reading to distract from serious affairs and as tablets of realism for applicants.


    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 already work with Java and was going to practice a little systematization of my knowledge in a voluntary-forced manner during practice. I planned to describe each of the days of practice, how the smartphone proved to be. After the third day, I planned to upgrade the smartphone to 7.8, but life made its own adjustments ...

    The first day

    It started for me a little later than for the rest. And just wanted to remember the development of Android in the evening. But as they say, being late by less than an academic hour is not being late.
    I was met by a familiar audience and a lot of students already tasting the delights of Java.
    Photos from the scene
    (Photo taken at Lumia 710)

    Results of the first lecture

    Of course, the first day of classes after rest (session) did not carry fundamental knowledge. We were briefly told about the history of Java, areas of application; recalled the main OOP paradigms and language syntax features. In short, the first day can be safely called "Introduction to Java and the next Hello World." At the same time, we were told that we will conduct practical classes under the supervision of practicing graduate students, whom they will introduce to us on Wednesday.
    Life is cruel: there cannot be much good: a lecture ended in three hours, instead of the expected five. But of course, it was not in vain that I spent these three hours ... (minus fifteen minutes late and fifteen minutes break).
    First impressions of Lumia

    Acquaintance with Lumiya did not go as smoothly as I would like. I used to see devices on WP only in pictures, but I was hoping that the experience of several androidphones and a symbian would help me. I logged in to Lumiya for a long time, but everything I did with it until this moment - it only played in the FlappyBird clone.

    What device pleased me at the lecture? First of all, I entered Yandex.Mail through a standard application. The device was adapted for the Russian consumer, and it was possible to indicate that mail on Yandex (apparently, having deprived itself of the pleasure of entering a POP3 server) is easyhaving dealt with the authorization (guess, you need to enter your Yandex username or email address in the "username" field) I was forced to contemplate the inscription "mail is being synchronized" for about fifteen minutes. To the credit of the developers, the letters over the past two weeks have really downloaded to the device. Having found a “connection” (as I thought), the time has come to go to the Marketplace in more detail. Do you know what they write about the Market? It seems to have everything, but there is nothing. I installed a couple more time-killers (a Doodle Jump clone and a Portal Ball puzzle) and a VK messenger. With the popularization of html5, it so happened that the number of standalone applications on my devices decreased, but I tried to go over the list of applications I needed. With a limited WP7 API for applications like LlamaI don’t have to hope, but I found the SSH terminal with ease, but the BT terminal ... ( well, you know )
    Mini summary

    And here you can diverge: the smartphone is discharged up to 20% (in three hours of active use), I haven’t heard anything new about Java, scored 10 points in FlappyBat and offended the girl in silence due to the fact that after Android with its push notifications, check Mail once an hour is a bit unsuitable for my active lifestyle. Masha, I'm sorry for my silence, I really didn’t know how mail works on WP .

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

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

    It turns out that I have to become a highly qualified specialist who knows a lot of things. I hope that the subjects related to the above will start from the third year. I was very pleased with the information about who graduates work in (the bachelor's degree in Software Engineering at LETI is only a couple of years old and there are simply no graduates as such).
    A bit about cards

    The path to my sister was not a short one, and I tried to use standard maps. To the credit of the GPS chip manufacturers, where I determined the device right away, but the standard maps upset me. Translit street names seriously?
    But it was too early to lose heart: at my service there are widely advertised Nokia Cards. The street names are already in Russian, but public transport still needs to be found (this is the “layer”), and only the metro and trams from the transport itself. I did not understand how to set the route to the point, and clicking on a point on the map caused the application to crash.
    But after all, Gandalf in the form of Marketplace and the cavalry rohirr, presented by Yandex.Maps, are hurrying to help me. It seems that everything is fine, only without the “walking routes”, and therefore public transport.
    I had to shove my topographical cretinism and craving for geolocation to hell, just getting on the subway, and not abruptly cutting off on a minibus. While I was getting (about forty minutes) the device was completely discharged from surfing.
    Cute couple in the subway
    (Photo taken at Lumia 710)
    Less than a day of active use: very unusual after Android, which stretched out for two days.

    Second day

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

    And during the break, a window was discovered. What is not a window, but an open door to the roof. Well, which student does not take a picture on the roof? By the way, I was not photographed, but my classmates were attacked there by a crazy cormorant.
    Photo from the roof of the university
    (Photo taken NOT at Lumia 710)

    After the lecture, a surprise awaited us all: there would be no more theoretical classes, and after a dozen minutes, we needed to meet with a graduate student and decide on practical tasks.
    You are not enough to tell the whole basis of Java for five hours? Of course, books and links 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 learn a new language."
    The meeting with the graduate student was a usual acquaintance: they determined the level of knowledge, gave the names and email of the headman.
    The practice turned out to be divided into two parts: implementing the work already done in Java and developing a new project in a team, using Git to synchronize the code and Redmine to set tasks.
    Soon, all the rules were laid out in VK, and the headman kindly added links for those who had not encountered Java before.
    Screenshot from VK


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

    Day three

    And now the first act has begun: the deadlines are set, the brigades are determined, and the Photoshop masters are already photoshopping ...
    Screenshot from VK

    And in my team, meanwhile, passions boil. What do we program that kind of? What to do, we will make the game, we decided immediately and almost unanimously. But what game?
    • A game with teleports, like the one on Nokia
    • A game about a wandering electron (I still did not understand what it was)
    • Space Shooting Using a Web Camera

    The discussion was long, but in the end we decided to do a mini-oldschool-hardcore-RPG. I even made a short list of the advantages of this idea.
    • Graphics are easy to find online
    • Logical division of work
    • Everyone will be able to take on a task for themselves when the base is ready (add enemies with their AI, add levels, add traps)

    They decided on that. But then the problems started ...


    It so happened that each of us had our own style of programming. Someone did not suffer a waste of 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 place the "main parent class" in it, at the same time using ONLY setters in the constructors. Trying to take a healthy look at things, I realized that a training 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 “only you need to write a framework first”, because “how to write a game without a framework”. Fortunately, the world has come: we write, as everyone knows,

    Day four

    While my classmates were engaged in the first task, I was absorbed in the idea of ​​showing that writing the basis for the game is not so difficult. Moreover, the entire code example was given on Habré .
    In fact, I slept all day, and began to work only in the evening.
    In a couple of hours I prepared a demo:
    • Managed Player (Walking + Shooting)
    • Moving camera
    • Bot (move to a point)
    • Fireball (bot with moving to one point)
    • Resource Manager (loading and caching tiles)
    • Render (with animation support)
    • Random card generator

    Class List and Demo Screenshot

    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 persuade for a long time that FireBall should not be the descendant of the Unit class. I finished by night, and in the morning there was already the delivery of the first task (an algorithm in Java). I had to redo the RPG demo to find the path using the wave algorithm.

    Fifth day

    It began for me somewhat late and original. It’s good to program at night, but only if you didn’t set the alarm on Nokia Lumia 710. I overslept a meeting with a graduate student, fortunately, the work could be done remotely, but for now ... The
    door woke me up: my team decided to work at the university failed, you can do it in the hostel, and they came directly to my room.

    The work went at some intersection of interests: I prefer to create classes as needed, and the guys started to create a class system for the reserve. Fortunately, the fact that I fell asleep again slightly reduced my discontent.
    When I woke up again, we faced a group of problems:
    • Decide what to order from food
    • Convince IntelliJ IDEA to work with the project folder that is on FTP
    • Find a compromise in code formatting and class numbers

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

    We might have overcome IntelliJ IDEA, but time was expensive. Therefore, I had to quickly configure Git and get to work.
    Point three is an eternal problem for many teams, we have found a compromise, which is what we wish for.
    Other teams also did not sit idle and bombarded the graduate student with questions.
    Screenshot from VK

    We worked in parallel: the guys rewrote my code according to their concepts, and I clarified some points and suggested the foundation for 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, food and a common cat supported our strength until the evening. And beautiful live music did not allow my desire to kill everyone to break free.

    Day results

    Closer to the night, we approached the demo that I wrote:
    • World render
    • Resource manager
    • Managed Player
    • Animation Support

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


    Now, looking at this day, I understand that we needed to write a dzdok and determine the terminology (sprites, tiles ...). Later, I was a little surprised when I found out that the “Tile class” is a cell of the map in which other objects are placed, and the “Tile class” is one square picture.

    Sixth day

    Since Vkontakte had a lot of distractions, and email was a little outdated, Slack was chosen for communication within the team: instant messages, a convenient mobile client, support for notifications in Chromium Based browsers, integration with Git and other services (Drobox, etc. )
    The sixth day I met with skills (fireball and treatment) and Logger, who beautifully notified when changing lives. Skills, only now I didn’t really like the animation. 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 there).
    And then I thought: AI write for a long time, and the game needs minimal playability to demonstrate what has been gained. Yes, and you need to somehow highlight the game against competitors. Have you seen games with the good old screen split, and even RPG? I have long been. For starters, I just added a second player. After that, I found an error in calculating the coordinates for the render (the offset of the objects was calculated incorrectly taking into account the fact that Player 1 was always in the center).
    When you do something interesting, the time flows very quickly: with surprise for myself, I found 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 gave a lot of valuable directions based on the work already done. Of course, the directions were duplicated for a slept public.
    Screenshot from VK

    But, we had a good night's sleep and started working on the project with renewed vigor.
    First, a camera class was added to simplify rendering. True, he did nothing, but was ...
    But the most important was the ability to move around the pixels, not 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 also caused errors. Previously, a fireball was created on the cell from the player, now it began to appear on the pixel from the player and exploded about it. A kind of elegant way to kill oneself. And what was the cost of a collision with oneself (moving within a single cell per pixel and checking its employment)!


    Of course, so that we would not be sad at all, the headman reposted funny pictures about Java to the group.
    Screenshot from VK

    Seventh day

    Once again, we have disagreements. And if we simply implemented the methods of the eighth Java in a separate package so that everyone could sit with their version of the JVM, then there were problems with the vision of the logic ...
    Stumbling two

    I have such a character that from the moment I started writing in Java I was paronoid of fear of memory leaks, over and over again re-reading articles on Habré , if we add to this hostility "Class for classes," you can understand how I reacted custom point class. Well, a point and a point, but the place of application ... Point was the coordinates (x, y) and was used only in one place: to determine the position of the object (including the tile) during rendering. I just howled: rendering occurs ~ 60 times per second, one rendering affects ~ 6400 cells, a new Point was created for rendering one point.
    60 * 6400 = 384000
    A couple of hundred thousand objects per second, which will be used only once. Of course, for GC this is a little hindrance, but why not just use two ints, in any case, working with a heap will be faster. The problem was resolved by introducing a pool of objects.
    Stumbling three

    The next stumbling block was the change in the map system.
    I imagined it like this:
    • Two-dimensional array with objects backgrounds, walls
    • A sheet of static objects (decals) such as flowers or any stones
    • A sheet of static objects 2 (decals that are OVER the players) such as arches or ceilings
    • List of dynamic objects such as players, bots

    First, we render the background (possibly even caching), then static objects, then static objects, then static objects, which are above dynamic ones.
    Of course, for such a system it would be necessary to sort the objects by Y (those objects whose Y has less are under those who have more).
    A small example

    My classmate replaced this system with a two-dimensional array of stacks. This gave flexibility to the number of render layers (any number of decal layers), 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 on the stack. Again, in my opinion, the load is superfluous: mileage on 6400 stacks is only for rendering a single frame, and the problem with dynamic objects was not solved ... We agreed that we would leave the stacks, but for the rest we will follow my idea.
    Stumbling four

    This was probably our biggest disagreement while working on the project. So I imagined the game loop:
    Вечный цикл{
    int a = текущее время();
    игровая логика();
    сон потока на (N - текущее время() - а);

    To sleep the thread, I used the good old Thread.Sleep (); a working classmate fundamentally disagreed with this: at first he wanted to do without pauses at all. Continuous execution of the game cycle led to 100% kernel load and ~ 2000FPS on powerful machines. I managed to convince him that FPS needs to be limited, and to transfer the time elapsed since its last execution to the execution of game logic. Unfortunately, there were problems with Sleep: just a classmate's dislike of Sleep and a problem with reading button clicks. The code has been rewritten to use Wait. But this did not solve the problem with a full kernel load, and my classmates decided to support FPS at 100 frames per second. To my joy, in the end, the code was rewritten to Sleep (the glory of multithreading for handling keystrokes),

    Seventh day

    A merge of branches was carried out, cameras were finalized and, most importantly, code refactoring related to rendering and moving was done. Errors related to moving around pixels instead of map cells have been completely fixed.
    In addition, added debug for debugging the render.
    Screenshot of Collision Debugging

    Day eight

    I decided to add more dynamics to the game, namely: traps and a new tile. To immediately see, I decided at the same time to use a map generator, instead of an empty one. There was no need to sleep when discussing and making the basis of the class system ...
    First of all, I created a tile class (map cell) with the trigger method and updated the physics so that they worked. But then the problems started ... I had to write a class to graphically represent the tile image, add a tile image to the enum and link them to the tile factories. At that time, as before, I would have managed with a class of wall and floor, which simply transferred images for rendering.
    Do all companies use Factory for every sneeze?
    And then I found out that the map generator considers enum with tiles as 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 just was boring, so I just wrote the AI ​​that chased the player. So I found out that the method of death works. It was very disappointing when the AI ​​I wrote shot me out of the gun, without realizing it ...

    Day nine

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

    Day ten

    Finally, upon hearing my requests, split-screen and work with multiple cameras and damage output to players were added.
    Screenshot of Splitscreen

    But the display of HP, alas, did not have time to add.
    Health and Mana Indicator Sketch

    The practice ended, and we didn’t have time to add anything else ...

    Eleventh day

    The process of submitting work was a pure formality. The graduate student had access to the repository and already knew what to expect from whom.
    Photos from the scene
    (Photo taken at Lumia 710)

    The only hitch was the question of what to write in the grade book: “credit” or assessment ...
    Result photo
    (Photo taken at Lumia 710)

    We assume, and God disposes

    So you can denote the summer practice and use of Nokia. The summer practice was not at all what I expected: the hectic first assignment, coupled with the incomplete second, left a hint of dissatisfaction. Very upset by the small amount of theoretical material, because I can self-learn and beyond the scope of practice. Despite the completely different programming styles, I am glad of the experience of team work with classmates and collaboration on GitHub (although I still get confused in terms), Slack (very pleased with the integration with Yandex.Browser) and Redmine. I used to just use notes in .txt and // TODO. Now, I realized the convenience of a system like Redmine: there’s nothing to keep in mind.
    What about Lumia? What can you say about a smartphone that already has gray hair in the OS? When I bought SE Vivaz on Symbian, I was expecting exactly that from the smartphone ... Now, after the notorious Vivaz and several smartphones on Android, the 710th seems like a greet of two thousand. I hope that Windows Phone 8.1 looks more worthy of its ancestor (I know the history of WP from this article ).

    The bugs we caught while developing the game

    • Diagonally moving (first we check the displacement on one axis, after - the displacement on the other)
    • Ability to repeatedly call the death method
    • Lack of life checks with some methods (thanks to zombie bots)
    • Checking for intersection of objects at only one point, not four
    • Collision of objects with themselves
    • Aggressive entities (e.g. fireball) inflict damage on their creator, appearing near him.


    Part of the story was changed, and some events moved in time for the integrity of the narrative.
    I will gladly correct any errors if you write to me in the PM. I will be glad to any criticism, as well as code and text. I will try to answer every question. Alas, my classmates are not on Habré.
    Perhaps the story contains a lot of water and excess, but the goal was to show the real learning process, not the spherical WINstory. I really apologize for the somewhat messy style of storytelling and JPG in the header of the post, the original has been deleted, and once again I can no longer photoshop.


    Also popular now: