Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplayer Tetris by Default #54

Merged
merged 1 commit into from Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 44 additions & 2 deletions blockly/src/index.js
Expand Up @@ -37,6 +37,48 @@ const gamesContainer = document.getElementById('gamesContainer')
const pageContainer = document.getElementById('pageContainer')

const ws = Blockly.inject(blocklyDiv, {toolbox});
const defaultWorkspace = {
"blocks": {
"languageVersion": 0,
"blocks": [
{
"type": "metadata",
"id": "A$mP~29yJri+II[;(i/h",
"x": 40,
"y": 60,
"inputs": {
"game name": {
"block": {
"type": "text",
"id": "uL4`ChH4}lTzo~sEz[ot",
"fields": {
"TEXT": "Multiplayer Tetris"
}
}
},
"author name": {
"block": {
"type": "text",
"id": "?)6dy[;RNRixg1lHZGed",
"fields": {
"TEXT": "BlastPad Team"
}
}
},
"description": {
"block": {
"type": "text",
"id": "D?WrcH,o0F0HKfy2~GC;",
"fields": {
"TEXT": "This is an example project."
}
}
}
}
},
]
}
};

saveGameButton.addEventListener("click", async (e) => {
const data = Blockly.serialization.workspaces.save(ws);
Expand Down Expand Up @@ -106,7 +148,7 @@ const fetchAndLoadGame = (gameName) => {
pageContainer.classList.remove("hidden");
}).catch((error) => {
console.log("No games found, loading empty workspace.")
Blockly.serialization.workspaces.load({}, ws, false);
Blockly.serialization.workspaces.load(defaultWorkspace, ws, false);
selectionContainer.classList.add("hidden");
pageContainer.classList.remove("hidden");
})
Expand Down Expand Up @@ -135,7 +177,7 @@ const startEditor = () => {
}).catch((err) => {
console.log(err);
console.log("No games found, loading empty workspace.")
Blockly.serialization.workspaces.load({}, ws, false);
Blockly.serialization.workspaces.load(defaultWorkspace, ws, false);
selectionContainer.classList.add("hidden");
pageContainer.classList.remove("hidden");
})
Expand Down