📜 ⬆️ ⬇️

Flash game "Mafia" in the conditions of "in contact"

The purpose of this article is to describe the process of creating an application, using the example of my game “Mafia” under “In Contact”.
For those who do not know (although I personally very much doubt that there will be such) what kind of game I recommend reading its description on Wikipedia .

If you know what As3, Flex, Java, multithreading, constant socket connection is, or you just wondered how to write flash-games, then I think the post is for you!
There are also some statistics under the cut.


I am a fan of "Mafia"


That's what I call myself since I first played it. All my fellow students were fans, and this is also not surprising - everyone played “mafia”! When I began to professionally develop Flash-games, I thought about writing my own version of the game. But all the time something was missing. However, this thought always served as a background for everything I did.
')

Helped "Crocodile"


Since there was an idea, I constantly monitored its implementation on the Internet. But whatever option I came across - all the time something did not suit. One drawback united almost all versions - they were quite complicated. And I wanted to create such a game so that the user simply, without thinking about anything, came in and immediately started playing. And this was helped by Crocodile - a simple realization of a stunning idea! “Hanging up” for a few days on the green tail of the contact “Genes”, I found the missing link and began writing my own Flash version of “Mafia”. But there was another auxiliary point: it so happened that shortly before work began, I was asked to help in the implementation of the game based on the written literary story. However, everything turned out to be much more complicated than it seemed (an online RPG with a large number of monsters on the map), and there were not enough flash features. The project went to "no", but the development remained. It was these developments that were useful to me when writing “Mafia” under “V Kontakte”. Combining my development with the principle of the game "Crocodile", I got what I have now.

Design


I did not have funds for professional services, and I don’t have it now. Therefore, I used my abilities: I painted everything myself right in the flash. The girlfriend helped a little - the second version of the icons was slightly modified by her.

What tools did I use to implement the idea?


  1. Resources, graphics - as I said, Adobe Flash 4.
  2. Client code - Action Script 3. Development conducted in the environment of Flex.
  3. Server - wrote in Java. Here I want to say why I chose Java. - It's simple. Looked on the internet for Java and C ++ performance tests. They were not much different from each other, but Java is very similar to Action Script 3, which was the main selection criterion. However, later this choice turned into advantages for me personally:
    1. The speed of development has increased, because the switch time between languages ​​was minimized.
    2. In Java, the system of working with memory is automated, but for me, as not a fan of unnecessary problems, this is good.
    3. The overall development time has been reduced, since Java has many specialized classes provided by language developers. Why reinvent the wheel if it was already invented before me?
    4. A multi-threaded server written in C ++ is a rather laborious thing compared to the same thing in Java.
    5. Java prohibits not to handle exceptions (try / catch construction).
  4. Communication between the client and the server is done via a permanent socket connection, and not on http requests, as is customary in most cases.
  5. Music - written by a professional composer-arranger in the framework of sponsorship.


Project structure


The game is built on the principle of horizontal scaling, at least, I tried to adhere to this principle, because the application was written under "V Kontakte", where the audience of potential users is very large. The week after the launch of the game showed that the audience is growing like an avalanche, which means that I was right: in less than a week, more than 15,000 people played the game (without advertising and promotion - just friends!), While the minimum number of players is 200 person; The maximum number of players simultaneously online during this time was 600 people. To serve this entire audience, there are now enough two “daemons” (server instances) that work independently of each other. With increasing load, I plan to increase the number of "demons", and, in turn, carry them across servers.

Terms of writing the game


The game was written in 2 weeks (taking into account the fact that I used the preliminary designs - as I wrote above).

trial version


In conclusion, I want to say that from a technical point of view, the game is launched in the beta version: all the processes are being debugged in the face of increasing load; in parallel, the game play is improving; balanced team strengths. I want to ensure that everyone was pleased to play.

Resources (statistics)


The game is running on a dedicated server (sponsored by a friend).
Server Specifications:
  1. Intel Xeon X3440 2.53GHz
  2. 8 GB RAM
  3. mother of intel s3420gp

One "daemon" consumes with a minimum load of 0.3% of the processor and 2% of RAM. With increasing load increases the load of RAM. Processor load varies in tenths of a percent (up to 0.5). At the same time, the server is not burdened by other projects.

Link to the game

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


All Articles