Starlight-30036225 / ChessTCP

FILLMELATER
0 stars 0 forks source link

Draw cycle simplification #27

Closed Starlight-30036225 closed 8 months ago

Starlight-30036225 commented 9 months ago

I think the drawing of pieces can be greatly simplified.

Starlight-30036225 commented 8 months ago

No it cannot. Ill fix this later.

Starlight-30036225 commented 8 months ago

The change I attempted to make to the draw cycle was to render pieces in the same step that the board squares were drawn. For instance, when drawing the first square at 0,0 that location on the board would be checked for a piece, which would likely be a rook, then that piece would be drawn. Then the draw cycle would move to the next square.

The problem arises when considering draw layers. The swift API layers each drawn sprite sequentially, meaning images drawn first will be under those drawn after. This causes the strange problem where, while dragging a piece, if moved towards a sprite drawn after itself, it will be displayed behind it.

image In this image, the rook has been selected and moved slightly to the right, causing it to be drawn before the square.

Starlight-30036225 commented 8 months ago

An easy solution to this I didn't think to consider is simply render the selected piece after everything else.