Starlight-30036225 / ChessTCP

FILLMELATER
0 stars 0 forks source link

Flipping the board for player 2 #11

Closed Starlight-30036225 closed 7 months ago

Starlight-30036225 commented 7 months ago

I need to create a way for the board to be drawn backwards for players who are playing black to make it clear which side they are on. However this is going to mean a lot of gutting my current display code to make it able to be flipped

Starlight-30036225 commented 7 months ago

I will start looking at this now...

wish me so much luck

Starlight-30036225 commented 7 months ago

I want the board to handle all of this internally, so the server and the other board should not have any difference if the board is flipped or not. Which means all communications inward and outward will need to be flipped.

This will be interesting...

Starlight-30036225 commented 7 months ago

The first, and easiest thing to do is just visually change the board by flipping the notation. This works really nicely as it can be read both ways easily. This can be done in one line at the start of the 'LoadMapFromNotation' function

image

So now, when the player is white: image

And when they are black: image

Starlight-30036225 commented 7 months ago

Deceptively, Right now it will work as expected because the board is the same on both sides. But currently, information send to the server and recieved will be the wrong way round. So I am likely going to need a function that flips X and Y variables. I think this will use mod, but ill have to do some tests

Starlight-30036225 commented 7 months ago

image

I think this will work, but its going to be a tricky thing to test...

Starlight-30036225 commented 7 months ago

image hmmmmmmm

Starlight-30036225 commented 7 months ago

image I dont know if this is better?

Starlight-30036225 commented 7 months ago

image Much better

Updated the function, and after a lot of tweeks this works.

To update moves as they are received I added another new function: image

Nice and simple

Only took me 45 minutes...

Starlight-30036225 commented 7 months ago

Only thing left is the ranks and files should(?) be easy...

Starlight-30036225 commented 7 months ago

image

took some tinkering to get the numbers perfect but this looks right?

image

Starlight-30036225 commented 7 months ago

I am very proud of this, time to close the issue.