Platformer教學(下)#1
@Stage\n\nwhen flag clicked\nforever\n    play sound [BGM v] until done\nend\n\n@教學\n\nwhen flag clicked\ngo to x: (0) y: (0)\nswitch costume to (引言 v)\nforever\n    if <not <(costume [number v]) = (最後頁碼)>> then\n        if <mouse down?> then\n            next costume\n            wait until <not <mouse down?>>\n        end\n    end\n    if <not <(costume [number v]) = (最後頁碼)>> then\n        if <key (right arrow v) pressed?> then\n            next costume\n            wait until <not <key (right arrow v) pressed?>>\n        end\n    end\n    if <not <(costume [number v]) = [1]>> then\n        if <key (left arrow v) pressed?> then\n            switch costume to ((costume [number v]) - (1))\n            wait until <not <key (left arrow v) pressed?>>\n        end\n    end\n    if <not <(costume [number v]) = (最後頁碼)>> then\n        if <key (space v) pressed?> then\n            next costume\n            wait until <not <key (space v) pressed?>>\n        end\n    end\n    if <not <(costume [number v]) = (最後頁碼)>> then\n        if <key (down arrow v) pressed?> then\n            next costume\n            wait until <not <key (down arrow v) pressed?>>\n        end\n    end\n    if <not <(costume [number v]) = [1]>> then\n        if <key (up arrow v) pressed?> then\n            switch costume to ((costume [number v]) - (1))\n            wait until <not <key (up arrow v) pressed?>>\n        end\n    end\nend\n\nwhen flag clicked\nset [最後頁碼 v] to [15]\nforever\n    set [頁數# v] to (costume [number v])\nend\n\nwhen flag clicked\nforever\n    if <(頁數#) = [2]> then\n        broadcast (重置 v)\n        wait until <not <(頁數#) = [2]>>\n    end\nend\n\nwhen flag clicked\nforever\n    if <(頁數#) = [6]> then\n        broadcast (重置 v)\n        wait until <not <(頁數#) = [6]>>\n    end\nend\n\nwhen flag clicked\nforever\n    if <(頁數#) = [9]> then\n        set [lv.# v] to [1]\n        broadcast (重置 v)\n        wait until <not <(頁數#) = [9]>>\n    end\nend\n\nwhen flag clicked\nforever\n    if <(頁數#) = [13]> then\n        set [lv.# v] to [1]\n        broadcast (重置 v)\n        wait until <not <(頁數#) = [13]>>\n    end\nend\n\n@玩家\n\nwhen flag clicked\nbroadcast (重置 v)\nforever\n    if <key (d v) pressed?> then\n        change [xv v] by (1)\n    end\n    if <key (a v) pressed?> then\n        change [xv v] by (-1)\n    end\n    set [xv v] to ((Xv) * (0.9))\n    change x by (Xv)\n    if <<<touching (場景 v)?> or <touching (第1-3關 v)?>> or <touching (第1-4關 v)?>> then\n        change x by (() - (Xv))\n        set [xv v] to [0]\n    end\n    change y by (Yv)\n    if <<<touching (場景 v)?> or <touching (第1-3關 v)?>> or <touching (第1-4關 v)?>> then\n        change y by (() - (Yv))\n        set [yv v] to [0]\n        if <key (w v) pressed?> then\n            set [yv v] to [10]\n        end\n    else\n        change [yv v] by (-1)\n    end\n    if <(x position) > [240]> then\n        change [lv.# v] by (1)\n        broadcast (重置 v)\n    end\n    if <(頁數#) > [5]> then\n        if <(y position) < [-189]> then\n            broadcast (重置 v)\n        end\n    end\n    if <(頁數#) > [12]> then\n        if <(Lv.#) = [4]> then\n            if <(x position) > [215]> then\n                set x to (215)\n            end\n        end\n    end\nend\n\nwhen flag clicked\ngo to x: (-180) y: (-50)\nhide\nwait (0.1) seconds\nforever\n    if <(頁數#) = [2]> then\n        show\n    else\n        if <(頁數#) = [3]> then\n            show\n        else\n            if <(頁數#) = [6]> then\n                show\n            else\n                if <(頁數#) = [9]> then\n                    show\n                else\n                    if <(頁數#) = [13]> then\n                        show\n                    else\n                        hide\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [重置 v]\ngo to x: (-180) y: (-50)\nset [xv v] to [0]\nset [yv v] to [0]\n\nwhen flag clicked\nforever\n    if <(頁數#) = [3]> then\n        if <(y position) < [-75]> then\n            set [xv v] to [0]\n            set [yv v] to [0]\n            set y to (-50)\n        end\n        wait until <not <(頁數#) = [3]>>\n    end\nend\n\n@場景\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nwait (0.1) seconds\nforever\n    if <(頁數#) = [2]> then\n        show\n    else\n        if <(頁數#) = [6]> then\n            show\n        else\n            hide\n        end\n    end\nend\n\nwhen flag clicked\nset [lv.# v] to [1]\n\nwhen flag clicked\nforever\n    if <(頁數#) = [6]> then\n        switch costume to (2 v)\n    else\n        switch costume to (1 v)\n    end\nend\n\n@第1-3關\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nwait (0.1) seconds\nforever\n    if <(頁數#) = [9]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    switch costume to (Lv.#)\nend\n\n@第1-4關\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nwait (0.1) seconds\nforever\n    if <(頁數#) = [13]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    switch costume to (Lv.#)\nend\n\n@Lv.#\n\nwhen flag clicked\nforever\n    if <(頁數#) = [13]> then\n        show variable [lv.# v]\n    else\n        hide variable [lv.# v]\n    end\nend\n\nwhen flag clicked\nforever\n    if <(頁數#) = [13]> then\n        set [lv.# v] to [4]\n    end\nend\n\n@封面\n\nwhen flag clicked\nforever\n    set [ghost v] effect to (100)\n    show\nend\n\n
Platformer教學(下)#1\n因爲最近我比較忙，幾天沒更新了，\n所以就提早發佈了下部分的部分内容。\n===================================\n下一頁 - 點擊 / 右方向鍵 / 下方向鍵 / 空白鍵\n上一頁 - 左方向鍵 / 上方向鍵\n===================================\nPlatformer教學(上)\nhttps://scratch.mit.edu/projects/592731535/\n\nPlatformer教學(下)#2\nhttps://scratch.mit.edu/projects/614645566/\n===================================\n補充：有一個Bug: 角色可以貼著天花板走\n           下次教學會再教你們怎樣修復。\n\n#ericbu #tutorial