Infinite-Chess / infinitechess.org

Infinite Chess Web Server
https://www.infinitechess.org
GNU Affero General Public License v3.0
173 stars 40 forks source link

Dragging pieces #22

Open optim-ally opened 2 months ago

optim-ally commented 2 months ago

Dragging the board is a new kind of user interaction in infinite chess vs 8x8 chess. It makes the familiar action of dragging pieces in online chess problematic. I tried several time to drag pieces in infinite chess before remembering that it didn't work like that, but perhaps it could!

We could introduce ways to explicitly choose "piece dragging" or "board dragging", like right clicking or holding down a particular key, but I expect most users won't bother with those.

I propose the following logic for handling "drag" interactions:

  1. if the board is already moving (e.g. it has remaining momentum from being dragged), then drag the board
  2. else if the click action was a right-click or CMD/CTRL was held, drag the board
  3. else if the cursor is not over a piece of the player's colour, drag the board
  4. else if the cursor is over multiple pieces (when zoomed far enough out), drag the board
  5. else drag the piece

This might need to go through several iterations if it's going to work, but what are initial thoughts?

Heinrich-XIAO commented 2 months ago

I feel like a good solution to this would be to drag the piece if the mouse was directly on the piece and drag the board otherwise.

optim-ally commented 2 months ago

Essentially, yes, but we need to be careful with the details. For example, if the board is zoomed out far enough then the mouse may be on top of multiple pieces.

Another issue is whether we consider the mouse "on" a piece if it is in the same square or if it actually needs to be inside the rendered shape of the piece. If it's the latter then cosmetic changes to the board and pieces could affect playing experience by making pieces harder or easier to move. I don't think that should be the case.

Naviary2 commented 2 months ago
  1. if the board is already moving (e.g. it has remaining momentum from being dragged), then drag the board

When dragging the board with the mouse and letting go, it no longer has momentum, it stops immediately. So it can't be thrown in this manner.

if the board is zoomed out far enough then the mouse may be on top of multiple pieces.

The coordinates of the mouse is a single point, so it can never technically be over multiple pieces, at least in the code. But at that zoom distance clicking and dragging probably shouldn't be selecting a piece anyway, the user probably intends on moving the board.

I feel like a good solution to this would be to drag the piece if the mouse was directly on the piece and drag the board otherwise.

I like this solution and I have actually thought this before! I personally think this is the best solution. But it can be tested!

When I check out Lichess.org's mouse controls, they also have click to select, and click-drag as well! We should have both. Should have thought of that when I was making the first release!

optim-ally commented 2 months ago

When dragging the board with the mouse and letting go, it no longer has momentum, it stops immediately. So it can't be thrown in this manner.

I'm planning ahead to when we have #23 😛

You pointed out on that issue that scrolling with W,A,S,D already gives the board "momentum". In that case, I think piece dragging should be disabled until the board has come to a halt.