My multiplayer game has wrong results!

Hello
I finished my first multiplayer game After I shared it with others and start playing, But it had wrong results, All of you will doubt of my conditions and events, I’m sure they are right, and I recorded a short video for you to watch the app’s mistake yourself, After watching it I wish to understand why it happened, by the way, sorry for my weak Inglish in the video, This link for a web page contains the vid. New Page - كنوز

Hello, please help me.

Please remember that we’re all in different time zones, so a response may not eventuate for quite a while - 1/2 a day or more.

I’ve watched the video, and I suspect it’ll be your events. I know you believe they’re correct, but if the tick appears one time and not another, it won’t be GDevelop that’s the issue.


I’m guessing you have 2 sets of events, one for the top (player 1) and one for the bottom (player 2). This isn’t the best way to approach a PvP game, and you may want to reconsider the following:

Instead of viewing the game as player 1 at the top and player 2 at the bottom, think of it as the top grid being for your application and the bottom being the player you are connecting to. So, say you and I were playing; you would see your objects in the top of your application instance, and I would see my objects at the top of my application instance.

And instead of it being a game with events for player 1 and events for player 2, view it as player and opponent. For you, you are the player and I’m the opponent. For me, I’m the player and you are the opponent. The player’s grid is always displayed at the top and the opponent’s grid is always displayed at the bottom.

And instead of passing co-ordinates of where the click is made, pass the grid position (column, row). If I click on the bottom grid the cell in column 4 and row 3, I then send you the message that I clicked on (4,3). You then check grid cell (4,3) in the top part of the screen and return what was hit. I update the bottom grid on my screen with the result you passed. If I selected a cell that has an object in it, then it is removed from the top grid on your screen. Likewise, if you selected a cell that has an object in it, then it is removed from the top grid on my screen.

This way you have one set of events that cover both players. Otherwise, it’s too prone to mistakes and takes a fair bit of faffing around.

I understand that this will require a fair amount of event rewriting and refactoring, but in the long run it’ll make your game a lot more efficient, bug free and easier to maintain or upgrade.

1 Like

Instead of viewing the game as player 1 at the top and player 2 at the bottom, think of it as the top grid being for your application and the bottom being the player you are connecting to

Hello,
Sorry, I feel that the two cases are similar, What do you mean by ( for your application )? And you said (The player’s grid is always displayed at the top and the opponent’s grid is always displayed at the bottom.) Doesn’t it mean a Player is on the top and another on the bottom?
(the top grid)
And do you mean that I delete squares and use the grid?
Finally, How can I do a condition (pass the grid position (column, row)?

for my first question: Do you mean that I should make the upper part the place to place items, whether for me or the opponent, and the lower part to be the place for guessing for both players?

If so, how do I implement the location condition on the grid to affect the top? How do I specify this by row and column?

The game running on each machine. Sorry, “application” was the wrong terminology for me to use.

Yes.

You know the position of the top left cell in the lower grid. So you then work out the column and row of the grid cell clicked with a (pseudo-code) formula along the lines of “column = trunc(CursorX() / gridCell.Width()) - top_left_grid_cell_x_position”, and similarly for the row but using Y and height.

Pass this information in a message. So it may be that you jsonify a structure that has these two values as children. Or you could pass the values in a string delimited by a non-numeric character.

To then get the column and row in the top grid, use the formula (also pseudo-code) “x_position = (column + 0.5) * gridCell.Width() + top_left_grid_cell_x_position”. I add the 0.5 to column to get the midpoint of the grid cell.

You can then use the point in object expression or create a test object at the position (and use collision) to determine what object may have been clicked.

It seems very complicated to me, so much so that I did not understand many things like this code where to put it, and how to link that to clicking… Sorry, this is just a flaw in me… If you could apply this for me to a simple file in one element, I would be grateful for your effort.
… If this is difficult for you due to your limited time, then I ask colleagues that someone help me by simplifying this information into a file that I can imitate and follow in his footsteps.

In addition to all of the above, the program hides the player elements. More than once, I reopened the program and did not see the lower player elements

I’ll help, not by doing the coding, but by taking you through the steps.

So, the initial steps are:

  1. create events so when you click on the bottom grid it calculates the columns and row of the clicked grid cell.

    How you confirm it’s the right columns and row is up to you - a temporary text box, a console message, looking up the variables in the debugger, it doesn’t matter, as long as you can verify the column and row are correctly calculated

  2. create events that when a key is pressed, place a tick in the cell in the top grid for the corresponding column and row of the bottom grid cell clicks (in step 1). This is temporary and just to confirm the correct cell is located in the top grid.

Once you’ve created these two sets of events and got them working, then I’ll take you through the next set of steps.

Okay, I’ll try that.

1 Like

Also, I’d suggest you store the column and row information in a structure. It should make sending the data a tad simpler.

So something like ClickedCell with children column and row.

Sorry, don’t waste your time, You think I can do that, No I can’t, So I requested help,
to create an event that (calculates the columns and rows of the clicked grid cell.) It seems to me like I want to make the sun rise from the west.
I gave up this game like others.