platformer tutorial


@Stage\n\nwhen flag clicked\nforever\n    play sound [Csikos Post v] until done\nend\n\n@Sprite1\n\nwhen flag clicked\nforever\n    if <(platformer) = [0]> then\n        hide variable [yv v]\n        hide variable [xv v]\n    end\n    if <(platformer) = [1]> then\n        if <key (right arrow v) pressed?> then\n            change [xv v] by (1)\n        end\n        if <key (left arrow 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 color (#000000)?> then\n            change y by (1)\n            if <touching color (#000000)?> then\n                change y by (1)\n                if <touching color (#000000)?> then\n                    change y by (1)\n                    if <touching color (#000000)?> then\n                        change y by (1)\n                        if <touching color (#000000)?> then\n                            change y by (1)\n                            if <touching color (#000000)?> then\n                                change x by ((Xv) * (-1))\n                                change y by (-5)\n                                if <key (up arrow v) pressed?> then\n                                    if <(Xv) > [0]> then\n                                        set [xv v] to [-5]\n                                    else\n                                        set [xv v] to [5]\n                                    end\n                                    set [yv v] to [10]\n                                else\n                                    set [xv v] to [0]\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n        change y by (-1)\n        if <touching color (#000000)?> then\n            if <key (up arrow v) pressed?> then\n                set [yv v] to [15]\n            end\n        end\n        change y by (1)\n        change [yv v] by (-1)\n        change y by (Yv)\n        if <touching color (#000000)?> then\n            change y by ((Yv) * (-1))\n            set [yv v] to [0]\n        end\n        hide variable [xv v]\n    end\n    if <(platformer) = [2]> then\n        show variable [xv v]\n        if <key (right arrow v) pressed?> then\n            change [xv v] by (1)\n        end\n        if <key (left arrow 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        set y to (-111)\n    end\n    if <(platformer) = [3]> then\n        show variable [xv v]\n        if <key (right arrow v) pressed?> then\n            change [xv v] by (1)\n        end\n        if <key (left arrow 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 color (#000000)?> then\n            change y by (1)\n            if <touching color (#000000)?> then\n                change y by (1)\n                if <touching color (#000000)?> then\n                    change y by (1)\n                    if <touching color (#000000)?> then\n                        change y by (1)\n                        if <touching color (#000000)?> then\n                            change y by (1)\n                            if <touching color (#000000)?> then\n                                change x by ((Xv) * (-1))\n                                change y by (-5)\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    if <(platformer) = [5]> then\n        if <key (right arrow v) pressed?> then\n            change [xv v] by (1)\n        end\n        if <key (left arrow 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 color (#000000)?> then\n            change y by (1)\n            if <touching color (#000000)?> then\n                change y by (1)\n                if <touching color (#000000)?> then\n                    change y by (1)\n                    if <touching color (#000000)?> then\n                        change y by (1)\n                        if <touching color (#000000)?> then\n                            change y by (1)\n                            if <touching color (#000000)?> then\n                                change x by ((Xv) * (-1))\n                                change y by (-5)\n                            end\n                        end\n                    end\n                end\n            end\n        end\n        change y by (-1)\n        if <touching color (#000000)?> then\n            if <key (up arrow v) pressed?> then\n                set [yv v] to [15]\n            end\n        end\n        change y by (1)\n        change [yv v] by (-1)\n        change y by (Yv)\n        if <touching color (#000000)?> then\n            change y by ((Yv) * (-1))\n            set [yv v] to [0]\n        end\n        show variable [yv v]\n        show variable [xv v]\n    end\n    if <(platformer) = [6]> then\n        if <key (right arrow v) pressed?> then\n            change [xv v] by (1)\n        end\n        if <key (left arrow 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 color (#000000)?> then\n            change y by (1)\n            if <touching color (#000000)?> then\n                change y by (1)\n                if <touching color (#000000)?> then\n                    change y by (1)\n                    if <touching color (#000000)?> then\n                        change y by (1)\n                        if <touching color (#000000)?> then\n                            change y by (1)\n                            if <touching color (#000000)?> then\n                                change x by ((Xv) * (-1))\n                                change y by (-5)\n                                if <key (up arrow v) pressed?> then\n                                    if <(Xv) > [0]> then\n                                        set [xv v] to [-5]\n                                    else\n                                        set [xv v] to [5]\n                                    end\n                                    set [yv v] to [10]\n                                else\n                                    set [xv v] to [0]\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n        change [yv v] by (-1)\n        change y by (Yv)\n        if <touching color (#000000)?> then\n            change y by ((Yv) * (-1))\n            set [yv v] to [0]\n        end\n        change y by (-1)\n        if <touching color (#000000)?> then\n            if <key (up arrow v) pressed?> then\n                set [yv v] to [15]\n            end\n        end\n        change y by (1)\n        if <touching color (#ff0000)?> then\n            go to x: (-212) y: (134)\n        end\n        if <(x position) > [220]> then\n            go to x: (-212) y: (134)\n            broadcast (next backdrop v)\n        end\n    end\nend\n\nwhen I receive [show platform v]\nshow\ngo to x: (-212) y: (134)\nset y to (-111)\n\nwhen I receive [hide platformer v]\nhide\n\n@Sprite2\n\nwhen flag clicked\nswitch costume to (backdrop1 v)\nset [platformer v] to [0]\nbroadcast (hide platformer v)\nforever\n    space\nend\n\nwhen flag clicked\nforever\n    if <(costume [number v]) = [3]> then\n        if <not <(platformer) = [1]>> then\n            set [platformer v] to [1]\n            broadcast (show platform v)\n        end\n    else\n        if <(costume [number v]) = [14]> then\n            if <not <(platformer) = [2]>> then\n                set [platformer v] to [2]\n                broadcast (show platform v)\n            end\n        else\n            if <(costume [number v]) = [20]> then\n                if <not <(platformer) = [3]>> then\n                    set [platformer v] to [3]\n                    broadcast (show platform v)\n                end\n            else\n                if <<(costume [number v]) = [23]> or <(costume [number v]) = [24]>> then\n                    if <not <(platformer) = [4]>> then\n                        set [platformer v] to [4]\n                        broadcast (show platform2 v)\n                    end\n                else\n                    if <(costume [number v]) = [28]> then\n                        if <not <(platformer) = [5]>> then\n                            set [platformer v] to [5]\n                            broadcast (show platform v)\n                        end\n                    else\n                        if <(costume [number v]) = [36]> then\n                            if <not <(platformer) = [1]>> then\n                                set [platformer v] to [1]\n                                broadcast (show platform v)\n                            end\n                        else\n                            if <<(costume [number v]) = [40]> or <(costume [number v]) = [41]>> then\n                                if <not <(platformer) = [6]>> then\n                                    set [platformer v] to [6]\n                                    broadcast (show platform v)\n                                end\n                            else\n                                if <not <(platformer) = [0]>> then\n                                    set [platformer v] to [0]\n                                    broadcast (hide platformer v)\n                                    broadcast (hide platformer2 v)\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine space\nwait (0.4) seconds\nwait until <<key (space v) pressed?> or <<key (a v) pressed?> or <key (d v) pressed?>>>\nif <<key (space v) pressed?> or <key (d v) pressed?>> then\n    next costume\nelse\n    switch costume to ((costume [number v]) - (1))\nend\n\nwhen I receive [next backdrop v]\nnext costume\n\n@Sprite3\n\nwhen I receive [show platform2 v]\nshow\ngo to x: (-92) y: (127)\n\nwhen flag clicked\nforever\n    if <(platformer) = [4]> then\n        set [yv v] to [0]\n        go to x: (-92) y: (127)\n        repeat until <[-140] > (y position)>\n            change [yv v] by (-1)\n            change y by (Yv)\n        end\n    end\nend\n\nwhen I receive [hide platformer2 v]\nhide\n\n@Sprite4\n\nwhen I receive [show platform2 v]\nshow\ngo to x: (68) y: (127)\n\nwhen flag clicked\nforever\n    if <(platformer) = [4]> then\n        go to x: (68) y: (127)\n        repeat until <[-140] > (y position)>\n            change y by (-5)\n        end\n    end\nend\n\nset [yv v] to [0]\ngo to x: (-92) y: (127)\n\nchange [yv v] by (-1)\n\nwhen I receive [hide platformer2 v]\nhide\n\n@example\n\nforever\n    if <key (right arrow v) pressed?> then\n        change [xv v] by (1)\n    end\n    if <key (left arrow 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 color (#000000)?> then\n        change y by (1)\n        if <touching color (#000000)?> then\n            change y by (1)\n            if <touching color (#000000)?> then\n                change y by (1)\n                if <touching color (#000000)?> then\n                    change y by (1)\n                    if <touching color (#000000)?> then\n                        change y by (1)\n                        if <touching color (#000000)?> then\n                            change x by ((Xv) * (-1))\n                            change y by (-5)\n                            if <key (up arrow v) pressed?> then\n                                if <(Xv) > [0]> then\n                                    set [xv v] to [-5]\n                                else\n                                    set [xv v] to [5]\n                                end\n                                set [yv v] to [10]\n                            else\n                                set [xv v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    change [yv v] by (-1)\n    change y by (Yv)\n    if <touching color (#000000)?> then\n        change y by ((Yv) * (-1))\n        set [yv v] to [0]\n    end\n    change y by (-1)\n    if <touching color (#000000)?> then\n        if <key (up arrow v) pressed?> then\n            set [yv v] to [15]\n        end\n    end\n    change y by (1)\n    if <touching color (#ff0000)?> then\n        go to x: (-212) y: (134)\n    end\n    if <(x position) > [220]> then\n        go to x: (-212) y: (134)\n        switch backdrop to (next backdrop v)\n    end\nend\n\n@Sprite5\n\nwhen flag clicked\nhide\n\nhide\n\nshow\n\n