Skip to content

Commit

Permalink
fix sticky mouse on Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
codefrau committed Aug 27, 2024
1 parent c59e6cb commit c7f6562
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Croquet Multiblaster
# Croquet Multiblaster 🚀

This is an homage to Asteroids, implemented as a single HTML page without any backend code.
All clients are kept in sync automatically by [Croquet](https://croquet.io/)'s synchronization technology.
Expand Down
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
opacity: 100%;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/@croquet/croquet@1.0.5"></script>
<script src="https://cdn.jsdelivr.net/npm/@croquet/croquet@1.1.0"></script>
<script type="module">
import emoji_regex from "https://cdn.jsdelivr.net/npm/emoji-regex/index.mjs";
window.EMOJI_REGEX = emoji_regex();
Expand Down Expand Up @@ -365,9 +365,9 @@
}
};

let x = 0, y = 0, id = 0, right = false, left = false, forward = false;
let x = 0, y = 0, id = null, right = false, left = false, forward = false;
document.onpointerdown = (e) => {
if (!id) {
if (id === null) {
id = e.pointerId;
x = e.clientX;
y = e.clientY;
Expand Down Expand Up @@ -401,7 +401,7 @@
document.onpointerup = (e) => {
e.preventDefault();
if (id === e.pointerId) {
id = 0;
id = null;
if (!right && !left && !forward) {
this.publish(this.viewId, "fire-blaster");
}
Expand Down Expand Up @@ -461,7 +461,7 @@
if (!label) {
label = `Player ${labels.size + 1}`;
highscore.push([label, ship.score]);
} else {
} else if (window.EMOJI_REGEX) {
const emoji = label.match(EMOJI_REGEX);
if (emoji?.length) emojis.set(ship, emoji[emoji.length >> 1]);
}
Expand Down

0 comments on commit c7f6562

Please # to comment.