【问题标题】:Calculate note upscroll speed through two variables通过两个变量计算音符上卷速度
【发布时间】:2021-04-14 13:05:18
【问题描述】:

我正在绝望地尝试在 Scratch 中重新创建一个 DDR 风格的节奏游戏克隆。 (但是,语言无关紧要,因为这个问题是关于数学的。)

我想知道;如何在控制音符速度时(游戏前)在音乐和音符之间实现不会延迟且不会破坏同步的完美同步。

需要的变量:

“math”:直接进入笔记中的“change y by”。

“dist”:直接转到其定义下方的“等待_秒”。

Sprite:注释解释器

when ????️ clicked
    set map to "q w p op op owp ..."
    set crawl to 8
    set bpm to 100
    set math to ((280 / crawl) / (bpm / 60) //needs improved formula!!
    set dist to ((math * (bpm / 60)) / 100) //needs improved formula!!
    comment "Y BOTTOM TO Y NOTE PRESSER DISTANCE IS 280px"
    set misses to 0
    set action to 0
    for each v in length of map
        if (letter v of map) = "q" then
            broadcast SENDLEFT
        else
            if (letter v of map) = "w" then
                broadcast SENDDOWN
            else
                if (letter v of map) = "o" then
                    broadcast SENDUP
                else
                    if (letter v of map) = "p" then
                        broadcast SENDRIGHT
                    else
                        if (letter v of map) = "" then
        wait dist seconds //wait until it can process next note

这就是“数学”的发展方向......

Sprite:下注

when I start as a clone
    go to front layer
    show
    repeat until (act = "down") and (touching down?) or (touching edge?) // detects when the "DOWN" (qWop) key is pressed
        change y by math //go up towards top of stage (Or note clickers if player is fast enough)
    if (touching edge?) then
        change misses by 1
    set act to 0
    delete this clone

舞台是这样的:

Stage appearance Stage appearance (with helper)

在现代 Microsoft Edge 89.0.774.76 上运行 Scratch 3.21.0; Windows 10 Home 20H2/2009(根据 Edge)

【问题讨论】:

    标签: javascript math mit-scratch


    【解决方案1】:

    “如何在音乐和音符之间实现完美同步,不会延迟......”?

    如果这是问题所在,则与使用 Scratch 有很大关系。

    几个技巧:

    • 每个块都定期发生:scratch 运行块,然后刷新屏幕,然后是下一个块...每次屏幕刷新都定期完成,因此每个块花费相同的时间。

    • 如果你想要一堆更快的块,例如对于计算,使用自定义块(粉红色的)并在构建它时勾选“运行而不刷新屏幕”。然后它以一个屏幕刷新的周期运行,但在完成之前不会进行屏幕更新。

    • 您可以通过运行充当节拍器的脚本来控制时间:

       when green flag
          forever
             broadcast tick
             wait 0.2 seconds (<-- or whatever the tempo is)
      

    然后是音乐和动画:

       when i receive tick
          play the_note
          move...
    

    【讨论】:

      【解决方案2】:

      这里有一个从头开始的块。添加音乐扩展。是 wait () beats block你也可以设置节奏。

      【讨论】:

      • 如果你能提供解释并重新格式化你的答案会更好,更有帮助。
      • 什么意思?
      • 有一个指南可以写一个好的答案。 stackoverflow.com/help/how-to-answer
      猜你喜欢
      • 2011-06-02
      • 2018-06-25
      • 1970-01-01
      • 1970-01-01
      • 2020-06-21
      • 2020-07-23
      • 1970-01-01
      • 2014-06-27
      • 2014-03-08
      相关资源
      最近更新 更多