Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ You can host the source files on either your Windows file system or on the Ubunt

**Windows File System:** Run the Git commands to clone and pull source files from a Windows command prompt. You may find this best if you're using programs such as SourceTree as a Git GUI. You can also edit source using your usual IDE.

**Ubuntu File System:** Run the Git commands to clone and pull source files from a WSL command prompt. In this case consider [using the Visual Studio Code WSL extension](https://code.visualstudio.com/docs/remote/wsl) as your dev environment - for features such as hot reload.
**Ubuntu File System:** Run the Git commands to clone and pull source files from a WSL command prompt. In this case consider [using the Visual Studio Code WSL extension](https://code.visualstudio.com/docs/remote/wsl) as your dev environment - for features such as better hot reload.

#### Running

Expand Down
2 changes: 1 addition & 1 deletion packages/multiplayer-do
40 changes: 28 additions & 12 deletions src/components/title-screen/TitleScreen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,12 @@ class TitleScreenRenderer extends EventTarget {
virtualPlayers.removeEventListener('leave', onVirtualPlayersLeave);
});
};
/*
(async () => {
multiplayerConnect();
})();
*/

const keydown = e => {
switch (e.key) {
case 'm': {
Expand Down Expand Up @@ -1084,7 +1090,7 @@ class TitleScreenRenderer extends EventTarget {
const onConnect = async position => {
// Initialize network realms player.
this.realms.localPlayer.initializePlayer({
position,
position,
}, {});
this.localPlayer.setRealmsPlayer(this.realms.localPlayer);
};
Expand Down Expand Up @@ -1152,13 +1158,13 @@ class TitleScreenRenderer extends EventTarget {
camera: this.camera,
keys: this.keys,
});
for (const player of this.remotePlayers.values()) {
player.update({
timestamp,
timeDiff,
camera: this.camera,
});
}
for (const player of this.remotePlayers.values()) {
player.update({
timestamp,
timeDiff,
camera: this.camera,
});
}
}
}
destroy() {
Expand Down Expand Up @@ -1655,8 +1661,8 @@ const TitleScreen = () => {
console.warn('got invalid file', {firstBytes, firstBytesString});
}
}
};
useEffect(() => {
};
useEffect(() => {
const router = useRouter();
if (!seenRouters.has(router)) {
seenRouters.set(router, true);
Expand All @@ -1670,10 +1676,10 @@ const TitleScreen = () => {
};
router.addEventListener('srcchange', srcchange);
return () => {
router.removeEventListener('srcchange', srcchange);
router.removeEventListener('srcchange', srcchange);
};
}
}, []);
}, []);

useEffect(() => {
const keydown = async e => {
Expand Down Expand Up @@ -1796,6 +1802,16 @@ const TitleScreen = () => {
titleScreenRenderer?.keys.down,
]);

useEffect(() => {
const destroyTitleScreenRenderer = () => {
titleScreenRenderer && titleScreenRenderer.destroy();
}
window.addEventListener('beforeunload', destroyTitleScreenRenderer);
return () => {
window.removeEventListener('beforeunload', destroyTitleScreenRenderer);
};
}, [titleScreenRenderer]);

return (
<div
className={styles.titleScreen}
Expand Down
6 changes: 6 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ export default defineConfig(({command, mode, ssrBuild}) => {
},
host: '0.0.0.0',
port: 9999,
watch: {
/* For Windows-hosted files. */
usePolling: true,
interval: 5000,
binaryInterval: 15000,
},
},
};
})