Time - A Scrolling Platformer(Mobile)

Instructions: -------------------Welcome to Time v1.0!-------------------\nmy April project\n\nPlease read all of the instructions\n\nPC: Arrow keys or WASD keys to move. You are timed so get to the end first for the highscore! \nMOBILE: Tap and hold on the screen for the joystick to appear. Drag in the direction you want to go. You are timed so get to the end first for the highscore!\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is possible\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \nPlease propose to be featured here: https://scratch.mit.edu/studios/4228481/comments/ all you have to do is copy the link to this game and paste it in the comment section for this studio, and make my day!\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you guys get this top loved, I will try to make a youtube video on how to make this!\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \nIf you have any questions, ask in the comments\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nYes, I know. There are a lot of bugs. I wanted to share this project on April 1, so I am still working on fixing the bugs.\n\nBug log:\n1. You die twice sometimes.\n2. You glitch when you touch something while on the moving platform\n3. When you hold the a key while respawning in the secret passage, you go through it.\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@Stage\n\nwhen I receive [game win!!!!! v]\nif <<(playing time) < (personal highscore)> or <(personal highscore) = [0]>> then\n    set [personal highscore v] to (playing time)\nend\n\nif <(playing time) < (☁ score)> then\n    set [☁ score v] to (playing time)\nend\n\nwhen flag clicked\nforever\n    play sound [recording25 v] until done\n    play sound [recording26 v] until done\nend\n\n@blank\n\n@Player\n\nwhen flag clicked\nbroadcast (Green Flag v) and wait\nbroadcast (Play Game v) and wait\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\nswitch costume to (costume10 v)\n\nwhen I receive [play game v]\nreset timer\nset [playing time 2 v] to [0]\nset [level v] to [1]\nforever\n    point in direction (90)\n    set size to (150) %\n    switch costume to (costume10 v)\n    broadcast (reset v) and wait\n    broadcast (setup v) and wait\n    game on\n    set [exit v] to []\n    repeat until <(EXIT) > []>\n        tick\n        broadcast (tick v) and wait\n        broadcast (frame v)\n        set [playing time v] to (join (letter (1) of ((timer) - (playing time 2))) (join (letter (2) of ((timer) - (playing time 2))) (join (letter (3) of ((timer) - (playing time 2))) (letter (4) of ((timer) - (playing time 2))))))\n        if <(letter (4) of ((timer) - (playing time 2))) = [.]> then\n            set [playing time v] to (join (playing time) (letter (5) of ((timer) - (playing time 2))))\n        end\n    end\n    if <(EXIT) = [Win]> then\n        Game - Win\n        stop [all v]\n    else\n        if <not <<(mobile button) = [reset]> or <key (r v) pressed?>>> then\n            game die\n        end\n    end\n    set [playing time 2 v] to ((timer) - (playing time))\nend\n\ndefine game on\nset [scrollx v] to (item (1) of [death pos v])\nset [scrolly v] to (item (2) of [death pos v])\nset [x v] to (item (1) of [death pos v])\nset [y v] to (item (2) of [death pos v])\nset [sx v] to [0]\nset [sy v] to [0]\nset [exit v] to []\nset [move v] to [no]\nset [moving platform: y v] to [-45]\nset size to (150) %\nset [ghost v] effect to (0)\nshow\nswitch costume to (LEVEL)\n\ndefine tick\nif <<key (left arrow v) pressed?> or <<key (a v) pressed?> or <<mouse down?> and <([x position v] of [joystick: background v]) > (mouse x)>>>> then\n    change [sx v] by (-3)\n    switch costume to (costume2 v)\nend\nif <<key (right arrow v) pressed?> or <<key (d v) pressed?> or <<mouse down?> and <(mouse x) > ([x position v] of [joystick: background v])>>>> then\n    change [sx v] by (3)\n    switch costume to (costume10 v)\nend\nset [sx v] to ((sx) * (0.8))\nif <([abs v] of (sx) ) > [0.9]> then\n    change player x by (round (sx))\nend\nif <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<mouse down?> and <(mouse y) > (([y position v] of [joystick: background v]) + (15))>>>> then\n    if <(in air) < [4]> then\n        set [sy v] to [16]\n    end\nend\nif <(sy) > [-20]> then\n    change [sy v] by (-2)\nend\nchange player y by (sy)\ntest - die/bounce\nset [scrollx v] to (x)\nif <(SCROLLX) < [0]> then\n    set [scrollx v] to [0]\nend\nchange [scrolly v] by (round (((y) - (SCROLLY)) / (8)))\nif <(SCROLLY) < [0]> then\n    set [scrolly v] to [0]\nend\nposition\nif <(y) < [-180]> then\n    set [exit v] to [die]\nend\n\ndefine change player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nposition\nrepeat until <<not <touching (platform v)?>> and <not <touching (moving platform v)?>>>\n    if <(sy) > [0]> then\n        change [y v] by (-1)\n    else\n        change [y v] by (1)\n        set [in air v] to [0]\n    end\n    position\n    set [sy v] to [0]\nend\n\ndefine position\ngo to x: ((x) - (SCROLLX)) y: ((y) - (SCROLLY))\n\ndefine change player x by (sx)\nchange [x v] by (sx)\nposition\nif <<touching (platform v)?> or <touching (moving platform v)?>> then\n    repeat (8)\n        change [y v] by (1)\n        position\n        if <<not <touching (platform v)?>> and <not <touching (moving platform v)?>>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-8)\n    if <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<mouse down?> and <(mouse y) > (([y position v] of [joystick: background v]) + (15))>>>> then\n        if <(sx) > [50]> then\n            set [sx v] to [-10]\n        else\n            set [sx v] to [10]\n        end\n        set [in air v] to [0]\n    else\n        set [sx v] to [0]\n    end\n    repeat until <<not <touching (platform v)?>> and <not <touching (moving platform v)?>>>\n        if <(sx) > [0]> then\n            change [x v] by (-1)\n        else\n            change [x v] by (1)\n        end\n        position\n    end\nend\n\ndefine game die\nset rotation style [all around v]\nset [exit v] to []\nset [death y v] to [10]\nrepeat (30)\n    turn right (5) degrees\n    change size by (-2)\n    change y by (death y)\n    change [death y v] by (-1)\nend\n\ndefine test - die/bounce\nif <<touching (bad v)?> or <<touching (spinning death v)?> or <<touching (spinning death2 v)?> or <touching (stomping death v)?>>>> then\n    set [exit v] to [die]\n    if <touching (bad v)?> then\n        start sound [recording1 v]\n    end\n    if <<touching (spinning death2 v)?> or <touching (spinning death v)?>> then\n        start sound [recording2 v]\n    end\n    if <touching (stomping death v)?> then\n        start sound [recording3 v]\n    end\nend\nif <touching (bouncy v)?> then\n    set [sy v] to [30]\nend\n\ndefine Game - Win\nset rotation style [don't rotate v]\nrepeat (50)\n    point towards (exit v)\n    turn right (65) degrees\n    move ((distance to [exit v]) / (2)) steps\n    change size by (-1)\n    change [ghost v] effect by (2)\nend\nhide\nchange [level v] by (1)\nwait (1) seconds\nbroadcast (game win!!!!! v) and wait\n\nwhen I receive [frame v]\nchange [frame v] by (1)\n\nwhen flag clicked\nforever\n    set [frame v] to [0]\n    wait (1) seconds\n    set [fps v] to (frame)\nend\n\nwhen flag clicked\ndelete all of [death pos v]\nadd [0] to [death pos v]\nadd [0] to [death pos v]\nforever\n    hide variable [fps v]\n    if <key (f v) pressed?> then\n        show variable [fps v]\n        wait until <not <key (f v) pressed?>>\n        wait until <key (f v) pressed?>\n        wait until <not <key (f v) pressed?>>\n    end\nend\n\nwhen I receive [stop everything!!!!! v]\nstop [other scripts in sprite v]\n\nset [playing time v] to [0]\n\n@platform\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLLX)) ((y) - (SCROLLY))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (level 1 - 1 v)\nclone at x: [400] y: [0]\nclone at x: [460] y: [0]\nclone at x: [400] y: [0]\nclone at x: [460] y: [0]\nclone at x: [460] y: [0]\nclone at the pos of x: [2521] y: [538]\nclone at x: [550] y: [-50]\nclone at x: [420] y: [-95]\nclone at x: [310] y: [0]\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\ndefine clone at the pos of x: (x) y: (y)\ncreate clone of (_myself_ v)\nset [x v] to (x)\nset [y v] to (y)\nnext costume\n\nwhen I receive [stop everything!!!!! v]\nstop [other scripts in sprite v]\n\n@Exit\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLLX)) ((y) - (SCROLLY))\nif <<(costume [number v]) = [2]> and <touching (player v)?>> then\n    set [exit v] to [Win]\nend\n\nwhen I receive [setup v]\nhide\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (open v)\nset [x v] to [3829]\nset [y v] to [475]\n\nif <(LEVEL) = [1]> then\n    clone at x: [3829] y: [475]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (closed v)\n        clone at x: [780] y: [462]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (closed v)\n            clone at x: [752] y: [24]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (closed v)\n                clone at x: [933] y: [166]\n            else\n                if <(LEVEL) = [5]> then\n                    switch costume to (closed v)\n                    clone at x: [531] y: [279]\n                else\n                    if <(LEVEL) = [6]> then\n                        switch costume to (closed v)\n                        clone at x: [1705] y: [50]\n                    else\n                        if <(LEVEL) = [7]> then\n                            switch costume to (closed v)\n                            clone at x: [1388] y: [-17]\n                        else\n                            if <(LEVEL) = [8]> then\n                                switch costume to (closed v)\n                                clone at x: [400] y: [415]\n                            else\n                                if <(LEVEL) = [9]> then\n                                    switch costume to (closed v)\n                                    clone at x: [124] y: [522]\n                                else\n                                    if <(LEVEL) = [10]> then\n                                        switch costume to (closed v)\n                                        clone at x: [-183] y: [-38]\n                                    else\n                                        set [x v] to [99999999999]\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine clone at x: (x) y: (y)\n\nwhen I receive [open portal v]\nswitch costume to (open v)\n\nwhen I receive [stop everything!!!!! v]\nstop [other scripts in sprite v]\n\n@bad\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLLX)) ((y) - (SCROLLY))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (level 1 - 1 v)\nclone at x: [400] y: [0]\nclone at x: [460] y: [0]\nclone at x: [500] y: [0]\nclone at x: [600] y: [0]\nclone at x: [220] y: [0]\nclone at the pos of x: [2478] y: [514]\nclone at x: [550] y: [-50]\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\ndefine clone at the pos of x: (x) y: (y)\ncreate clone of (_myself_ v)\nset [x v] to (x)\nset [y v] to (y)\nnext costume\n\nwhen I receive [stop everything!!!!! v]\nstop [other scripts in sprite v]\n\n@secret passage\n\nwhen I receive [tick v]\ngo to x: ((2187) - (SCROLLX)) y: ((-1) * (SCROLLY))\nif <touching (player v)?> then\n    switch costume to (costume2 v)\nelse\n    switch costume to (costume1 v)\nend\nif <<((2187) - (SCROLLX)) = (x position)> and <((-1) * (SCROLLY)) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [stop everything!!!!! v]\nstop [other scripts in sprite v]\n\n@moving platform\n\nwhen I receive [tick v]\ngo to x: ((2370) - (SCROLLX)) y: ((moving platform: y) - (SCROLLY))\nif <<((2370) - (SCROLLX)) = (x position)> and <((moving platform: y) - (SCROLLY)) = (y position)>> then\n    show\nelse\n    hide\nend\nchange y by (10)\nif <touching (player v)?> then\n    set [move v] to [yes]\nend\nchange y by (-10)\nif <(move) = [yes]> then\n    if <not <(moving platform: y) = [639]>> then\n        change [moving platform: y v] by (2)\n    end\nend\n\nwhen flag clicked\nset [move v] to [no]\nset [moving platform: y v] to [-45]\n\nwhen I receive [stop everything!!!!! v]\nstop [other scripts in sprite v]\n\n@spinning death\n\nwhen I receive [tick v]\nturn right (-15) degrees\ngo to x: ((2440) - (SCROLLX)) y: ((160) - (SCROLLY))\nif <<(x position) = ((2440) - (SCROLLX))> and <(y position) = ((160) - (SCROLLY))>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [stop everything!!!!! v]\nstop [other scripts in sprite v]\n\n@spinning death2\n\nwhen I receive [tick v]\nturn right (-15) degrees\ngo to x: ((2555) - (SCROLLX)) y: ((300) - (SCROLLY))\nif <<(x position) = ((2555) - (SCROLLX))> and <(y position) = ((300) - (SCROLLY))>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [stop everything!!!!! v]\nstop [other scripts in sprite v]\n\n@checkpoint\n\nwhen I receive [tick v]\nif <(do it?) = [yes]> then\n    go to x: ((2750) - (SCROLLX)) y: ((560) - (SCROLLY))\n    if <<(x position) = ((2750) - (SCROLLX))> and <(y position) = ((560) - (SCROLLY))>> then\n        show\n    else\n        hide\n    end\n    if <touching (player v)?> then\n        start sound [Coin v]\n        set [do it? v] to [no]\n        set [y v] to [5]\n        set [num v] to [1]\n    end\nelse\n    if <(num) < [25]> then\n        set x to ((2750) - (SCROLLX))\n        change y by (y)\n        change [y v] by (-1)\n        change [num v] by (1)\n    else\n        hide\n    end\nend\n\nwhen I receive [stop everything!!!!! v]\nstop [other scripts in sprite v]\n\nwhen I receive [green flag v]\nbroadcast (go v)\n\nwhen I receive [go v]\nset [do it? v] to [yes]\nwait until <(do it?) = [no]>\ndelete all of [death pos v]\nadd [2750] to [death pos v]\nadd [560] to [death pos v]\n\n@checkpoint2\n\nwhen I receive [tick v]\nif <(do it?2) = [yes]> then\n    go to x: ((2180) - (SCROLLX)) y: ((-15) - (SCROLLY))\n    if <<(x position) = ((2180) - (SCROLLX))> and <(y position) = ((-15) - (SCROLLY))>> then\n        if <not <touching color (#e5a900)?>> then\n            show\n        else\n            hide\n        end\n    else\n        hide\n    end\n    if <touching (player v)?> then\n        start sound [Coin v]\n        set [do it?2 v] to [no]\n        set [y v] to [5]\n        set [num v] to [1]\n    end\nelse\n    if <(num) < [25]> then\n        set x to ((2180) - (SCROLLX))\n        change y by (y)\n        change [y v] by (-1)\n        change [num v] by (1)\n    else\n        hide\n    end\nend\n\nwhen I receive [stop everything!!!!! v]\nstop [other scripts in sprite v]\n\nwhen I receive [go v]\nset [do it?2 v] to [yes]\nwait until <(do it?2) = [no]>\ndelete all of [death pos v]\nadd [2180] to [death pos v]\nadd [-40] to [death pos v]\n\n@stomping death\n\nwhen I receive [tick v]\nchange [y v] by (2)\ngo to x: ((x) - (SCROLLX)) y: ((y) - (SCROLLY))\nif <<(x position) = ((x) - (SCROLLX))> and <(y position) = ((y) - (SCROLLY))>> then\n    show\nelse\n    hide\nend\nif <(y) = [530]> then\n    set [y v] to [450]\nend\n\nwhen flag clicked\nset [y v] to [450]\nset [x v] to [3420]\ncreate clone of (_myself_ v)\nset [x v] to [3600]\n\nwhen I receive [stop everything!!!!! v]\nstop [other scripts in sprite v]\n\n@joystick: background\n\nwhen I receive [tick v]\nset [ghost v] effect to (50)\nhide\nif <mouse down?> then\n    if <(mouse down last) = [no]> then\n        go to (mouse-pointer v)\n    end\n    set [mouse down last v] to [yes]\n    switch costume to (costume1 v)\n    show\n    set [joystick x v] to (x position)\n    set [joystick y v] to (y position)\nelse\n    set [mouse down last v] to [no]\nend\n\nwhen I receive [tick v]\n\ndelete this clone\n\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\n\nshow\n\ngo to (mouse-pointer v)\nswitch costume to (costume2 v)\n\n@joystick: stick\n\nwhen I receive [tick v]\nswitch costume to (costume2 v)\nhide\nif <mouse down?> then\n    go to (joystick: background v)\n    show\n    block name\nend\n\ndefine block name\nif <(mouse x) > (x position)> then\n    set [time v] to [0]\n    repeat until <<(x position) = (mouse x)> or <(time) = [20]>>\n        change x by (1)\n        change [time v] by (1)\n    end\nelse\n    if <(x position) > (mouse x)> then\n        set [time v] to [0]\n        repeat until <<(x position) = (mouse x)> or <(time) = [20]>>\n            change x by (-1)\n            change [time v] by (1)\n        end\n    end\nend\nif <(mouse y) > (y position)> then\n    set [time v] to [0]\n    repeat until <<(y position) = (mouse y)> or <(time) = [20]>>\n        change y by (1)\n        change [time v] by (1)\n    end\nelse\n    if <(y position) > (mouse y)> then\n        set [time v] to [0]\n        repeat until <<(y position) = (mouse y)> or <(time) = [20]>>\n            change y by (-1)\n            change [time v] by (1)\n        end\n    end\nend\n\n@background win\n\nwhen I receive [game win!!!!! v]\nset [ghost v] effect to (100)\nshow\nrepeat (50)\n    change [ghost v] effect by (-2)\nend\n\nwhen I receive [green flag v]\nhide\n\n@thumnail\n\nwhen flag clicked\nhide\n\n@replay\n\nwhen flag clicked\nhide\n\nwhen I receive [game win!!!!! v]\nbroadcast (stop everything!!!!! v)\nshow\nforever\n    if <touching (mouse-pointer v)?> then\n        set size to (110) %\n        if <mouse down?> then\n            delete all of [death pos v]\n            add [0] to [death pos v]\n            add [0] to [death pos v]\n            broadcast (Green Flag v)\n            broadcast (Play Game v)\n            hide\n            stop [this script v]\n        end\n    else\n        set size to (100) %\n    end\nend\n\n@username\n\ndefine write (val) to encoded\nset [letter # v] to [1]\nrepeat (length of (val))\n    set [encoded v] to (join (encoded) (item # of (letter (letter #) of (val)) in [digits v]))\n    change [letter # v] by (1)\nend\nset [encoded v] to (join (encoded) [00])\n\ndefine begin decode of (encoded)\nset [encoded v] to (encoded)\nset [letter # v] to [1]\n\ndefine value = read from encoded\nset [value v] to []\nforever\n    set [idx v] to (join (letter (letter #) of (encoded)) (letter ((letter #) + (1)) of (encoded)))\n    change [letter # v] by (2)\n    if <(idx) < [1]> then\n        stop [this script v]\n    end\n    set [value v] to (join (value) (item (idx) of [digits v]))\nend\n\nwhen I receive [game win!!!!! v]\nif <(playing time) < (☁ score)> then\n    set [☁ score v] to (playing time)\n    set [encoded v] to []\n    write (username) to encoded\n    set [☁ username v] to (encoded)\n    begin decode of (encoded)\n    value = read from encoded\n    set [highscore v] to (join (☁ score) (join [ - ] (value)))\nend\n\nwhen flag clicked\nset [encoded v] to (☁ username)\nbegin decode of (encoded)\nvalue = read from encoded\nset [highscore v] to (join (☁ score) (join [ - ] (value)))\n\n