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
21 changes: 21 additions & 0 deletions DinoGame/DinoGame.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!--
Descirption: https://github.com/rushairer/Arduino_DinoGame 的米思奇扩展库
Author: 阿笨
Homepage: https://github.com/rushairer
-->
<script type="text/javascript" src="./block/dino_game.js"></script>
<script type="text/javascript" src="./generator/dino_game.js"></script>
<category id="dino_game_category" name="Dino Game" colour="345">
<block type="dino_game_setup">
</block>
<block type="dino_game_loop">
</block>
<block type="dino_game_start_game">
</block>
<block type="dino_game_dino_jump">
</block>
<block type="dino_game_set_cheat">
</block>
<block type="dino_game_show_ultraman">
</block>
</category>
3 changes: 3 additions & 0 deletions DinoGame/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Mixly_DinoGame

![Preview](./preview.png)
79 changes: 79 additions & 0 deletions DinoGame/block/dino_game.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
;(() => {
//
Blockly.Blocks.dino_game_setup = {
init: function () {
this.appendDummyInput()
.appendField('DinoGame初始化, 选择u8g2实例:')
.appendField(new Blockly.FieldTextInput('u8g2'), 'oled')

this.setPreviousStatement(true, null)
this.setNextStatement(true, null)
this.setColour(345)
this.setTooltip('Dino')
this.setHelpUrl('Dino')
},
}

Blockly.Blocks.dino_game_loop = {
init: function () {
this.appendDummyInput().appendField('DinoGame循环执行命令')
this.setPreviousStatement(true, null)
this.setNextStatement(true, null)
this.setColour(345)
this.setTooltip('Dino')
this.setHelpUrl('Dino')
},
}

Blockly.Blocks.dino_game_start_game = {
init: function () {
this.appendDummyInput().appendField('DinoGame开始游戏')
this.setPreviousStatement(true, null)
this.setNextStatement(true, null)
this.setColour(345)
this.setTooltip('Dino')
this.setHelpUrl('Dino')
},
}

Blockly.Blocks.dino_game_dino_jump = {
init: function () {
this.appendDummyInput().appendField('DinoGame恐龙跳跃')
this.setPreviousStatement(true, null)
this.setNextStatement(true, null)
this.setColour(345)
this.setTooltip('Dino')
this.setHelpUrl('Dino')
},
}

Blockly.Blocks.dino_game_set_cheat = {
init: function () {
this.appendDummyInput()
.appendField('是否开启作弊')
.appendField(
new Blockly.FieldDropdown([
['开启', 'CHEAT_MODE_CHEAT'],
['关闭', 'CHEAT_MODE_NORMAL'],
]),
'isCheat'
)
this.setPreviousStatement(true, null)
this.setNextStatement(true, null)
this.setColour(345)
this.setTooltip('Dino')
this.setHelpUrl('Dino')
},
}

Blockly.Blocks.dino_game_show_ultraman = {
init: function () {
this.appendDummyInput().appendField('DinoGame显示奥特曼')
this.setPreviousStatement(true, null)
this.setNextStatement(true, null)
this.setColour(345)
this.setTooltip('Dino')
this.setHelpUrl('Dino')
},
}
})()
3 changes: 3 additions & 0 deletions DinoGame/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "0.1.0"
}
37 changes: 37 additions & 0 deletions DinoGame/generator/dino_game.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
;(() => {
//
Blockly.Arduino.forBlock.dino_game_setup = function () {
var oled = this.getFieldValue('oled')
Blockly.Arduino.definitions_[
'header'
] = `#include "dino_game_arduino.h"\nDinoGameArduino dinoGameArduino(&${oled});`
Blockly.Arduino.setups_['setup'] = 'dinoGameArduino.setup();'
var code = ''
return code
}

Blockly.Arduino.forBlock.dino_game_loop = function () {
var code = 'dinoGameArduino.loop();'
return code
}

Blockly.Arduino.forBlock.dino_game_start_game = function () {
var code = 'dinoGameArduino.startGame();'
return code
}

Blockly.Arduino.forBlock.dino_game_dino_jump = function () {
var code = 'dinoGameArduino.dinoJump();'
return code
}
Blockly.Arduino.forBlock.dino_game_set_cheat = function () {
var dropdown_isCheat = this.getFieldValue('isCheat')
var code = `dinoGameArduino.setCheatMode(${dropdown_isCheat});`
return code
}

Blockly.Arduino.forBlock.dino_game_show_ultraman = function () {
var code = 'dinoGameArduino.showUltraman();'
return code
}
})()
Loading