Funpack10:Kitronik ARCADE游戏手柄 摩斯密码练习器
Funpack10:Kitronik ARCADE游戏手柄 摩斯密码练习器
标签
嵌入式系统
安先生
更新2021-08-31
596

功能介绍

  • 开发板
Kitronik ARCADE是一款专门设计用于运行复古街机游戏的平台 - 来自英国的Kitronik公司专为创客教育市场推出的Kitronik Arcade,搭配微软MakeCode Arcade编辑器一起使用。
 

arcade布局 图.png

 
  • 编程开发
Microsoft MakeCode Arcade

MakeCode Arcade 编辑器旨在让从初学者到经验丰富的游戏爱好者,都可以创建在浏览器或掌上游戏机上运行的复古街机游戏。它由拖放的块组成,这些块组合在一起形成程序。你还可以使用 Javascript 为 ARCADE 编写代码,并且已经支持 Python 编辑器!

 

  本期任务

设计一个摩斯密码练习器,SWA为点,SWB为横,从以下两种方式中任选一个完成:

.LCD屏上随机出现一个字符,敲出对应的组合(3-5个字符即可),正确时,蜂鸣器响;错误时,蜂鸣器发出振动 

 

图片2.png

 

 

  代码片段

 
  • 关键逻辑判断
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("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 == "-----") {
        output = textsprite.create("0")
    } else if (input2 == "..--..") {
        output = textsprite.create("?")
    } else if (input2 == "-..-.") {
        output = textsprite.create("/")
    } else if (input2 == "-....-") {
        output = textsprite.create("-")
    } else if (input2 == "") {
        output = textsprite.create("")
    }
  • 按键注册
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
    pause(100)
    info.stopCountdown()
    music.baDing.play()
    input2 = "" + input2 + "."
    mySprite.say(input2)
})
controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
    pause(100)
    info.stopCountdown()
    music.baDing.play()
    input2 = "" + input2 + "-"
    mySprite.say(input2)
})
controller.left.onEvent(ControllerButtonEvent.Pressed, function () {
    panduan()
    if (input2 == text_list[CODE]) {
        music.magicWand.play()
        info.changeScoreBy(1)
        mySprite2.say("答对了", 1000)
        pause(1000)
    } else {
        mySprite2.say(text_list[CODE])
        music.wawawawaa.play()
        mySprite2.say("答错了", 1000)
        info.changeLifeBy(-1)
    }
    pause(1000)
    output.destroy()
    next()
})
 
 
功能截图
 
答对,打错
截图如下如所示
FpK_zEium8Svq7d-1nGGhrrBk0tRFpZwk7sjbAeYtBaAXJ6pF7ISHo18Fpsg5vWEVCWbJpmhlPnt33C1KFdc
 
心得体会
 
希望下次能带来更多有趣的开发板 让大家都能参与其中。
附件下载
arcade-莫斯摩玛练习器 (3).uf2
团队介绍
安迪
评论
0 / 100
查看更多
目录
硬禾服务号
关注最新动态
0512-67862536
info@eetree.cn
江苏省苏州市苏州工业园区新平街388号腾飞创新园A2幢815室
苏州硬禾信息科技有限公司
Copyright © 2023 苏州硬禾信息科技有限公司 All Rights Reserved 苏ICP备19040198号