How I did a football simulator for 13 years
The story that I will tell began 13 years ago in an informatics class. My seventh graders and friends solved all the problems in Pascal and played fun in the first Quake. Our teacher saw it, came up to me and said just one phrase, which twisted my picture of the world: “If you want to play games in the classroom, write them yourself”. Since then, I occasionally make games. One of them - a football simulator, which will be discussed.
This is a fascinating story about my development path, unfinished projects and why sometimes they don’t need to be completed.
Disclaimer: since the events described in this text, I made a course on developing on Unity and laid out a few of my games on Google Play and the Windows Store. Now I am the editor of the Yandex.Money blog and am telling this story in order to share my experience with the community.
In the Russian-language game dev of those times there was an interesting feature - MS DOS was almost over and domestic programmers were actively sawing toys for Windows. There were a lot of computer simulators, tanks, various card and "logical" games. And massively sold discs with these games. About how such collections were compiled, a little is written in the Testers Chronicles, but then I did not know about it yet.
Surely many of you remember this wonderful menu:
Life, of course, patted him
On one of these CDs, I first met Coach, a text-based football manager. There you could take any team from the English Premier League and try to bring it to the championship. And this game was distributed in the shareware model: it was possible to play two seasons, and then pay. Of course, it was not possible to pay in any way, because for this it was necessary to send a bank transfer to the creator of the game, and at the age of 13, you don’t even go to the bank, you don’t even think about it. Yandex.Money then already existed, but before the appearance of the Cashier there were 8 years left, therefore it was also inconvenient. My friends and I played for two seasons, and then we started again.
I had to look for a solution, and in the process I wrote one of my first games - Coach, with a more interesting Russian league for me, a cup and a bunch of bugs. I did not change the name, I just changed the two to three. It turned out like this:
Coach 3 v2.52
What does any football team need? Of course, the players. Naturally, no one knew about any licenses for clubs and players then - we just got together with a classmate and made lists of teams from memory. Therefore, for example, CSKA and Spartak still had 11 people (yes, it was a simulator without replacements), but Luch-Energiya from Vladivostok was left with empty plates instead of players.
As I remember: in 2005, I armed myself with a computer science textbook for the 9th grade (there was just about my favorite Visual Basic 6) and opened the form editor - I learned the word IDE much later. I dragged the button onto the form, clicked and opened the code editor. Proud of myself i typed
PrivateSub Command1_Click() EndEndSub
and clicked "Run." Everything worked and I was very pleased. After a while, a text football simulator appeared - Coach v2.52.
Lawyers from the RPL, if you are reading this, this game has never been published or sold for money
Then it seemed to me that this is the pearl of the program code. Of course, at that moment I did not know much and, for example, the standings were stored in six arrays from Label right on the form. No saving, no variable arrays - just hardcore. Naturally, this caused strange bugs:
All teams played 2 matches, but some of them were 3, and others were one
You could also buy Roy Keane and Andriy Shevchenko in Spartak. Not sure what it was even in one football simulator of the time
In general, imagine that you suddenly forgot how to use databases, write something to text files and store data in arrays. The only thing left is the controls on the forms. Fearfully? And somehow the weekdays of a seventh grader looked like that he decided that he could go to game devs.
I have no source for this version, but I am sure that there was something like this:
m = Form1.Label5(0).Caption Form2.Label3(m).Caption = Form2.Label3(m).Caption + 3
About some features of VB6 in the textbook did not write. Therefore, for example, when I found out that Shape can be poured in various ways, I made a whole window for it with a choice of lawn at the club stadium:
And would you be able to cut the lawn on a flute on a wall tube?
Important moral # 1 - explore the capabilities of the tools you use every day.
I was sure that once I would send this game to some kind of multiplayer - so I even wrote a certificate. Of course, it was then seen by two and a half testers. But since it happened - let it be published.
Coach 3 V2.08 - 2006 Edition
Hello! Thank you for purchasing this game.
3.Test Platform 4.What's
7.Thank you so much ...
Run the Setup.exe file and unzip the files into the folder with: \ Program files \ Football Manager 2005
And then unzip the file setup2.exe
No P4-2500. Everything is extremely simple. So,
Pentium 1-233 MHz (рекомендуется 300 и выше)
16 MB RAM (рекомендуется 32 и выше)
Video 16 MB
Windows 9x,Me,NT,2003,Longhorn. На XP работает только при наличии файла msvbvm60.dll в корневом каталоге с:\windows\system
Celeron 1100 MHz
160 MB RAM
Windows XP SP2
Cделал много нового.
Например, теперь в чемпионате России участвуют 14(!) команд вместо 8.
Изменен диалог "Команда«, появилось меню о тренере клуба.
Теперь игра ЗАВИСИТ от тактики!
Впервые со времен Coach 1 вам нормально начаисляются очки.
Лига Чемпионов.Супер-Кубок России.
Не изменяйте и не удаляйте файлы из папки с:\program files\football manager 2005\clubs\emblems
После установки скопируйте файл MSVBVM60.DLL в папку c:\windows\system
Деинсталляция не требуется.Просто сотрите папку с игрой.
Кушербаеву Данияру за бета-тестирование.
Карнееву Михаилу, Трофименко Михаилу за бета тестирование и ценные советы.
Сайту rfpl.org за форму команд Премьер-Лиги.
P.S Наши победят!
If I knew that I would return to this project over the next 13 years, then, of course, I would be more responsible in preserving everything connected with it. Nevertheless, Coach 2.5 remained in history and runs even now, right from the folder that is called:
E:\prod\dev\My_old_dev_projects\Dev\Старые игрули,но работают
Surely there were earlier versions, but I had nowhere to back up, and the source code until 2005, together with their earlier versions, was lost once when a 2.3 GB hard drive failed. nostalgic sighs And remember, when to put Blood 2, you had to erase Age of Empires 2?
Screenshot version 1.62. If Windows 10 1803 was released in 2004, then I would not have this toolkit either
Important moral # 2 - make backups.
And most importantly - the gameplay. Random events that do not depend on anything — this is what grabbed attention to the long hours of development and testing. And we tested it like that - we played it until something ridiculous falls off.
Do not ask what attack points are. I do not remember
See that nervous pink square? Now I will tell about him.
"Shinnik" and a visual football simulator
Together with Coach on those disks two more games spread. The first - “FC Shinnik” from Evgeny Sharov - it was a mediocre team management, but you could watch the match. Judging by the captions, it was also done for quite a long time - from 1996 to 2000. The second game was the dosovsky “Football 4 × 4” - there was absolutely nothing impressive except running people, but it fascinated me so much that I decided to do the same a game for yourself.
At first, due to lack of experience, a pink square appeared. He moved across the field, indicating where the game is going now. And, like, even influenced something. It was not enough and I made the second football project in my life - Football View.
Yes, yes, they are smeared banners. In the past decade, this was somehow simpler.
Riddle - how to move players around the field all the time, when it is impossible to hang a separate script on each person, which will take into account the position, neighbors and distance to the ball? The answer is to use a timer and twist players in a cycle, randomly shifting them to the width of the sprite. The code is straight from 2005, so I am now very ashamed.
PrivateSub Igroki_Timer() k = k + 1 ′ движения игроков For i = 1 To8Randomize (x) x = Int(Rnd * 4) If x = 1 Then Image2(i).Top = Image2(i).Top — 360If x = 2 Then Image2(i).Top = Image2(i).Top + 360If x = 3 Then Image2(i).Left = Image2(i).Left + 360If x = 4 Then Image2(i).Left = Image2(i).Left — 360 y = Int(Rnd * 4) If y = 1 Then Image3(i).Top = Image3(i).Top — 360If y = 2 Then Image3(i).Top = Image3(i).Top + 360If y = 3 Then Image3(i).Left = Image3(i).Left — 360If y = 4 Then Image3(i).Left = Image3(i).Left + 360 ′ остановка и пас If Image2(i).Top = Image1.Top And Image2(i).Left = Image1.LeftThen Igroki.Enabled = False: pas_vpravo.Enabled = TrueIf Image3(i).Top = Image1.Top And Image3(i).Left = Image1.LeftThen Igroki.Enabled = False: pas_vlevo.Enabled = True ’ уход за верхнюю линию и нижнюю линию If Image2(i).Top <= 1080Then Image2(i).Top = Image2(i).Top + 720If Image3(i).Top <= 1080Then Image3(i).Top = Image3(i).Top + 720If Image2(i).Top >= 4320Then Image2(i).Top = Image2(i).Top — 720If Image3(i).Top >= 4320Then Image3(i).Top = Image3(i).Top — 720 ′ Уход игроков за левую линию и правую линию If Image2(i).Left <= 480Then Image2(i).Left = Image2(i).Left + 3720If Image3(i).Left <= 480Then Image3(i).Left = Image3(i).Left + 3720If Image2(i).Left >= 6600Then Image2(i).Left = Image2(i).Left — 3720If Image3(i).Left >= 6600Then Image3(i).Left = Image3(i).Left — 3720Next i EndSub
Important moral # 3 - write clear and detailed comments.
Another timer checked that the match was over:
If Val(Label5.Caption) = "90"And Val(Label2.Caption) > Val(Label1.Caption) ThenMsgBox ("Матч окончен.Победила команда" + Label3.Caption): End
And now - the worst. The ball was moving around the field by four timers, which were called pas_vverh, pas_vniz, pas_vpravo and pas_vlevo. Some now twitched eyes, others urgently went to re-read Stroustrup, others asked the dumb question - “But we see that the ball does not move up and down on the gif.” Of course, because I could not properly coordinate the four timers among themselves.
I am looking at the code now and I understand that it even provides for indirect control of the ball , but it does not work.
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If (KeyCode = vbKeyLeft) Then pas_vlevo.Enabled = TrueIf (KeyCode = vbKeyRight) Then pas_vpravo.Enabled = TrueIf (KeyCode = vbKeyUp) Then Pas_verh.Enabled = TrueIf (KeyCode = vbKeyDown) Then Pas_vniz.Enabled = TrueEnd Sub
All my ninth and tenth grades, my classmate and I were busy writing a simulator of the operating system, so hands did not reach football. “Yes, this is for chickens to laugh,” I thought, when in 2009 I still dug up the old version, “You need to rewrite everything from scratch.”
How do I refactor non refactored
Rewriting from scratch is a great idea when the project is small and there are a dozen ways in the head to make it better and more convenient than it was. I needed a perfect text football simulator, and of course, everything went wrong again.
In 2009, it became easier with the Internet, and I went to the RFPL website and began to think how to pick up teams that were stored in this form:
I didn’t know how to get it then, parse the pages too, but I knew very briefly about xml and csv. Therefore, the technical solution was very strange:
- Use your hands to copy the contents of the page and paste it into Excel. Information on each player occupied four lines, and somewhere nearby was a photo. I did not use them and easily disposed of.
- All the lines from Excel needed to be copied to a text file parse.txt
- A parser was written that read the file line by line and scattered information about the players on four lists - at the nominal position on the field.
- All these lists were saved in a text file of a certain format, which the game easily ate after launch.
In the parser code there are several funny places, for example, such a commented line. I can not imagine why and where it came from.
’ If Val(List1.List(I)) * 0 = 0 ThenMsgBox (List1.List(I))
Sometimes the parser choked and the file with the command looked like this:
gk71 Бабурин 22 Бородин 81 Дронов 30 Жевнов 91 Зайцев 16 Малафеев df 3 Алвеш Португалия 2 Анюков 83 Васильев 14 Губочан Словакия 96 Зуев
This led to strange bugs inside the game itself.
Zenit could play Portugal midfielder with a rating of 86.
This version has more team management and less fun. Tactics again almost did not affect anything, but you could buy and sell players, they were injured and received cards. Keeping the tournament table on the form is a thing of the past, now everything was in memory and it became much more convenient to work with it.
There was a problem with drawing on the form of a heap of numbers, but she decided elegantly:
So so ux
Of course, in the code there were still pieces that you could not see without tears:
For i = 1 To 15 If tbl(i) = team2 Then i = i + 1 k = k + 1 If k = 1 Then tr = Int(Rnd * 5) + 2: xa = Int(Rnd * tr): ia = i If k = 2 Then xb = Int(Rnd * tr) If xa > xb Then pts(ia) = pts(ia) + 3: gm(2, ia) = gm(2, ia) + 1: gm(4, i) = gm(4, i) + 1: gm(5, ia) = gm(5, ia) + xa: gm(5, i) = gm(5, i) + xb: gm(6, ia) = gm(6, ia) + xb: gm(6, i) = gm(6, i) + xa If xa < xb Then pts(i) = pts(i) + 3: gm(2, i) = gm(2, i) + 1: gm(4, ia) = gm(4, ia) + 1: gm(5, ia) = gm(5, ia) + xa: gm(5, i) = gm(5, i) + xb: gm(6, ia) = gm(6, ia) + xb: gm(6, i) = gm(6, i) + xa If xa = xb Then pts(i) = pts(i) + 1: pts(ia) = pts(ia) + 1: gm(3, i) = gm(3, i) + 1: gm(3, ia) = gm(3, ia) + 1: gm(5, ia) = gm(5, ia) + xa: gm(5, i) = gm(5, i) + xb: gm(6, ia) = gm(6, ia) + xb: gm(6, i) = gm(6, i) + xa Form6.List1(ng).AddItem tbl(ia) + Str(xa) + «:» + Str(xb) + " " + tbl(i) k = 0 End If
This game was almost perfect - you could legally buy Igor Akinfeev a striker in Amkar, and then see how the Volga Nizhny Novgorod becomes the champion of Russia. And in general, everything became much more decent - well, I thought so at first. Four years later, everything was not so rosy.
RFPL 2 - Resurrection
By 2013, I had already worked as a programmer for the money. I thought and wanted to write a new version of the simulator - a fresh look at the old code showed that there was nothing good at all. Well, that is absolutely nothing.
Important morality # 4 - sometimes it is better to rewrite from scratch.
The RFPL site has changed by that time, so I wrote another parser (its code sank into oblivion), but now there were no annoying errors with the country. For the players, I started a separate structure where I indicated, among other things, club membership - it became easier to implement transfers and keep statistics. And they all got points, depending on the "star" and position on the field.
Type player Surname As String FirstName As String Num As String Team As String Goals As Integer Shots As Integer Saves As Integer AttPts As Integer DefPts As Integer MidPts As Integer GoalPts As Integer Position As String Star As Boolean Stamina As Integer Yellow As Integer TeamPts As Integer Injured As Integer fromStart As Boolean fromBench As BooleanEndType
There was a button “Avtosostav” for especially lazy players - she herself filled the position with the strongest “players”. Unfortunately, I was still playing it.
By that time, I also figured out the table - I was not lazy and made an understandable “classic” table with the necessary indicators, which can be seen immediately. Along with this appeared the statistics of the top scorers.
Added save, even better transfers, the results of parallel matches of each round. Now I look at it and understand that this is all very childish and naive occupation, but then it looked impressive. All but one thing. See:
Shameful. Ball Instead. Pink. Little square.
Important moral # 5 - sometimes it’s better not to do anything than to make a pink square.
A few more years passed and I decided to teach a computer to play football. Or at least pretend that he plays football. With a ball, players on the field, without text and lists. And here is the place for another important moral, which coincides with the section heading:
If you do not make backups, then you will have nothing to talk about in this section.
From the big project on Unity from 2016, in which there were good models of the movement of agents, positional play and almost clever movement of the ball, there remained a small gif from one of the early stages of development.
Therefore, I will talk about this some other time, when I rewrite everything from scratch again.
What is it all about?
I like to remember this story from the very beginning. I like to think that this toy “simulator” brought more experience and fun than some university classes and work tasks. Remembering how he registered the first mail to which grateful players would send letters, and how in 2007 he wrote on the city forum "Read textbooks on the Internet is cheating, I will learn everything by typing." These are wonderful feelings, which you probably have in different forms.
In this post there were a lot of obvious tips - about backups, comments and the need for refactoring - everyone knows this without me. And most importantly, be sure to remember the thought of Lyubov Nikolaevna Kaftunkina, my informatics teacher:
"If you want to play games in class, write them yourself."