Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
faucomte97 committed Dec 1, 2023
1 parent 7c1d8c2 commit c53f653
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions game/static/game/js/blocklyCustomBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,21 @@ function initCustomBlocks() {
}

function initCustomBlocksDescription() {
let fieldImage = new Blockly.FieldImage(
ocargo.Drawing.imageDir + CHARACTER_EN_FACE_URL,
ocargo.BlocklyControl.BLOCK_CHARACTER_HEIGHT,
ocargo.BlocklyControl.BLOCK_CHARACTER_WIDTH
)

if(new Date().getMonth() === 11 && CHARACTER_NAME === "Van") {
fieldImage = new Blockly.FieldImage(
ocargo.Drawing.imageDir + "characters/top_view/Sleigh.svg",
ocargo.BlocklyControl.BLOCK_CHARACTER_HEIGHT,
ocargo.BlocklyControl.BLOCK_CHARACTER_WIDTH
)
}

Blockly.Blocks["start"] = {
// Beginning block - identifies the start of the program
init: function () {
ocargo.blocklyControl.numStartBlocks++;
this.setColour(50);
this.appendDummyInput().appendField(gettext("Start")).appendField(fieldImage);
this.appendDummyInput()
.appendField(gettext("Start"))
.appendField(new Blockly.FieldImage(
new Date().getMonth() === 11 && CHARACTER_NAME === "Van"
? ocargo.Drawing.imageDir + "characters/top_view/Sleigh.svg"
: ocargo.Drawing.imageDir + CHARACTER_EN_FACE_URL,
ocargo.BlocklyControl.BLOCK_CHARACTER_HEIGHT,
ocargo.BlocklyControl.BLOCK_CHARACTER_WIDTH
)
);
this.setNextStatement(true, "Action");
this.setTooltip(gettext("The beginning of the program"));
this.setDeletable(false);
Expand Down

0 comments on commit c53f653

Please sign in to comment.