📜 ⬆️ ⬇️

What to do IT in the army - a guide to action

The first article caused a great resonance throughout the internet. Now I want to talk a little about the technical side of the question, namely, how to start developing BomberMan in Excel. The source code of the game will not be due to its absence, but there will be only a few explanations of the principles of work.

The methods described in the article do not claim to be the ultimate truth. I describe how it was done by me TAM, in places where there is no Internet and a strong mental impact.

Part one is the creation of a client form.
There are forms in VBA ... it is more pleasant to work with forms and the most important thing is more familiar. For BomberMan, I needed 12 thumbnails and a bit of creativity in Paint:

- empty cell
')
- concrete wall

- whole brick wall

- dilapidated brick wall (at the time of the explosion imitation of extinction)

- bomb

- bright fire explosion

- dying fire after the explosion (similar disappearance)

- RIP grave

- green man

- red

- blue

- yellow

The playing field is 19x29 in size, of which 9x14 are concrete walls. The principle of building a game form is as follows: you need to add 8 standards of thumbnails to the form (Visible = false, we just copy the images from them) and 19x29 = 551 Image blank cells, we will substitute reference textures into them. The remaining four images (multi-colored people) will move over the playing field along the coordinates.

Create a form in VBA Excel.



At form initialization it is necessary to place empty cells of Image1..551 and colored people in their places. Cycle from 1 to 551, with the assignment of the parameters of the coordinates Left and Top. Well, the connection menu sketched.



The client application itself is simple. Next, track the keystrokes, move the little man and write his coordinates to a file. At the same time, we constantly read and display the changes on the playing field. This is the basis.

Part two - client interaction with the server.
I organized the gameplay through text files. The first file is the playing field 19 lines of 29 numbers each. 0 is an empty cell, 1 is a fading fire, 2 is a bright fire, 3 is a ruined wall, 4 is a whole wall ... etc. The server works with a simple sequence of numbers.



Another four files are responsible for the current coordinates of each of the players and his fresh bombs. Thus, the program acting as a server reads four files with coordinates, processes the playing field for the next point in time and spits out the main file, which each client reads at one time.

Part three - the server.
The server is smart. This is a separate application and the timer is ticking inside, files with the coordinates of each player are loaded by it

Offtopic
Yes, with bare coordinates, without teleportation protection, if you know what I mean. Hello to colleagues who do not understand how I ran away from imprisonment among bombs ... Generally speaking, my client was able to run through bombs. God mode, so to speak. And I always referred to the "bug in the beta version" :)

and a field is generated for the next point in time.



The next moment in time is such a conditional moment when the bright fire from the explosion dims, the damaged wall collapses to the end, the timer of each of the bombs decreases by one, causing the explosion function when necessary. At the same time, new bombs, new explosions and player coordinates are added to the array of the playing field.

The explosion function, by the way, was implemented in the form of recursion. The entire connected chain of bombs exploded at one time, and not in turn. An alternate break would require too much FPS, which I could not afford. And so the explosion turned out spectacular and faded out at the same time. In the screenshot, there are some slight differences in attenuation, but this is apparently caused by the brakes on the client side.



Your trial has produced a sort of brief theoretical description of how the Bomberman’s network works on VBA.

PS No matter what, and the year is very little ... How much more I wanted to have time to do, but not enough time.

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


All Articles