Red's Adventure - Platformer - Mobile friendly


@Stage\n\nwhen flag clicked\nforever\n    if <<<<(level) = [8]> or <(level) = [9]>> or <(level) = [10]>> or <(level) = [11]>> then\n        switch backdrop to (backdrop2 v)\n    else\n        switch backdrop to (backdrop1 v)\n    end\nend\n\n@coin\n\nwhen flag clicked\nset [coin v] to [0]\nforever\n    next costume\n    wait (0.01) seconds\nend\n\nwhen flag clicked\nset [ghost v] effect to (20)\nswitch costume to (costume1 v)\ngo to [front v] layer\nforever\n    if <(level) = [4]> then\n        show\n        go to x: (85) y: (-164)\n        if <touching (red v)?> then\n            change [coin v] by (1)\n            start sound [Connect v]\n            repeat until <(level) = [5]>\n                hide\n            end\n        end\n    else\n        if <(level) = [9]> then\n            show\n            go to x: (12) y: (45)\n            if <touching (red v)?> then\n                start sound [Connect v]\n                change [coin v] by (1)\n                repeat until <(level) = [10]>\n                    hide\n                end\n            end\n        else\n            hide\n            if <(level) = [13]> then\n                show\n                go to x: (46) y: (71)\n                if <touching (red v)?> then\n                    start sound [Connect v]\n                    change [coin v] by (1)\n                    repeat until <(level) = [14]>\n                        hide\n                    end\n                end\n            else\n                hide\n            end\n        end\n    end\nend\n\n@assets\n\n@Level\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nwhen I receive [next level v]\nnext costume\n\n@RED\n\nwhen I start as a clone\nrepeat (10)\n    change [ghost v] effect by (15)\n    change size by (-2)\nend\ndelete this clone\n\ndefine Controls - Left and Right\nset [speed x v] to ((speed x) * (0.7))\nif <<<<key (a v) pressed?> or <key (left arrow v) pressed?>> or <<(mouse x) < (x position)> and <mouse down?>>> and <not <touching (water v)?>>> then\n    change [speed x v] by (-1.5)\nend\nif <<<<key (d v) pressed?> or <key (right arrow v) pressed?>> or <<(x position) < (mouse x)> and <mouse down?>>> and <not <touching (water v)?>>> then\n    change [speed x v] by (1.5)\nend\nif <<<<key (a v) pressed?> or <key (left arrow v) pressed?>> or <<(mouse x) < (x position)> and <mouse down?>>> and <touching (water v)?>> then\n    change [speed x v] by (-0.8)\nend\nif <<<<key (d v) pressed?> or <key (right arrow v) pressed?>> or <<(x position) < (mouse x)> and <mouse down?>>> and <touching (water v)?>> then\n    change [speed x v] by (0.8)\nend\n\ndefine Walk (direction) (speed) max step (step)\npoint in direction (direction)\nchange x by (speed)\nchange [frame v] by (([abs v] of (speed) ) / (8))\nset [slope v] to [0]\nGet Touching <(in platforrm) = [1]>\nrepeat until <<(slope) = (step)> or <(touch) = [0]>>\n    change y by (1)\n    change [slope v] by (1)\n    Get Touching <(in platforrm) = [1]>\nend\nif <(slope) = (step)> then\n    change x by ((0) - (speed))\n    change y by ((0) - (slope))\n    if <<(touch) = [1]> and <(in platforrm) = [1]>> then\n        set [in platforrm v] to [2]\n        Walk (direction) (speed) max step (step)\n        if <(speed x) = [0]> then\n            set [in platforrm v] to [1]\n        end\n    else\n        if <<<key (w v) pressed?> and <([abs v] of (speed) ) > [3.5]>> and <(touch) > [1]>> then\n            set [speed x v] to ((-1.2) * (speed))\n            set [speed y v] to [11]\n            set [falling? v] to [6]\n            set [wall jump v] to [15]\n        else\n            set [speed x v] to [0]\n        end\n    end\nend\n\ndefine Controls - Jump, Crouch\nif <touching (water v)?> then\n    if <<<key (w v) pressed?> or <key (up arrow v) pressed?>> or <<mouse down?> and <(y position) < (mouse y)>>> then\n        change [speed y v] by (2)\n    else\n        change [speed y v] by (-0.01)\n    end\nelse\n    if <<<key (w v) pressed?> or <key (up arrow v) pressed?>> or <<mouse down?> and <(y position) < (mouse y)>>> then\n        if <<(jump key) = [0]> and <(falling?) < [3]>> then\n            set [speed y v] to [14]\n            set [falling? v] to [6]\n            set [jump key v] to [1]\n        end\n    else\n        set [jump key v] to [0]\n    end\nend\n\ndefine Gravity\nif <<(speed y) < [4]> or <<<key (w v) pressed?> or <key (up arrow v) pressed?>> or <<mouse down?> and <(y position) < (mouse y)>>>> then\n    change [speed y v] by (-1)\nelse\n    change [speed y v] by (-2)\nend\nchange y by (speed y)\nchange [falling? v] by (1)\n\ndefine Check Hit Ceiling / Floor <up?>\nGet Touching \nif <(touch) = [0]> then\n    set [in platforrm v] to [1]\nelse\n    if <<up?> and <(touch) = [1]>> then\n        set [in platforrm v] to [2]\n    end\nend\nrepeat until <(touch) < (in platforrm)>\n    if <up?> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling? v] to [0]\n    end\n    Get Touching <not <up?>>\n    set [speed y v] to [0]\nend\n\ndefine Get Touching <check platform?>\nif <touching (level v)?> then\n    set [touch v] to [9]\nelse\n    if  then\n        set [touch v] to [1]\n    else\n        set [touch v] to [0]\n    end\nend\n\ndefine Reset Level\nset size to (25) %\nset rotation style [left-right v]\ngo to x: (146) y: (200)\nreset timer\nshow\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [falling? v] to [10]\nset [in platforrm v] to [1]\nset [frame v] to [0]\nset [wall jump v] to [0]\n\ndefine Set Costume\nif <(falling?) < [6]> then\n    if <(frame) = [0]> then\n        switch costume to (stand v)\n    else\n        switch costume to ([floor v] of ((4) + ((frame) mod (18))) )\n    end\nelse\n    if <(speed y) > [0]> then\n        switch costume to (jump v)\n    else\n        switch costume to (fall v)\n    end\nend\n\nwhen I receive [stop intro v]\nforever\n    if <key (q v) pressed?> then\n        if <(level) = [15]> then\n    end\nend\n\nwhen I receive [stop intro v]\nif <<(Title) > [0]> and <(Full) < [12]>> then\n    hide\n    stop [this script v]\nend\nReset Level\nforever\n    switch costume to (hitbox v)\n    Controls - Jump, Crouch\n    Gravity\n    Check Hit Ceiling / Floor <(speed y) > [0]>\n    if <(y position) < [-189]> then\n        Reset Level\n    end\n    if <(wall jump) > [0]> then\n        change [wall jump v] by (-1)\n    else\n        Controls - Left and Right\n    end\n    if <(speed x) < [-0.5]> then\n        Walk (-90) (speed x) max step (([ceiling v] of ([abs v] of ((speed x) * (1.3)) ) ) + (1))\n    else\n        if <(speed x) > [0.5]> then\n            Walk (90) (speed x) max step (([ceiling v] of ([abs v] of ((speed x) * (1.3)) ) ) + (1))\n        else\n            set [frame v] to [0]\n        end\n    end\n    if <touching (trampoline v)?> then\n        change [speed y v] by (15)\n    end\n    if <[238] < (x position)> then\n        if <(level) = [15]> then\n    end\n    if <<<(y position) < [-180]> or <touching (danger v)?>> or <touching (enemies v)?>> then\n        if <(level) = [12]> then\n            go to x: (-224) y: (-135)\n        else\n            go to x: (-216) y: (116)\n        end\n        broadcast (die v)\n    end\n    Set Costume\n    broadcast (tick v) and wait\nend\n\nwhen I receive [stop intro v]\nforever\n    play sound [y2mate v] until done\nend\n\nwhen I receive [stop intro v]\nset [level v] to [1]\ngo to x: (-216) y: (116)\nforever\n    create clone of (_myself_ v)\nend\n\nwhen I receive [yay! you won v]\nhide\n\n@danger\n\nif  then\n\nwhen flag clicked\nswitch costume to (costume1 v)\ngo to [back v] layer\ngo [forward v] (2) layers\nforever\n    if <(costume [number v]) = [5]> then\n        turn right (5) degrees\n    else\n        point in direction (90)\n    end\nend\n\nwhen I receive [next level v]\nnext costume\n\n@decoration\n\nwhen flag clicked\nswitch costume to (costume1 v)\ngo to [back v] layer\n\nwhen I receive [next level v]\nnext costume\n\n@Enemies\n\nwhen I receive [restart v]\ndelete this clone\n\ndefine Clone (type) (x) (y)\ngo to x: (x) y: (y)\nset [clone# v] to (costume [number v])\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nclear graphic effects\nset size to (70) %\nshow\nset [enemyx v] to [0]\nset [enemyy v] to [0]\ngo to [front v] layer\nforever\n    if <<<(level) = [3]> or <(level) = [10]>> or <(level) = [14]>> then\n        show\n        change [enemyy v] by (-1)\n        if <([x position v] of [red 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 [red 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 (level v)?> then\n            change y by (1)\n        end\n        if <touching (level v)?> then\n            change y by (1)\n        end\n        if <touching (level v)?> then\n            change y by (1)\n        end\n        if <touching (level v)?> then\n            change y by (1)\n        end\n        if <touching (level v)?> then\n            change y by (-4)\n            change x by ((Enemyx) * (-1))\n            if <(y position) < ([x position v] of [red 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 (level 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)) < ([x position v] of [red v])> and <touching (level v)?>> then\n            set [enemyy v] to [14]\n        end\n        change y by (1)\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nset [amount v] to [1]\nset [speed v] to [1]\nhide\nif  then\n    delete this clone\nend\nrepeat (Amount)\n    Clone [1] [194] [-20]\n    wait (1) seconds\nend\n\ndelete this clone\n\nwhen I receive [die v]\nif <(level) = [3]> then\n    go to x: (178) y: (-84)\nelse\n    if <(level) = [10]> then\n        go to x: (178) y: (-20)\n    else\n        if <(level) = [14]> then\n            go to x: (178) y: (-20)\n        end\n    end\nend\n\nwhen I start as a clone\nforever\n    if <(level) = [3]> then\n        switch costume to (costume1 v)\n    else\n        if <(level) = [10]> then\n            switch costume to (costume2 v)\n        else\n            if <(level) = [14]> then\n                switch costume to (costume3 v)\n            end\n        end\n    end\nend\n\n@water\n\ngo [forward v] (1) layers\n\nwhen flag clicked\nforever\n    next costume\n    wait (0.01) seconds\nend\n\nwhen flag clicked\nset [ghost v] effect to (20)\nswitch costume to (costume1 v)\ngo to [front v] layer\nforever\n    if <<(username) = [ProgrammeKing]> and <key (space v) pressed?>> then\n        broadcast (NEXT LEVEL v)\n        wait (0.1) seconds\n        change [level v] by (1)\n    end\n    if <(level) = [6]> then\n        show\n    else\n        hide\n    end\nend\n\n@thumb\n\nwhen I receive [no 3 coins v]\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nswitch costume to (costume3 v)\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\nwhen I receive [yay! you won v]\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nswitch costume to (costume4 v)\n\nwhen I receive [stop intro v]\nset [ghost v] effect to (100)\nshow\n\nwhen flag clicked\nswitch costume to (costume5 v)\nset [ghost v] effect to (100)\nhide\n\nset [ghost v] effect to (0)\n\n@Chest\n\ndefine OPEN THE CHEST\nswitch costume to (costume1 v)\nwait (0.01) seconds\nswitch costume to (costume2 v)\nwait (0.01) seconds\nswitch costume to (costume3 v)\nwait (0.01) seconds\nswitch costume to (costume4 v)\nwait (0.01) seconds\nswitch costume to (costume5 v)\n\nwhen flag clicked\nhide\nswitch costume to (costume v)\ngo to [back v] layer\ngo to x: (165) y: (-83)\nforever\n    if <(level) = [15]> then\n        show\n    else\n        hide\n    end\n    if <touching (red v)?> then\n        if <(coin) = [3]> then\n            OPEN THE CHEST\n            broadcast (Yay! You won v) and wait\n        else\n            broadcast (No 3 coins v) and wait\n        end\n    end\nend\n\nbroadcast (Yay! You won v)\n\nwhen I receive [stop intro v]\nhide\n\n@Trampoline\n\nwhen flag clicked\nswitch costume to (costume1 v)\ngo to x: (-7) y: (-95)\nforever\n    if <(level) = [13]> then\n        show\n    else\n        hide\n    end\n    if <touching (red v)?> then\n        switch costume to (costume2 v)\n        wait (1) seconds\n        switch costume to (costume1 v)\n    end\nend\n\n@intro\n\nwhen flag clicked\nshow\nset [ghost v] effect to (0)\nset [brightness v] effect to (0)\nswitch costume to (intro v)\nrepeat (39)\n    next costume\n    wait (0.02) seconds\nend\nrepeat (10)\n    change [brightness v] effect by (-10)\nend\nrepeat (20)\n    change [brightness v] effect by (10)\nend\nbroadcast (stop intro v)\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\n