Skip to content

Commit

Permalink
feat(wip): pointer in orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
owulveryck committed Nov 15, 2023
1 parent 3d62145 commit 03fdb7c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,18 @@ function connectWebSocket() {
}
if (message.Type === 3) {
// Code 3: Update and draw laser pointer
if (message.Code === 1) { // Horizontal position
latestX = scaleValue(message.Value, MAX_X_VALUE, canvasPresent.width);
} else if (message.Code === 0) { // Vertical position
latestY = canvasPresent.height - scaleValue(message.Value, MAX_Y_VALUE, canvasPresent.height);
if (rotate) {
if (message.Code === 1) { // Horizontal position
latestX = scaleValue(message.Value, MAX_X_VALUE, canvasPresent.width);
} else if (message.Code === 0) { // Vertical position
latestY = canvasPresent.height - scaleValue(message.Value, MAX_Y_VALUE, canvasPresent.height);
}
} else {
if (message.Code === 1) { // Horizontal position
latestX = canvasPresent.width - scaleValue(message.Value, MAX_X_VALUE, canvasPresent.width);
} else if (message.Code === 0) { // Vertical position
latestY = scaleValue(message.Value, MAX_Y_VALUE, canvasPresent.height);
}
}
if (draw) {
drawLaser(latestX, latestY);
Expand Down

0 comments on commit 03fdb7c

Please sign in to comment.