A Mobile Platformer.

Instructions: Use the arrow keys to move in "PC Mode" or tap the joystick to move in "Mobile Mode" Reach the right side of the screen to advance.\nSequel: https://scratch.mit.edu/projects/319526501/\n3rd: https://scratch.mit.edu/projects/319810395/

@Stage\n\nwhen flag clicked\n\nbroadcast (turn page v)\n\nwhen flag clicked\nforever\n    if <(Level) = [13]> then\n        switch backdrop to (backdrop2 v)\n    else\n        if <(Level) > [13]> then\n            switch backdrop to (backdrop3 v)\n        else\n            switch backdrop to (backdrop1 v)\n        end\n    end\nend\n\nwhen I receive [turn page v]\nforever\n    play sound [Bob-omb Battlefi v] until done\nend\n\nswitch backdrop to (backdrop1 v)\n\n@Improved2\n\nwhen I receive [turn page v]\nif <(Title) > [0]> 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) < [-180]> 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    Set Costume\n    broadcast (tick v)\nend\n\nbroadcast (tick v) and wait\n\ndefine Controls - Left and Right\nset [speed x v] to ((speed x) * (0.7))\nif <<key (left arrow v) pressed?> or <(left key pressed) = [1]>> then\n    change [speed x v] by (-1.5)\nend\nif <<key (right arrow v) pressed?> or <(right key pressed) = [1]>> then\n    change [speed x v] by (1.5)\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 (up arrow v) pressed?> or <(up key pressed) = [1]>> 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 <<key (up arrow v) pressed?> or <<(up key pressed) = [1]> or <touching (bounce v)?>>> 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\nelse\n    set [jump key v] to [0]\nend\nif <<key (down arrow v) pressed?> or <(down key pressed) = [1]>> then\n    set [in platforrm v] to [2]\nend\n\ndefine Gravity\nif <<(speed y) < [4]> or <<key (up arrow v) pressed?> or <(up key pressed) = [1]>>> 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 (ground v)?> then\n    set [touch v] to [9]\nelse\n    if <<check platform?> and <touching (platforms v)?>> then\n        set [touch v] to [1]\n    else\n        set [touch v] to [0]\n    end\nend\nif <touching (hurt v)?> then\n    Reset Level\nend\nif <(x position) > [235]> then\n    change [level v] by (1)\n    Reset Level\nend\n\ndefine Reset Level\nset size to (25) %\nset rotation style [left-right v]\npoint in direction (90)\ngo to x: (146) y: (200)\ngo to x: (-202) y: (-100)\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]\nbroadcast (spawn enemies v)\n\ndefine Set Costume\nif <(falling?) < [6]> then\n    if <(frame) = [0]> then\n        switch costume to (costume13 v)\n    else\n        switch costume to ([floor v] of ((1) + ((frame) mod (12))) )\n    end\nelse\n    if <(speed y) > [0]> then\n        switch costume to (costume13 v)\n    else\n        switch costume to (costume13 v)\n    end\nend\n\nwhen flag clicked\nset [level v] to [1]\n\nset [jump key v] to [1]\n\nset [falling? v] to [6]\n\nwhen I receive [reset level v]\nReset Level\n\nwhen I receive [bounce v]\nset [speed y v] to [6]\nset [falling? v] to [6]\nset [jump key v] to [1]\n\n@Ground\n\nwhen flag clicked\ngo to x: (0) y: (0)\nforever\n    switch costume to (Level)\nend\n\n@hurt\n\nwhen flag clicked\ngo to x: (0) y: (0)\nforever\n    switch costume to (Level)\n    if <(Level) = [8]> then\n        turn right (1.5) degrees\n    else\n        if <(Level) = [9]> then\n            turn right (2.5) degrees\n        else\n            point in direction (90)\n        end\n    end\nend\n\npoint in direction (90)\n\n@Sprite1\n\nwhen flag clicked\nhide\n\nwhen I receive [turn page v]\ngo to x: (0) y: (0)\nshow\nset [ghost v] effect to (50)\ngo to [front v] layer\nif <(Mobile?) = [0]> then\n    hide\nend\n\n@Sprite2\n\nwhen flag clicked\nhide\nset [left key pressed v] to [0]\nset [right key pressed v] to [0]\nset [down key pressed v] to [0]\nset [down key pressed v] to [0]\n\nif <<(direction) > [44]> and <(direction) < [91]>> then\n\nwhen I receive [turn page v]\ngo to x: (0) y: (0)\nset [left key pressed v] to [0]\nset [right key pressed v] to [0]\nset [down key pressed v] to [0]\nset [down key pressed v] to [0]\nshow\nset [ghost v] effect to (50)\ngo to [front v] layer\nforever\n    go to x: (0) y: (0)\n    set [left key pressed v] to [0]\n    set [right key pressed v] to [0]\n    set [up key pressed v] to [0]\n    set [down key pressed v] to [0]\n    if <(Mobile?) = [0]> then\n        hide\n        stop [this script v]\n    end\n    if <mouse down?> then\n        go to x: (0) y: (0)\n        point towards (mouse-pointer v)\n        move (28) steps\n        if <<(direction) > [-60]> and <(direction) < [60]>> then\n            set [up key pressed v] to [1]\n        else\n            if <<(direction) < [-120]> or <(direction) > [120]>> then\n                set [down key pressed v] to [1]\n            end\n        end\n        if <<(direction) > [30]> and <(direction) < [150]>> then\n            set [right key pressed v] to [1]\n        else\n            if <<(direction) > [-150]> and <(direction) < [-30]>> then\n                set [left key pressed v] to [1]\n            end\n        end\n    end\nend\n\n@Platforms\n\nwhen flag clicked\ngo to x: (0) y: (0)\nforever\n    switch costume to (Level)\nend\n\n@Sprite3\n\nwhen flag clicked\nshow\npoint in direction (90)\nhide variable [level v]\nhide variable [mobile? v]\ngo to [front v] layer\nswitch costume to (costume1 v)\ngo to x: (0) y: (0)\nset [id v] to [0]\nrepeat (3)\n    change [id v] by (1)\n    create clone of (_myself_ v)\nend\nforever\n    set [id v] to [0]\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nif <(id) = [0]> then\n    go to [front v] layer\n    go [forward v] (1) layers\n    go to x: (pick random (-240) to (240)) y: (-480)\n    point in direction (90)\n    set rotation style [all around v]\n    switch costume to (costume4 v)\n    show\n    set [ghost v] effect to (50)\n    repeat (40)\n        turn right (3) degrees\n        change y by (10)\n    end\n    repeat until <touching (_edge_ v)?>\n        turn right (3) degrees\n        change y by (10)\n    end\n    change y by (10)\n    delete this clone\nelse\n    if <(id) = [1]> then\n        go to [front v] layer\n        go to x: (0) y: (0)\n        switch costume to (costume5 v)\n        show\n    else\n        if <(id) = [2]> then\n            go to [front v] layer\n            go to x: (-100) y: (0)\n            switch costume to (costume2 v)\n            show\n            forever\n                if <touching (mouse-pointer v)?> then\n                    set [brightness v] effect to (50)\n                    if <mouse down?> then\n                        set [mobile? v] to [1]\n                        start sound [Collect v]\n                        broadcast (turn page v)\n                    end\n                else\n                    clear graphic effects\n                end\n            end\n        else\n            if <(id) = [3]> then\n                go to [front v] layer\n                go to x: (100) y: (0)\n                switch costume to (costume3 v)\n                show\n                forever\n                    if <touching (mouse-pointer v)?> then\n                        set [brightness v] effect to (50)\n                        if <mouse down?> then\n                            set [mobile? v] to [0]\n                            start sound [Collect v]\n                            broadcast (turn page v)\n                        end\n                    else\n                        clear graphic effects\n                    end\n                end\n            end\n        end\n    end\nend\n\nchange y by (10)\n\nrepeat until <not <touching (_edge_ v)?>>\n\nrepeat (40)\n    change y by (10)\nend\nrepeat until <touching (_edge_ v)?>\n    change y by (10)\nend\nchange y by (10)\ndelete this clone\n\nset [ghost v] effect to (50)\n\nforever\n    go to [front v] layer\nend\n\nset [mobile? v] to [0]\n\nwhen I receive [turn page v]\nshow variable [level v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@Logo\n\nwhen flag clicked\ngo to x: (0) y: (0)\nforever\n    show\n    set [ghost v] effect to (100)\n    go to [front v] layer\nend\n\n@Sprite4\n\nwhen flag clicked\nhide\n\ndefine Create enemy (x) (y) (level)\nif <(Level) = (level)> then\n    go to x: (x) y: (y)\n    set [dizzy v] to [0]\n    set [level in v] to (Level)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nhide\nshow\nset [speed x v] to [0]\nset size to (30) %\nset rotation style [left-right v]\nset [level in v] to (Level)\nset [speed y v] to [0]\nset [start x v] to (x position)\nset [start y v] to (y position)\nforever\n    switch costume to (costume15 v)\n    Controls - Jump, Crouch\n    Gravity\n    Check Hit Ceiling / Floor <(speed y) > [0]>\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 (improved2 v)?> and <(([y position v] of [improved2 v]) - (15)) < (y position)>> then\n        broadcast (reset level v)\n    end\n    if <<touching (improved2 v)?> and <(([y position v] of [improved2 v]) - (15)) > (y position)>> then\n        broadcast (bounce v)\n        switch costume to (costume14 v)\n        switch costume to (costume2 v)\n        start sound [pop2 v]\n        wait (0.1) seconds\n        delete this clone\n    end\nend\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 Gravity\nif <(speed y) < [4]> 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 Controls - Jump, Crouch\n\ndefine Walk (direction) (speed) max step (step)\npoint in direction (direction)\nchange x by (speed)\nchange [frame v] by (([abs v] of (speed) ) / (4))\nset [slope2 v] to [0]\nGet Touching <(in platforrm) = [1]>\nrepeat until <<(slope2) = (step)> or <(touch) = [0]>>\n    change y by (1)\n    change [slope2 v] by (1)\n    Get Touching <(in platforrm) = [1]>\nend\nif <(slope2) = (step)> then\n    change x by ((0) - (speed))\n    change y by ((0) - (slope2))\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    end\nend\n\nwhen I start as a clone\nforever\n    if <([x position v] of [improved2 v]) < (x position)> then\n        change [speed x v] by (-0.5)\n    end\n    if <([x position v] of [improved2 v]) > (x position)> then\n        change [speed x v] by (0.5)\n    end\n    if <(speed x) > [1.5]> then\n        set [speed x v] to [1.5]\n    end\n    if <(speed x) < [-1.5]> then\n        set [speed x v] to [-1.5]\n    end\nend\n\n\n\nset [speed x v] to [0]\n\nrepeat (10)\n\nwhen I receive [tick v]\n\ndefine Set Costume\nif <(falling?) < [6]> then\n    if <(frame) = [0]> then\n        switch costume to (costume3 v)\n    else\n        switch costume to ([floor v] of ((1) + ((frame) mod (13))) )\n    end\nelse\n    if <(speed y) > [0]> then\n        switch costume to (costume3 v)\n    else\n        switch costume to (costume3 v)\n    end\nend\n\nwhen I start as a clone\nforever\n    if <not <(Level) = (level in)>> then\n        delete this clone\n    end\nend\n\nswitch costume to (costume16 v)\n\n\n\nset [ghost v] effect to (100)\n\nhide\ndelete this clone\n\n\n\nstop [other scripts in sprite v]\n\nhide\n\nif <(level) > (Level)> then\n\nwhen I receive [spawn enemies v]\ndelete this clone\n\nswitch costume to (costume15 v)\n\nrepeat (10)\n\nif <<([abs v] of (speed x) ) > [4]> and <(falling?) = [0]>> then\n    set [speed y v] to [25]\n    set [falling? v] to [6]\n    set [jump key v] to [1]\nend\n\nif <(Level) = [4]> then\n    Create enemy (0) (0) (4)\nend\n\n\n\nwhen I receive [spawn enemies v]\ngo to x: (0) y: (0)\nhide\nwait (0.1) seconds\nif <(Level) = [16]> then\n    Create enemy (0) (-120) (16)\nend\nif <(Level) = [17]> then\n    Create enemy (0) (-120) (17)\n    Create enemy (0) (-120) (17)\n    Create enemy (100) (-120) (17)\n    Create enemy (150) (-120) (17)\nend\nif <(Level) = [18]> then\n    Create enemy (150) (-120) (18)\n    Create enemy (150) (-120) (18)\n    Create enemy (150) (-120) (18)\n    Create enemy (0) (-120) (18)\nend\nif <(Level) = [19]> then\n    Create enemy (-190) (100) (19)\n    Create enemy (0) (100) (19)\n    Create enemy (190) (100) (19)\n    Create enemy (0) (-100) (19)\n    Create enemy (0) (-100) (19)\n    Create enemy (0) (-100) (19)\nend\nif <(Level) = [20]> then\n    Create enemy (-35) (-150) (20)\n    Create enemy (-35) (-150) (20)\n    Create enemy (-35) (-150) (20)\n    Create enemy (-35) (-150) (20)\n    Create enemy (-35) (-150) (20)\n    Create enemy (-35) (-150) (20)\n    Create enemy (-150) (-50) (20)\nend\n\ndefine Get Touching <check platform?>\nif <<touching (ground v)?> or <<touching (sprite4 v)?> or <touching (sprite10 v)?>>> then\n    set [touch v] to [9]\nelse\n    if <<check platform?> and <touching (platforms v)?>> then\n        set [touch v] to [1]\n    else\n        set [touch v] to [0]\n    end\nend\n\nCreate enemy (196) (124) (19)\n\nwhen I receive [reset level v]\ndelete this clone\n\nSet Costume\n\nCreate enemy (0) (100) (19)\nCreate enemy (190) (100) (19)\nCreate enemy (0) (-100) (19)\nCreate enemy (0) (-100) (19)\nCreate enemy (0) (-100) (19)\n\n\n\n