内容介绍
内容介绍
功能介绍:
本期的主角是
Kitronik ARCADE for MakeCode Arcade
Kitronik ARCADE是一个功能齐全的可编程游戏手柄,搭配MakeCode Arcade方块编辑器一起使用,培养你的编程技能。
本期任务:
设计一个摩斯密码练习器,SWA为点,SWB为横,从以下两种方式中任选一个完成:
1.LCD屏上随机出现一个字符,敲出对应的组合(3-5个字符即可),正确时,蜂鸣器响;错误时,蜂鸣器发出振动
2.敲击按键,识别出按键组合对应的字符,在屏幕上打出自己的id
-
主要代码片段
-
按键响应
-
controller.up.onEvent(ControllerButtonEvent.Pressed, function () {
panduantext()
pause(1000)
output.destroy()
})
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
music.jumpUp.play()
input2 = "" + input2 + "."
textSprite2 = textsprite.create(input2)
pause(1000)
textSprite2.destroy()
})
controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
music.jumpUp.play()
input2 = "" + input2 + "_"
textSprite2 = textsprite.create(input2)
pause(1000)
textSprite2.destroy()
})
-
-
比较处理函数
-
if (input2 == "._") {
output = textsprite.create("A")
} else if (input2 == "_...") {
output = textsprite.create("B")
} else if (input2 == "_._.") {
output = textsprite.create("C")
} else if (input2 == "_..") {
output = textsprite.create("D")
} else if (input2 == ".") {
output = textsprite.create("E")
} else if (input2 == ".._.") {
output = textsprite.create("F")
} else if (input2 == "__.") {
output = textsprite.create("G")
} else if (input2 == "....") {
output = textsprite.create("H")
} else if (input2 == "..") {
output = textsprite.create("I")
} else if (input2 == ".___") {
output = textsprite.create("J")
} else if (input2 == "_._.") {
output = textsprite.create("K")
} else if (input2 == "._..") {
output = textsprite.create("L")
} else if (input2 == "__") {
output = textsprite.create("M")
} else if (input2 == "_.") {
output = textsprite.create("N")
} else if (input2 == "..._") {
output = textsprite.create("O")
} else if (input2 == ".__.") {
output = textsprite.create("P")
} else if (input2 == "__._") {
output = textsprite.create("Q")
} else if (input2 == "._.") {
output = textsprite.create("R")
} else if (input2 == "...") {
output = textsprite.create("S")
} else if (input2 == "_") {
output = textsprite.create("T")
} else if (input2 == ".._") {
output = textsprite.create("U")
} else if (input2 == "..._") {
output = textsprite.create("V")
} else if (input2 == ".__") {
output = textsprite.create("W")
} else if (input2 == "_.._") {
output = textsprite.create("X")
} else if (input2 == "_.__") {
output = textsprite.create("Y")
} else if (input2 == "__..") {
output = textsprite.create("Z")
} else if (input2 == "_____") {
output = textsprite.create("0")
} else if (input2 == ".____") {
output = textsprite.create("1")
} else if (input2 == "..___") {
output = textsprite.create("2")
} else if (input2 == "...__") {
output = textsprite.create("3")
} else if (input2 == "..._") {
output = textsprite.create("4")
} else if (input2 == ".....") {
output = textsprite.create("5")
} else if (input2 == "_....") {
output = textsprite.create("6")
} else if (input2 == "__...") {
output = textsprite.create("7")
} else if (input2 == "___..") {
output = textsprite.create("8")
} else if (input2 == "____.") {
output = textsprite.create("9")
} else {
}
if (input2 == morse_code[value2]) {
mySprite.say("Yes!" + morse_code[value2])
music.magicWand.play()
} else {
music.siren.play()
controller.vibrate(500)
mySprite.say("No!" + morse_code[value2])
}
功能演示
1,开机正常显示如下 :
提示关键字
2,当输入错误时 提示NO, 并输出正确的提示 以及对应的显示
3. 输入正确的提示 提示yes 和对应的输出
心得体会
非常感谢主办方
这次能玩上自己写的游戏 , O(∩_∩)O
期望后面能有更多好玩的东西。
附件下载
arcade-and_code (1).uf2
团队介绍
评论
0 / 100
查看更多