📜 ⬆️ ⬇️

How I did a football simulator for 13 years

2_fview_gameplay


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 the first Quake fun. 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 way of a developer, unfinished projects and why sometimes they do not 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 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:


1250menu
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 13 years old, you don’t even think about it at the bank. Yandex.Money then already existed, but before the appearance of the Cashier there were 8 years left, therefore it is also inconvenient. My friends and I played for two seasons, and then started anew.


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, 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, nobody 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 textbook on computer science 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


Private Sub Command1_Click() End End Sub 

and clicked "Run." Everything worked and I was very pleased. After a while, a text football simulator appeared - Coach v2.52.


2018-11-01_11-03-44
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, strange bugs were caused by this:


2018-11-01_11-11-04
All teams played 2 matches, but some of them were 3, and others were one


2018-11-01_11-17-52
You could also buy Roy Keane and Andriy Shevchenko in Spartak. Not sure what it was in at least one football simulator of the time


In general, imagine that you have forgotten 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 can go to game devs.


I have no source code 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 learned that Shape can be poured in different ways, I made a whole window for this with the choice of lawn at the club stadium:


1_coach_stadium
Would you cut the lawn on a flute of vibrant pipes?


Important moral # 1 - explore the possibilities of the tools that 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 once it happened - let it be published.


readme.txt

Coach 3 V2.08 - 2006 Edition




Hello! Thank you for purchasing this game.


1.Installation
2.System requirements
3. Test platform
4. What's new
5. Tips
6.Installation
7. Thank you so much ...


1.Installation
Run the file Setup.exe and unzip the files in the folder with: \ Program files \ Football Manager 2005
And then still unzip the file setup2.exe


2.System requirements
No P4-2500. Everything is extremely simple. So,


Pentium 1-233 MHz (300 and higher recommended)
HDD 5MB
16 MB RAM (32 or higher recommended)
Video 16 MB
Windows 9x, Me, NT, 2003, Longhorn. On XP, it works only if there is an msvbvm60.dll file in the root directory of c: \ windows \ system
Mouse.


3. Test platform
Celeron 1100 MHz
160 MB RAM
Video 16MB
Windows XP SP2


4. What's new


Made a lot of new things.
For example, now in the championship of Russia participate 14 (!) Teams instead of 8.
The "Team" dialogue has been changed; a menu about the coach of the club has appeared.
Now the game depends on tactics!
Strong rivals.
For the first time since Coach 1, you normally get points.
Champions League. Super Cup of Russia.


5. Tips.


Do not change or delete files from the folder with: \ program files \ football manager 2005 \ clubs \ emblems
After installation, copy the MSVBVM60.DLL file to the c: \ windows \ system folder


6.Installation


Uninstallation is not required. Just delete the game folder.


7. Thank you so much ...


Kusherbayev Daniyar for beta testing.
Mikhail Karneev, Mikhail Trofimenko for beta testing and valuable advice.
Site rfpl.org for the form of teams of the Premier League.


01.27.06


PS Ours will win!


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 disk failed. nostalgic sighs And remember, when to put the Blood 2, you had to erase Age of Empires 2?


0__football_champ_nogame
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.


1_coach_gameplay
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 management team, 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.


4x4 football

2018-11-01_23-53-44


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.


2_fview_gameplay
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 spin 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.


 Private Sub Igroki_Timer() k = k + 1 ′   For i = 1 To 8 Randomize (x) x = Int(Rnd * 4) If x = 1 Then Image2(i).Top = Image2(i).Top — 360 If x = 2 Then Image2(i).Top = Image2(i).Top + 360 If x = 3 Then Image2(i).Left = Image2(i).Left + 360 If x = 4 Then Image2(i).Left = Image2(i).Left — 360 y = Int(Rnd * 4) If y = 1 Then Image3(i).Top = Image3(i).Top — 360 If y = 2 Then Image3(i).Top = Image3(i).Top + 360 If y = 3 Then Image3(i).Left = Image3(i).Left — 360 If y = 4 Then Image3(i).Left = Image3(i).Left + 360 ′    If Image2(i).Top = Image1.Top And Image2(i).Left = Image1.Left Then Igroki.Enabled = False: pas_vpravo.Enabled = True If Image3(i).Top = Image1.Top And Image3(i).Left = Image1.Left Then Igroki.Enabled = False: pas_vlevo.Enabled = True '        If Image2(i).Top <= 1080 Then Image2(i).Top = Image2(i).Top + 720 If Image3(i).Top <= 1080 Then Image3(i).Top = Image3(i).Top + 720 If Image2(i).Top >= 4320 Then Image2(i).Top = Image2(i).Top — 720 If Image3(i).Top >= 4320 Then Image3(i).Top = Image3(i).Top — 720 ′         If Image2(i).Left <= 480 Then Image2(i).Left = Image2(i).Left + 3720 If Image3(i).Left <= 480 Then Image3(i).Left = Image3(i).Left + 3720 If Image2(i).Left >= 6600 Then Image2(i).Left = Image2(i).Left — 3720 If Image3(i).Left >= 6600 Then Image3(i).Left = Image3(i).Left — 3720 Next i End Sub 

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) Then MsgBox (" . " + Label3.Caption): End 

And now - the worst. The ball moved on 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 Straustrup, 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 = True If (KeyCode = vbKeyRight) Then pas_vpravo.Enabled = True If (KeyCode = vbKeyUp) Then Pas_verh.Enabled = True If (KeyCode = vbKeyDown) Then Pas_vniz.Enabled = True End Sub 

All the 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, after all, I 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 your 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:


3_rpfl_players


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:


  1. 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 picture. I did not use them and easily disposed of.
  2. All the lines from Excel needed to be copied to a text file parse.txt
  3. 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.
  4. All of 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 Then MsgBox (List1.List(I)) 

Sometimes the parser choked and the file with the command looked like this:


 gk 71  22  81  30  91  16  df 3   2  83  14   96  

This led to strange bugs inside the game itself.


2018-11-01_13-08-10
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 the drawing on the form of a heap of numbers, but she decided elegantly:


3_rfpl_tablefix
So so ux


Of course, there were still pieces in the code 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 Nizhny Novgorod Volga 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's 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 affiliation - 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 Boolean End Type 

2018-11-01_13-30-49
There was a button "Avtosostav" for especially lazy players - she herself filled the position with the most powerful "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.


2018-11-01_13-34-53


Added save, even better transfers, the results of parallel matches of each round. Now I look at it and understand that all this is very childish and naive occupation, but then it looked impressive. All but one thing. See:


4_rfpl2_gameplay
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.


ezgif-2-358042221c7d


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 many 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 Kftunkina, my informatics teacher:


"If you want to play games in class, write them yourself."

')

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


All Articles