Platformer gimmick!

Instructions: スペースキーを押して、ボタンを押そう！\nPress space!\n\n\n#Platformer #actiongaem #gaem\n\nmusic @syokaki \n\nhttps://scratch.mit.edu/projects/548585315

@Stage\n\n@スプライト1\n\nwhen flag clicked\nhide\nforever\n    play sound [Masked Heroes v] until done\nend\n\nshow\ngo to [front v] layer\n\n@スプライト2\n\nwhen flag clicked\nshow\nswitch costume to (k v)\ngo to x: (-220) y: (-87)\nset [x v] to [0]\nset [y v] to [0]\nforever\n    if <(上下) = [下]> then\n        switch costume to (2 v)\n        change [y v] by (-3)\n        change y by (y)\n        if <<touching (地面 v)?> or <touching (壁 v)?>> then\n            change y by ((0) - (y))\n            set [y v] to [0]\n        end\n    else\n        switch costume to (1 v)\n        change [y v] by (-1)\n        if <<key (right arrow v) pressed?> or <<mouse down?> and <[20] < (mouse x)>>> then\n            change [x v] by (1.2)\n        end\n        if <<key (left arrow v) pressed?> or <<mouse down?> and <(mouse x) < [-20]>>> then\n            change [x v] by (-1.2)\n        end\n        set [x v] to ((x) * (0.9))\n        change x by (x)\n        if <<touching (地面 v)?> or <touching (壁 v)?>> then\n            change y by (1)\n            if <<touching (地面 v)?> or <touching (壁 v)?>> then\n                change y by (1)\n                if <<touching (地面 v)?> or <touching (壁 v)?>> then\n                    change y by (1)\n                    if <<touching (地面 v)?> or <touching (壁 v)?>> then\n                        change y by (1)\n                        if <<touching (地面 v)?> or <touching (壁 v)?>> then\n                            change y by (-2)\n                            change x by ((x) * (-1))\n                            set [x v] to [0]\n                            if <<(s) = [8]> and <<key (up arrow v) pressed?> or <<mouse down?> and <[10] < (mouse y)>>>> then\n                                set [y v] to [15]\n                            else\n                            end\n                            if <(x) = ([abs v] of (x) )> then\n                                set [x v] to [-10]\n                            else\n                                set [x v] to [10]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n        change y by (y)\n        if <<touching (地面 v)?> or <touching (壁 v)?>> then\n            change y by ((0) - (y))\n            set [y v] to [0]\n        end\n        change y by (-2)\n        if <<<key (up arrow v) pressed?> and <<touching (地面 v)?> or <touching (壁 v)?>>> or <<<mouse down?> and <[10] < (mouse y)>> and <<touching (地面 v)?> or <touching (壁 v)?>>>> then\n            wait (０) seconds\n            if <<touching (地面 v)?> or <touching (壁 v)?>> then\n                set [y v] to [15]\n            end\n        end\n        change y by (1)\n        if <<[239] < (x position)> and <not <(s) = [8]>>> then\n            broadcast (NEXT v)\n            set [x v] to [0]\n            set [y v] to [0]\n            change [s v] by (1)\n            go to x: (-200) y: (-52)\n        end\n        if <<touching (スプライト6 v)?> or <touching (スプライト4 v)?>> then\n            go to x: (-200) y: (-52)\n            set [x v] to [0]\n            set [y v] to [0]\n        end\n    end\n    if <(y position) < [-170]> then\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n        clear graphic effects\n        go to x: (-200) y: (-52)\n        set [x v] to [0]\n        set [y v] to [0]\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (赤 v)?> then\n        go to x: (-200) y: (-70)\n    end\nend\n\nif <not <(s) = [8]>> then\n    if <key (space v) pressed?> then\n        wait until <not <key (space v) pressed?>>\n        broadcast (魂 v) and wait\n        if <(上下) = [下]> then\n            set [上下 v] to [上]\n        else\n            set [上下 v] to [下]\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <(s) = [8]> then\n        set size to (30) %\n    else\n        set size to (50) %\n    end\nend\n\n@地面\n\nwhen flag clicked\ngo to x: (0) y: (0)\nforever\n    switch costume to (s)\nend\n\n@スプライト3\n\nwhen flag clicked\nshow\nset [上下 v] to [上]\nset [x v] to [0]\nset [y v] to [0]\nset [s v] to [1]\ngo to x: (-220) y: (89)\nforever\n    if <(s) = [8]> then\n        hide\n    else\n        if <(上下) = [上]> then\n            switch costume to (2 v)\n            change [ｙ v] by (3)\n            change y by (ｙ)\n            if <touching (地面 v)?> then\n                change y by ((0) - (ｙ))\n                set [ｙ v] to [0]\n            end\n        else\n            show\n            switch costume to (1 v)\n            change [ｙ v] by (1)\n            if <<key (right arrow v) pressed?> or <<mouse down?> and <[20] < (mouse x)>>> then\n                change [ｘ v] by (1)\n            end\n            if <<key (left arrow v) pressed?> or <<mouse down?> and <(mouse x) < [-20]>>> then\n                change [ｘ v] by (-1)\n            end\n            set [ｘ v] to ((ｘ) * (0.9))\n            change x by (ｘ)\n            if <touching (地面 v)?> then\n                change y by (-1)\n                if <touching (地面 v)?> then\n                    change y by (-1)\n                    if <touching (地面 v)?> then\n                        change y by (-1)\n                        if <touching (地面 v)?> then\n                            change y by (-1)\n                            if <touching (地面 v)?> then\n                                change y by (4)\n                                change x by ((ｘ) * (-1))\n                                set [ｘ v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n            change y by (ｙ)\n            if <touching (地面 v)?> then\n                change y by ((0) - (ｙ))\n                set [ｙ v] to [0]\n            end\n            change y by (2)\n            if <<<key (up arrow v) pressed?> and <touching (地面 v)?>> or <<<mouse down?> and <[10] < (mouse y)>> and <touching (地面 v)?>>> then\n                set [ｙ v] to [-10]\n            end\n            if <[233] < (x position)> then\n                broadcast (NEXT v)\n                wait (0.7) seconds\n                go to x: (-200) y: (-52)\n                set [x v] to [0]\n                set [y v] to [0]\n                change [s v] by (1)\n            end\n            change y by (-2)\n            if <touching (スプライト6 v)?> then\n                go to x: (-200) y: (-52)\n                set [x v] to [0]\n                set [y v] to [0]\n            end\n        end\n    end\nend\n\nif <<key (up arrow v) pressed?> or <<mouse down?> and <[10] < (mouse y)>>> then\n    set [ｙ v] to [-15]\n    if <(ｘ) = ([abs v] of (ｘ) )> then\n        set [ｘ v] to [-10]\n    else\n        set [ｘ v] to [10]\n    end\nelse\nend\n\nwhen I receive [next v]\ngo to x: (-200) y: (52)\nset [x v] to [0]\nset [y v] to [0]\n\n@ボタン\n\nwhen flag clicked\ndelete all of [ギミック v]\ninsert [] at (1) of [ギミック v] \ninsert [ボタン壁] at (2) of [ギミック v] \ninsert [ボタン壁穴] at (3) of [ギミック v] \ninsert [ボタン矢ずっとボーン] at (4) of [ギミック v] \ninsert [壁ボタン落とし穴] at (5) of [ギミック v] \ninsert [ボタン] at (6) of [ギミック v] \ninsert [ボタン敵ストーン] at (7) of [ギミック v] \ninsert [決戦] at (8) of [ギミック v] \nswitch costume to (ボタン v)\nhide\n\ndefine a\nswitch costume to (ボタン v)\nforever\n    if < (costume [name v]) contains [ボタン]?> then\n        if <touching (スプライト3 v)?> then\n            switch costume to (コスチューム3 v)\n            play sound [ポップ v] until done\n            broadcast (ギミック v)\n            stop [this script v]\n        end\n    end\n    if < (item (s) of [ギミック v]) contains [ボタン]?> then\n        show\n    else\n        hide\n    end\nend\n\nwhen I receive [next v]\na\n\n@壁\n\nwhen flag clicked\ngo to x: (0) y: (0)\nforever\n    if < (item (s) of [ギミック v]) contains [壁]?> then\n        show\n        if < (item (s) of [ギミック v]) contains [落とし穴]?> then\n            switch costume to (4 v)\n            if <touching (スプライト2 v)?> then\n                hide\n            end\n        else\n            if < (item (s) of [ギミック v]) contains [穴]?> then\n                switch costume to (3 v)\n            else\n                switch costume to (2 v)\n            end\n        end\n    else\n        if < (item (s) of [ギミック v]) contains [壁]?> then\n            show\n        else\n            hide\n        end\n    end\nend\n\nwhen I receive [ギミック v]\nif <(s) = [2]> then\n    replace item (2) of [ギミック v] with []\nelse\n    if <(s) = [3]> then\n        replace item (3) of [ギミック v] with []\n    else\n        if <(s) = [5]> then\n            replace item (5) of [ギミック v] with [壁穴]\n        else\n            if <(s) = [6]> then\n                replace item (3) of [ギミック v] with []\n            end\n        end\n    end\nend\n\nforever\n    switch costume to (s)\nend\n\n@スプライト8\n\nwhen flag clicked\nshow\ngo to x: (113) y: (-83)\nforever\n    if <not <(s) = [8]>> then\n        if <<key (space v) pressed?> or <<touching (mouse-pointer v)?> and <mouse down?>>> then\n            wait until <not <<key (space v) pressed?> or <<touching (mouse-pointer v)?> and <mouse down?>>>>\n            broadcast (魂 v) and wait\n            if <(上下) = [下]> then\n                set [上下 v] to [上]\n            else\n                set [上下 v] to [下]\n            end\n        end\n    end\nend\n\n@スプライト5\n\nwhen I receive [魂 v]\nshow\nset [ghost v] effect to (50)\nif <(上下) = [上]> then\n    go to (スプライト2 v)\n    point towards (スプライト3 v)\n    set [a v] to (distance to [スプライト3 v])\nelse\n    go to (スプライト3 v)\n    point towards (スプライト2 v)\n    set [a v] to (distance to [スプライト2 v])\nend\ngo to [back v] layer\nrepeat until <<<touching (スプライト3 v)?> and <(上下) = [上]>> or <<touching (スプライト2 v)?> and <(上下) = [下]>>>\n    move ((a) - ((a) / (1.2))) steps\n    change [a v] by (((a) - ((a) / (1.2))) * (-1))\nend\nrepeat (10)\n    move ((a) - ((a) / (1.2))) steps\n    change [a v] by (((a) - ((a) / (1.2))) * (-1))\nend\nhide\n\nwhen flag clicked\nhide\n\n@スプライト6\n\nwhen flag clicked\nset [特別 v] to [0]\nset [s v] to [1]\nforever\n    if < (item (s) of [ギミック v]) contains [矢ずっと]?> then\n        create clone of (_myself_ v)\n        if <(s) = [4]> then\n            wait (0.5) seconds\n        end\n    else\n        if < (item (s) of [ギミック v]) contains [決戦]?> then\n            set [特別 v] to [1]\n            create clone of (_myself_ v)\n        else\n            hide\n        end\n    end\nend\n\nwhen I receive [ギミック v]\nif <(s) = [4]> then\n    broadcast (NEXT v)\n    set [特別 v] to [ボタン]\n    repeat (10)\n        create clone of (_myself_ v)\n    end\n    set [特別 v] to [0]\nelse\n    if <(s) = [6]> then\n        set [特別 v] to [どんまい！]\n        set [ｗ v] to [160]\n        replace item (6) of [ギミック v] with [矢ずっと]\n    end\nend\n\nwhen I start as a clone\nshow\nif <(特別) = [0]> then\n    if <(pick random (1) to (2)) = [1]> then\n        set [方向 v] to [上]\n        point in direction (180)\n        if <(s) = [4]> then\n            go to x: (pick random (0) to (240)) y: (-180)\n        end\n    else\n        set [方向 v] to [左]\n        point in direction (90)\n        go to x: (240) y: (pick random (-150) to (160))\n    end\n    set [スピード v] to (pick random (30) to (70))\nelse\n    if <(特別) = [ボタン]> then\n        go to (特別)\n        set [方向 v] to [左]\n        point in direction (90)\n        set [スピード v] to (pick random (30) to (70))\n    else\n        if <(特別) = [どんまい！]> then\n            set [方向 v] to [左]\n            point in direction (90)\n            set [スピード v] to (pick random (30) to (70))\n            go to x: (240) y: (ｗ)\n            change [ｗ v] by (-20)\n            if <(ｗ) < [-140]> then\n                set [ｗ v] to [160]\n            end\n        else\n        end\n    end\nend\nrepeat until <<(x position) < [-220]> or <[170] < (y position)>>\n    if <(方向) = [上]> then\n        change y by (スピード)\n    else\n        change x by ((スピード) * (-1))\n    end\nend\ndelete this clone\n\nrepeat (10)\n    create clone of (_myself_ v)\nend\nset [特別 v] to [0]\n\nset [方向 v] to (item (a) of [決戦 v])\npoint in direction (90)\nset [スピード v] to (pick random (30) to (70))\ngo to x: (240) y: (ｗ)\nchange [ｗ v] by (-20)\nif <(ｗ) < [-140]> then\n    set [ｗ v] to [160]\nend\n\n@スプライト4\n\nwhen flag clicked\nhide\nwait (1) seconds\nforever\n    if < (item (s) of [ギミック v]) contains [敵]?> then\n        show\n        歩く\n    else\n        hide\n    end\nend\n\ndefine 歩く\ngo to x: (160) y: (-70)\npoint in direction (90)\nrepeat (40)\n    move (-2) steps\n    if <touching (スプライト7 v)?> then\n        replace item (7) of [ギミック v] with []\n        hide\n    end\nend\npoint in direction (-90)\nrepeat (40)\n    move (-2) steps\n    if <touching (スプライト7 v)?> then\n        hide\n        replace item (7) of [ギミック v] with []\n    end\nend\npoint in direction (90)\n\n@スプライト7\n\nwhen flag clicked\nhide\n\nwhen I receive [ギミック v]\nset [ｙ v] to [0]\nif <(s) = [7]> then\n    show\n    go to x: (55) y: (180)\n    repeat (60)\n        change [ｙ v] by (-0.5)\n        change y by (ｙ)\n    end\n    go to [back v] layer\n    hide\nelse\n    if <(s) = [6]> then\n    end\nend\n\n@赤\n\nwhen flag clicked\nhide\nwait (1) seconds\nwait until <(s) = [8]>\nreset timer\nforever\n    set [停止 v] to [0]\n    横から\n    set [停止 v] to [x]\n    縦から\n    set [停止 v] to [0]\nend\n\ndefine 横から\nrepeat (15)\n    set [a v] to (pick random (1) to (4))\n    set x to (250)\n    if <(a) = [1]> then\n        set y to (-85)\n    else\n        if <(a) = [2]> then\n            set y to (20)\n        else\n            if <(a) = [3]> then\n                set y to (108)\n            else\n                set y to (168)\n            end\n        end\n    end\n    create clone of (_myself_ v)\n    wait (0.7) seconds\nend\n\ndefine 縦から\nrepeat (30)\n    set y to (-180)\n    set x to (pick random (-240) to (240))\n    create clone of (_myself_ v)\n    wait (0.3) seconds\nend\n\nwhen I start as a clone\nshow\nif < (a) contains [特殊]?> then\n    動く [] [] [] [] (letter (3) of (a))\nelse\n    if <(x position) = [250]> then\n        動く [x] [-10] [] [] []\n    end\n    if <(y position) = [-180]> then\n        動く [] [] [y] [-10] []\n    end\nend\n\ndefine 動く (x) (xスピード) (y) (yスピード) (特殊)\nif <(x) = [x]> then\n    point in direction (90)\n    repeat (10)\n        move (xスピード) steps\n        確認 (x)\n    end\n    repeat until <touching (_edge_ v)?>\n        move (xスピード) steps\n        確認 (x)\n    end\n    delete this clone\nelse\n    if <(y) = [y]> then\n        point in direction (180)\n        repeat (10)\n            move (yスピード) steps\n            確認 (y)\n        end\n        repeat until <touching (_edge_ v)?>\n            move (yスピード) steps\n            確認 (y)\n        end\n        delete this clone\n    else\n        if <(特殊) = [1]> then\n    end\nend\n\ndefine 確認 (名前)\nif <touching (スプライト2 v)?> then\nend\nif < (停止) contains (名前)?> then\n    wait until <not <(停止) = (名前)>>\nend\n\nstop [other scripts in sprite v]\n\n