Purpleformer || A Platformer (Mobile Friendly) #GAMES

Instructions: NEW GAME NOW OUT: https://scratch.mit.edu/projects/588626439/\n\n\nNOW NEWLY RESTORED!\nSorry, it took so long!\n\nStay tuned for the sequal!\n\nNo Advertising!\n\n11 levels of platforming fun!!!\n\nMy most popular project.\n\nHard mode makes it so if you die you go back to level 1 and you cannot skip.\n\nIf you get stuck in the ground press r (to restart).\n\nMobile Friendly\n\nUse the arrow keys to move (now with down to fall faster). Dodge spikes and enemies. Get to the flag to move on. \n\nPress s to skip a level.

@Stage\n\nwhen flag clicked\nswitch backdrop to (backdrop5 v)\n\nwhen I receive [start v]\nforever\n    switch backdrop to ((Level) + (1))\nend\n\nwhen flag clicked\nforever\n    wait (.5) seconds\n    play sound [Inferno v] until done\n    wait (.5) seconds\n    play sound [Nebula v] until done\nend\n\n@Sprite5\n\n@Player\n\nset [brightness v] effect to (100)\n\nwhen flag clicked\nset [started v] to [0]\n\nwhen I receive [start v]\nset [started v] to [1]\n\nwhen flag clicked\nforever\n    if <(Level) < [11]> then\n        if <not <(Mode) = [Hard]>> then\n            if <<(started) = [1]> and <key (s v) pressed?>> then\n                change [level v] by (1)\n                broadcast (next level v)\n            end\n            wait until <not <key (s v) pressed?>>\n        end\n    end\nend\n\nwhen I receive [message1 v]\nif <(Clone?) = [true]> then\n    switch costume to (playertrail v)\n    change size by (-10)\n    change [ghost effect v] by (10)\n    set [ghost v] effect to (Ghost Effect)\n    if <(Ghost Effect) = [100]> then\n        delete this clone\n    end\nend\n\nwhen I start as a clone\nset [ghost effect v] to [50]\n\nwhen I receive [restart level v]\nshow\ngo to x: (-220) y: (-100)\nClear\nif <(Level) = [2]> then\n    broadcast (2 v)\nend\n\nwhen flag clicked\nset [wall jumping v] to [0]\ngo to x: (-200) y: (-100)\nset [velocity y v] to [0]\nset rotation style [left-right v]\n\ndefine Detect Ground <up?>\nchange [falling v] by (1)\nrepeat until <not <touching (ground v)?>>\n    if <up?> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling v] to [0]\n        set [velocity y v] to [0]\n    end\nend\n\ndefine Walk (direction) (speed)\nswitch costume to (playermoving v)\npoint in direction (direction)\nchange x by (speed)\nset [slope v] to [0]\nrepeat until <<(Slope) = [8]> or <not <touching (ground v)?>>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <(Slope) = [8]> then\n    change x by (() - (speed))\n    change y by (() - (Slope))\n    if <<<key (up arrow v) pressed?> or <<(mouse y) > ((y position) + (20))> and <mouse down?>>> and <([abs v] of (speed) ) > [3]>> then\n        if <(wall jumping) = [0]> then\n            set [velocity x v] to ((-1.2) * (speed))\n            set [velocity y v] to [11]\n            set [falling v] to [6]\n            set [wall jumping v] to [15]\n        end\n    else\n        set [velocity y v] to [0]\n    end\nend\n\ndefine Clear\ndelete this clone\n\nwhen I receive [start v]\nhide\nset [level v] to [1]\nforever\n    change [velocity y v] by (-1)\n    change y by (Velocity Y)\n    Detect Ground <(Velocity Y) > [0]>\n    if <(wall jumping) > [0]> then\n        change [wall jumping v] by (-1)\n    else\n        set [velocity x v] to ((Velocity X) * (0.7))\n        if <<key (left arrow v) pressed?> or <<(mouse x) < ((x position) + (20))> and <mouse down?>>> then\n            change [velocity x v] by (-1.5)\n        end\n        if <<key (right arrow v) pressed?> or <<(mouse x) > ((x position) + (20))> and <mouse down?>>> then\n            change [velocity x v] by (1.5)\n        end\n    end\n    if <(Velocity X) < [-1.5]> then\n        Walk [-90] (Velocity X)\n    else\n        if <(Velocity X) > [1.5]> then\n            Walk [90] (Velocity X)\n        else\n            switch costume to (playeridle v)\n        end\n    end\n    Animate\n    if <<<key (up arrow v) pressed?> or <<(mouse y) > ((y position) + (20))> and <mouse down?>>> and <(Falling) < [4]>> then\n        set [velocity y v] to [12]\n    end\n    if <<key (down arrow v) pressed?> or <<((y position) + (-20)) > (mouse y)> and <mouse down?>>> then\n        change [velocity y v] by (-1)\n    end\nend\n\nwhen I receive [start v]\nshow\nforever\n    set [clone? v] to [true]\n    create clone of (_myself_ v)\n    set [clone? v] to [false]\n    broadcast (message1 v)\n    wait (0) seconds\nend\n\nwhen I receive [start v]\nforever\n    if <<touching (spikes v)?> or <touching (enemies v)?>> then\n        if <(Mode) = [Hard]> then\n            set [level v] to [1]\n        end\n        broadcast (restart level v)\n    end\n    if <touching (end flag v)?> then\n        change [level v] by (1)\n        broadcast (next level v)\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nswitch costume to (playeridle v)\n\ndefine Animate\nif <(costume [name v]) = [PlayerIdle]> then\n    if <(Velocity Y) > [0]> then\n        switch costume to (idlejump v)\n    else\n        if <(Falling) > [0]> then\n            switch costume to (fallidle v)\n        else\n            switch costume to (playeridle v)\n        end\n    end\nelse\n    change y by (-10)\n    if <(Velocity Y) > [0]> then\n        switch costume to (playerjump v)\n    else\n        if <<(Falling) > [0]> and <not <touching (ground v)?>>> then\n            switch costume to (playerfall v)\n        else\n            switch costume to (playermoving v)\n        end\n    end\n    change y by (10)\nend\n\n@Ground\n\nwhen flag clicked\nhide\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\n\nset [ghost v] effect to (0)\n\nwhen I receive [start v]\nshow\nforever\n    switch costume to (Level)\nend\n\nset [brightness v] effect to (100)\n\n@Spikes\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\ngo to x: (36) y: (28)\nshow\nforever\n    switch costume to (Level)\n    if <(Level) = [10]> then\n        set [ghost v] effect to (100)\n    else\n        set [ghost v] effect to (0)\n    end\nend\n\n@end flag\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nshow\nforever\n    if <(Level) = [1]> then\n        go to x: (211) y: (109)\n    else\n        if <(Level) = [2]> then\n            go to x: (200) y: (-8)\n        else\n            if <(Level) = [3]> then\n                go to x: (211) y: (126)\n            else\n                if <(Level) = [4]> then\n                    go to x: (211) y: (130)\n                else\n                    if <(Level) = [5]> then\n                        go to x: (211) y: (-115)\n                    else\n                        if <(Level) = [6]> then\n                            go to x: (211) y: (120)\n                        else\n                            if <(Level) = [7]> then\n                                go to x: (211) y: (120)\n                            else\n                                if <(Level) = [8]> then\n                                    go to x: (211) y: (115)\n                                else\n                                    if <(Level) = [9]> then\n                                        go to x: (200) y: (-85)\n                                    else\n                                        if <(Level) = [10]> then\n                                            go to x: (200) y: (-85)\n                                        else\n                                            hide\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    wait (.1) seconds\n    next costume\nend\n\nwhen I receive [next level v]\nhide\n\nwhen I receive [restart level v]\nshow\n\n@Enemies\n\nwhen I receive [restart v]\ndelete this clone\n\ndefine Clone (x) (y)\ngo to x: (x) y: (y)\nswitch costume to (enemyidle v)\nset [clone# v] to [1]\ncreate clone of (_myself_ v)\nset [clone# v] to [0]\n\nswitch costume to (weapon1 v)\ncreate clone of (_myself_ v)\nswitch costume to (enemyidle v)\n\nwhen I start as a clone\nif <(Clone#) = [1]> then\n    clear graphic effects\n    set size to (100) %\n    show\n    set [enemyx v] to [0]\n    set [enemyy v] to [0]\n    go to [front v] layer\n    forever\n        if <touching (spikes v)?> then\n            clear graphic effects\n            set rotation style [all around v]\n            repeat (20)\n                turn right (15) degrees\n                change y by (10)\n                change [ghost v] effect by (5)\n            end\n            delete this clone\n        end\n        change [enemyy v] by (-1)\n        if <([x position v] of [player v]) < ((x position) - (10))> then\n            change [enemyx v] by ((0) - ((Speed) / (10)))\n            point in direction (-90)\n        end\n        if <((x position) - (-10)) < ([x position v] of [player v])> then\n            change [enemyx v] by ((Speed) / (10))\n            point in direction (90)\n        end\n        set [enemyx v] to ((Enemyx) * (0.9))\n        change x by (Enemyx)\n        if <touching (ground v)?> then\n            change y by (1)\n        end\n        if <touching (ground v)?> then\n            change y by (1)\n        end\n        if <touching (ground v)?> then\n            change y by (1)\n        end\n        if <touching (ground v)?> then\n            change y by (1)\n        end\n        if <touching (ground v)?> then\n            change y by (-4)\n            change x by ((Enemyx) * (-1))\n            if <(y position) < ([y position v] of [player v])> then\n                set [enemyy v] to [10]\n                if <([abs v] of (x) ) = (x)> then\n                    set [enemyx v] to [-10]\n                else\n                    set [enemyx v] to [10]\n                end\n            else\n                set [enemyx v] to [0]\n            end\n        end\n        change y by (Enemyy)\n        if <touching (ground v)?> then\n            change y by ((Enemyy) - ((Enemyy) * (2)))\n            set [enemyy v] to [0]\n        end\n        change y by (-1)\n        if <<((y position) - (-50)) < ([y position v] of [player v])> and <touching (ground v)?>> then\n            set [enemyy v] to [14]\n        end\n        change y by (1)\n        Animate\n    end\nend\n\nwhen flag clicked\nset [speed v] to [3]\n\nwhen I receive [restart level v]\nif  then\n    delete this clone\nend\nif <(Level) = [2]> then\n    Clone [-50] [-50]\nend\nif <(Level) = [4]> then\n    Clone [10] [90]\nend\n\nwhen I start as a clone\nif <(Clone#) = [1]> then\n    forever\n        set [clone# v] to [2]\n        create clone of (_myself_ v)\n        set [clone# v] to [1]\n        wait (0) seconds\n    end\nelse\n    set [ghost effect en v] to [50]\n    switch costume to (enemytrail v)\nend\n\nwhen I receive [message1 v]\nif <(Clone#) = [2]> then\n    change [ghost effect en v] by (10)\n    set [ghost v] effect to (Ghost Effect En)\n    change size by (-10)\n    if <(Ghost Effect En) = [100]> then\n        delete this clone\n    end\nend\n\nwhen flag clicked\nset [clone# v] to [0]\n\nwhen [r v] key pressed\nbroadcast (restart level v)\n\ndefine Animate\nif <(costume [name v]) = [PlayerIdle]> then\n    if <(Velocity Y) > [0]> then\n        switch costume to (idlejump v)\n    else\n        if <(Falling) > [0]> then\n            switch costume to (fallidle v)\n        else\n            switch costume to (enemyidle v)\n        end\n    end\nelse\n    change y by (-10)\n    if <(Velocity Y) > [0]> then\n        switch costume to (enemyjump v)\n    else\n        if <<(Falling) > [0]> and <not <touching (ground v)?>>> then\n            switch costume to (enemyfall v)\n        else\n            switch costume to (enemymoving v)\n        end\n    end\n    change y by (10)\nend\n\n@Sprite1\n\nwhen flag clicked\nhide\nforever\n    reset timer\nend\n\ngo to [front v] layer\n\nwhen [timer v] > (0.001)\nshow\n\n@Sprite3\n\nwhen flag clicked\nshow\ngo to x: (0) y: (100)\npoint in direction (90)\n\nwhen I receive [start v]\nstop [other scripts in sprite v]\nhide\ndelete this clone\n\n@Sprite4\n\nwhen flag clicked\nset size to (100) %\nshow\ngo to x: (0) y: (0)\nforever\n    if <touching (mouse-pointer v)?> then\n        set size to (110) %\n        if <mouse down?> then\n            hide\n            broadcast (start v)\n            stop [this script v]\n        end\n    else\n        set size to (100) %\n    end\nend\n\n@Sprite6\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nset [level v] to [0]\n\nwhen I receive [next level v]\nrun\n\ndefine run\ngo to [front v] layer\nset [ghost v] effect to (100)\nshow\nrepeat (20)\n    change [ghost v] effect by (-5)\nend\nbroadcast (restart level v)\nrepeat (20)\n    change [ghost v] effect by (5)\nend\nhide\n\nwhen I receive [start v]\nrun\n\n@Sprite7\n\nwhen I receive [next level v]\nshow\ngo to [front v] layer\ngo [backward v] (1) layers\n\nwhen I receive [restart level v]\nhide\n\nwhen I receive [start v]\nshow\ngo to [front v] layer\ngo [backward v] (1) layers\n\nwhen flag clicked\nhide\n\n@Sprite8\n\nwhen flag clicked\nswitch costume to (normal v)\nset size to (100) %\nshow\ngo to x: (0) y: (-120)\nforever\n    if <touching (mouse-pointer v)?> then\n        set size to (110) %\n        if <mouse down?> then\n            next costume\n            wait until <not <mouse down?>>\n        end\n    else\n        set size to (100) %\n    end\nend\n\nwhen I receive [start v]\nset [mode v] to (costume [name v])\nhide\n\n@Pen light (Not made by me)\n\nhide\n\nset [pen or stamp? v] to [Stamp]\n\nset [pen or stamp? v] to [Pen]\n\nwhen flag clicked\nset [torch power v] to [100]\ndelete all of [torch x v]\ndelete all of [torch y v]\ndelete all of [torch distances v]\nset [torch power v] to [65]\npen up\nerase all\nset pen size to (80)\nforever\n    erase all\n    if <<(Level) = [9]> or <(Level) = [10]>> then\n        Draw Light\n    end\nend\n\ndefine Draw Light\nset pen color to (#000000)\nerase all\ngo to x: (-240) y: (170)\nrepeat (18)\n    repeat (24)\n        Find Distance and Transparency\n        pen up\n        change x by (20)\n        pen down\n        set pen (brightness v) to (0)\n    end\n    pen up\n    change y by (-20)\n    set x to (-240)\nend\n\ndefine Find Distance and Transparency\nset [closest torch v] to [1000]\nset [distance from torch v] to ([sqrt v] of (((((x position) + (16)) - ([x position v] of [player v])) * (((x position) + (16)) - ([x position v] of [player v]))) + (((y position) - ([y position v] of [player v])) * ((y position) - ([y position v] of [player v])))) )\nif <(Distance From Torch) < (Closest Torch)> then\n    set [closest torch v] to (Distance From Torch)\nend\nset [distance from torch v] to ([sqrt v] of (((((x position) + (16)) - ([x position v] of [end flag v])) * (((x position) + (16)) - ([x position v] of [end flag v]))) + (((y position) - ([y position v] of [end flag v])) * ((y position) - ([y position v] of [end flag v])))) )\nif <(Distance From Torch) < (Closest Torch)> then\n    set [closest torch v] to (Distance From Torch)\nend\nset pen (transparency v) to (((Torch Power) + (100)) - (Closest Torch))\nif <[100] < (((Torch Power) + (100)) - (Closest Torch))> then\n    set pen (brightness v) to (100)\n    set pen (transparency v) to (99)\nend\n\nset [torch power v] to [75]\n\n@Sprite2\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\ngo to [back v] layer\nshow\nif <not <(Mode) = [Hard]>> then\n    forever\n        if <<touching (mouse-pointer v)?> and <mouse down?>> then\n            change [level v] by (1)\n            broadcast (next level v)\n            wait until <not <mouse down?>>\n        end\n        if <(Level) = [11]> then\n            hide\n            stop [this script v]\n        end\n    end\nend\nhide\n\n