Inverses: A multitask platformer

Instructions: Welcome to Inverses! Inverses is a platformer where you have to control 2 characters to unlock the portal and advance to the next level. Collect both keys to unlock the portal and avoid the dangers along the way.\n\nGood luck!\n

@Stage\n\nwhen flag clicked\nswitch backdrop to (backdrop1 v)\nset [ghost v] effect to (100)\nrepeat (5)\n    change [ghost v] effect by (-20)\nend\nbroadcast (Start Game v)\n\nswitch backdrop to (intro v)\nset [gamemode v] to [Intro]\nwait until <(GameMode) = [Main Menu]>\n\nwhen I receive [reset v]\nset [ghost v] effect to (100)\nrepeat (5)\n    change [ghost v] effect by (-20)\nend\n\nwhen [r v] key pressed\nbroadcast (Reset v)\n\nwhen [p v] key pressed\nif <(Level) = [13]> then\n    if <(Username list showing?) = [no]> then\n        hide list [hall of fame v]\n        set [username list showing? v] to [yes]\n    else\n        show list [hall of fame v]\n        set [username list showing? v] to [no]\n    end\nend\n\nwhen flag clicked\nshow list [hall of fame v]\nset [username list showing? v] to [no]\n\n@Thumbnail\n\nhide\n\nwhen I receive [tick v]\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\nshow\ngo to [front v] layer\n\n@Black Character\n\nwhen flag clicked\nhide\ngo to [front v] layer\nswitch costume to (normal v)\nset size to (20) %\n\nwhen I receive [start game v]\nshow\nbroadcast (Reset v)\n\nwhen I receive [start game v]\nforever\n    if <(Hint State) = [0]> then\n        if <key (right arrow v) pressed?> then\n            point in direction (-90)\n            change [xv - black v] by (1)\n        end\n        if <key (left arrow v) pressed?> then\n            point in direction (90)\n            change [xv - black v] by (-1)\n        end\n        set [xv - black v] to ((Xv - black) * (0.9))\n        change x by (Xv - black)\n        if  then\n            change y by (1)\n            if  then\n                change y by (1)\n                if  then\n                    change y by (1)\n                    if  then\n                        change y by (1)\n                        if  then\n                            change y by (1)\n                            if  then\n                                change x by ((Xv - black) * (-1))\n                                set [yv - black v] to [0]\n                                change y by (-5)\n                                if <key (up arrow v) pressed?> then\n                                    if <(Xv - black) > [0]> then\n                                        set [xv - black v] to [-5]\n                                    else\n                                        set [xv - black v] to [5]\n                                    end\n                                    set [yv - black v] to [10]\n                                else\n                                    set [xv - black v] to [0]\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n        change [yv - black v] by (-1)\n        change y by (Yv - black)\n        if <<touching color (#b2b2b2)?> or <touching color (#000000)?>> then\n            change y by ((Yv - black) * (-1))\n            set [yv - black v] to [0]\n        end\n        change y by (-1)\n        if <<touching color (#b2b2b2)?> or <touching color (#000000)?>> then\n            if <key (up arrow v) pressed?> then\n                set [yv - black v] to [12]\n            end\n        end\n        change y by (1)\n        if <touching color (#ff0000)?> then\n            broadcast (Reset v)\n        end\n    end\n    if <touching color (#c841ff)?> then\n        set [yv - black v] to [-20]\n    end\n    if <touching color (#ffec24)?> then\n        set [yv - black v] to [20]\n    end\nend\n\nwhen I receive [start game v]\nset [level v] to [1]\n\nwhen [space v] key pressed\n\nbroadcast (Start Game v)\n\nwhen I receive [reset v]\ngo to x: (-137) y: (-130)\nset rotation style [left-right v]\npoint in direction (-90)\nset [yv - black v] to [0]\nset [xv - black v] to [0]\n\n@White Character\n\nwhen flag clicked\nhide\nset size to (20) %\n\nwhen I receive [start game v]\nforever\n    if <(Hint State) = [0]> then\n        if <key (d v) pressed?> then\n            point in direction (-90)\n            change [xv - white v] by (1)\n        end\n        if <key (a v) pressed?> then\n            point in direction (90)\n            change [xv - white v] by (-1)\n        end\n        set [xv - white v] to ((Xv - white) * (0.9))\n        change x by (Xv - white)\n        if <<touching color (#b2b2b2)?> or <touching color (#ffffff)?>> then\n            change y by (1)\n            if <<touching color (#b2b2b2)?> or <touching color (#ffffff)?>> then\n                change y by (1)\n                if <<touching color (#b2b2b2)?> or <touching color (#ffffff)?>> then\n                    change y by (1)\n                    if <<touching color (#b2b2b2)?> or <touching color (#ffffff)?>> then\n                        change y by (1)\n                        if <<touching color (#b2b2b2)?> or <touching color (#ffffff)?>> then\n                            change y by (1)\n                            if <<touching color (#b2b2b2)?> or <touching color (#ffffff)?>> then\n                                change x by ((Xv - white) * (-1))\n                                set [yv - white v] to [0]\n                                change y by (-5)\n                                if <key (w v) pressed?> then\n                                    if <(Xv - white) > [0]> then\n                                        set [xv - white v] to [-5]\n                                    else\n                                        set [xv - white v] to [5]\n                                    end\n                                    set [yv - white v] to [10]\n                                else\n                                    set [xv - white v] to [0]\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n        change [yv - white v] by (-1)\n        change y by (Yv - white)\n        if <<touching color (#b2b2b2)?> or <touching color (#ffffff)?>> then\n            change y by ((Yv - white) * (-1))\n            set [yv - white v] to [0]\n        end\n        change y by (-1)\n        if <<touching color (#b2b2b2)?> or <touching color (#ffffff)?>> then\n            if <key (w v) pressed?> then\n                set [yv - white v] to [12]\n            end\n        end\n        change y by (1)\n        if <touching color (#ff0000)?> then\n            broadcast (Reset v)\n        end\n        if <touching color (#c841ff)?> then\n            set [yv - white v] to [-20]\n        end\n        if <touching color (#ffec24)?> then\n            set [yv - white v] to [20]\n        end\n    end\nend\n\nwhen I receive [start game v]\ngo to [front v] layer\nshow\n\nwhen I receive [reset v]\ngo to x: (-180) y: (-130)\nset rotation style [left-right v]\npoint in direction (-90)\nset [xv - white v] to [0]\nset [yv - white v] to [0]\n\n@Ground\n\nturn right (7) degrees\npoint in direction (90)\n\nchange size by (200)\n\nwhen I receive [next level v]\nif <(Level) = [6]> then\n    switch costume to (7 v)\nelse\n    if <(Level) = [8]> then\n        switch costume to (9 v)\n    else\n        if <(Level) = [12]> then\n            switch costume to (end v)\n        else\n            if <(Level) = [13]> then\n                switch costume to (end v)\n            else\n                next costume\n            end\n        end\n    end\nend\nchange [level v] by (1)\n\nset [switch state v] to [0]\nwait (0) seconds\n\nwhen I receive [start game v]\nswitch costume to (1 v)\nset [level v] to [1]\n\nwhen I receive [tick v]\nif <(Level) = [6]> then\n    if <(Switch State) = [1]> then\n        switch costume to (6a v)\n    else\n        switch costume to (6b v)\n    end\nend\nif <(Level) = [8]> then\n    if <(Switch State) = [1]> then\n        switch costume to (8a v)\n    else\n        switch costume to (8b v)\n    end\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset size to (100) %\n\n@FPS Counter\n\nwhen I receive [tick v]\nchange [frames v] by (1)\n\nwhen I receive [start game v]\nset [sine factor v] to [0]\nforever\n    broadcast (tick v)\nend\n\nwhen I receive [start game v]\nreset timer\nforever\n    set [frames v] to [0]\n    set [start time v] to (timer)\n    wait until <(timer) > ((start time) + (1))>\n    set [fps v] to (frames)\nend\n\nwhen flag clicked\nforever\n    change [sine factor v] by (3)\nend\n\nwhen flag clicked\nset [last lvl legit? v] to [True]\n\nwhen flag clicked\nwait (5) seconds\nwait until <(Level) = [13]>\nif <(Last Lvl Legit?) = [True]> then\n    broadcast (Beat Last Level Legit v)\nend\n\n@Keys\n\nset size to (200) %\ngo to [back v] layer\n\nwhen I receive [reset v]\nset [white key state v] to [1]\nset [black key state v] to [1]\nbroadcast (Spawn Keys v)\n\nwhen I receive [spawn keys v]\nswitch costume to (white key v)\ncreate clone of (_myself_ v)\nswitch costume to (black key v)\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\ngo to [front v] layer\nshow\nif <(costume [number v]) = [1]> then\n    set x to (item (Level) of [xloc white key v])\n    set y to (item (Level) of [yloc white key v])\n    wait until <touching (white character v)?>\n    hide\n    broadcast (Key Collected v)\n    set [white key state v] to [0]\n    delete this clone\nelse\n    set x to (item (Level) of [xloc black key v])\n    set y to (item (Level) of [yloc black key v])\n    wait until <touching (black character v)?>\n    hide\n    broadcast (Key Collected v)\n    set [black key state v] to [0]\n    delete this clone\nend\n\ndelete (11) of [yloc white key v]\ndelete (11) of [xloc white key v]\n\nadd [-5] to [xloc white key v]\nadd [75] to [yloc white key v]\n\nadd [80] to [xloc black key v]\nadd [80] to [yloc black key v]\n\nwhen I receive [reset v]\ndelete this clone\n\ndelete (10) of [yloc black key v]\ndelete (10) of [xloc black key v]\n\nwhen I start as a clone\nforever\n    if <(Level) = [13]> then\n        delete this clone\n    end\nend\n\n@Portal particles\n\nwhen flag clicked\nhide\n\nwhen I receive [start game v]\nforever\n    if <<(Black Key State) = [0]> and <(White Key State) = [0]>> then\n        create clone of (_myself_ v)\n    end\nend\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I start as a clone\nshow\ngo to [front v] layer\nclear graphic effects\ngo to (portal v)\npoint in direction (pick random (1) to (360))\nrepeat (20)\n    move (2) steps\n    turn right (5) degrees\n    change [ghost v] effect by (2)\nend\ndelete this clone\n\nadd [220] to [xloc portal v]\n\ndelete (12) of [xloc portal v]\n\n@WASD\n\nwhen I receive [start game v]\nshow\nset size to (70) %\ngo to [back v] layer\nrepeat until <not <(Level) = [1]>>\n    go to (white character v)\n    change y by ((35) + ((3) * ([sin v] of (Sine Factor) )))\nend\nhide\ngo to x: (1000) y: (1000)\n\nchange [sine factor v] by (1)\n\ndelete this clone\n\nwhen I start as a clone\n\nwhen I receive [tick v]\n\nwait (0) seconds\n\n@Arrows\n\nwhen I receive [tick v]\n\nwait (0) seconds\n\nwhen I receive [start game v]\nshow\nset size to (70) %\ngo to [back v] layer\nrepeat until <not <(Level) = [1]>>\n    go to (black character v)\n    change y by ((35) + ((3) * ([sin v] of (Sine Factor) )))\nend\nhide\ngo to x: (1000) y: (1000)\n\n@Portal\n\nwhen flag clicked\nset size to (12) %\ngo to x: (0) y: (0)\nforever\n    go to [back v] layer\n    set x to (item (Level) of [xloc portal v])\n    set y to ((-120) + ((-5) * ([sin v] of (Sine Factor) )))\n    set [brightness v] effect to (pick random (0) to (5))\n    wait (0.1) seconds\nend\n\nwhen I receive [tick v]\nif <(costume [number v]) = [1]> then\n    if <<touching (white character v)?> or <touching (black character v)?>> then\n        broadcast (Next Level v)\n        broadcast (Reset v) and wait\n    end\nend\n\nwhen I receive [tick v]\nif <<(Black Key State) = [0]> and <(White Key State) = [0]>> then\n    switch costume to (unlocked v)\nelse\n    if <<(Black Key State) = [0]> and <(White Key State) = [1]>> then\n        switch costume to (white locked v)\n    else\n        if <<(Black Key State) = [1]> and <(White Key State) = [0]>> then\n            switch costume to (black locked v)\n        else\n            if <<(Black Key State) = [1]> and <(White Key State) = [1]>> then\n                switch costume to (white locked + black locked v)\n            end\n        end\n    end\nend\n\nwhen [n v] key pressed\nif <(Level) = [12]> then\n    set [last lvl legit? v] to [False]\nend\nif <(Level) < [13]> then\n    broadcast (Next Level v)\n    broadcast (Reset v)\nend\n\nwhen I receive [tick v]\nif <(Level) = [13]> then\n    hide\nelse\n    show\nend\n\n@MUSIC\n\nwhen flag clicked\nset volume to (100) %\nforever\n    play sound [Vexento - Particles v] until done\nend\n\nwhen [m v] key pressed\nif <(volume) = [100]> then\n    set volume to (0) %\nelse\n    set volume to (100) %\nend\n\n@Switch\n\nwhen I receive [tick v]\nif <(Switch State) = [1]> then\n    switch costume to (left v)\nelse\n    switch costume to (right v)\nend\n\nwhen flag clicked\nset size to (20) %\nforever\n    if <<<touching (black character v)?> or <touching (white character v)?>> and <key (space v) pressed?>> then\n        if <(Switchable?) = [1]> then\n            if <(Switch State) = [1]> then\n                set [switch state v] to [0]\n            else\n                set [switch state v] to [1]\n            end\n            set [switchable? v] to [0]\n        end\n    else\n        set [switchable? v] to [1]\n    end\nend\n\nwhen I receive [reset v]\nset [switch state v] to [1]\n\nwhen I receive [tick v]\nif <(Level) = [6]> then\n    show\n    go to x: (-200) y: (0)\nelse\n    if <(Level) = [8]> then\n        show\n        go to x: (150) y: (-153)\n    else\n        \n    end\nend\n\nset size to (20) %\n\n@Hints\n\nwhen I receive [start game v]\ngo to x: (0) y: (0)\nset [hint state v] to [0]\nset [ghost v] effect to (30)\ngo to [front v] layer\nhide\n\nforever\n\nwhen I receive [tick v]\ngo to [front v] layer\nswitch costume to (Level)\nif <(Hint State) = [1]> then\n    show\nelse\n    hide\nend\n\nwhen [h v] key pressed\nif <(Hint State) = [1]> then\n    set [hint state v] to [0]\nelse\n    set [hint state v] to [1]\nend\n\n@Saves Reader\n\nwhen I receive [load data v]\nset [chars v] to [abcdefghijklmnopqrstuvwxyz!@#$%^&*\(\)~`";:?/.>,<|\}\]{\[+=_-1234567890 ]\nif <not <[hall of fame v] contains (username)?>> then\n    Encode Username\nend\ndelete (all) of [hall of fame v]\nDecode Usernames\n\ndefine Convert [] to Numbers\nset [append to me! v] to []\nset [i1 v] to [1]\nrepeat (length of (letters))\n    set [i2 v] to [1]\n    repeat until <(letter (i2) of (Chars)) = (letter (i1) of (letters))>\n        change [i2 v] by (1)\n    end\n    if <(length of (i2)) = [1]> then\n        set [i2 v] to (join [0] (i2))\n    end\n    set [append to me! v] to (join (Append to me!) (i2))\n    change [i1 v] by (1)\nend\n\ndefine Search For User ID\nset [user location in save list v] to []\nset [i0 v] to [1]\nrepeat until <not <(User Location in Save List) = []>>\n    if <(username) = (item (i0) of [hall of fame v])> then\n        set [user location in save list v] to (i0)\n    end\nend\n\ndefine Encode Username\nConvert (username) to Numbers\nset [☁ users \(encoded\) v] to (join (☁ Users \(Encoded\)) (join (Append to me!) [00]))\n\ndefine Decode Usernames\nset [i1 v] to [0]\nset [i0 v] to [1]\nrepeat until <(i0) = [0]>\n    set [append to me! v] to []\n    set [scanner v] to []\n    repeat until <<(Scanner) = [00]> or <(i1) > (length of (☁ Users \(Encoded\)))>>\n        set [scanner v] to []\n        repeat (2)\n            change [i1 v] by (1)\n            set [scanner v] to (join (Scanner) (letter (i1) of (☁ Users \(Encoded\))))\n        end\n        if <(Scanner) = [00]> then\n        else\n            set [append to me! v] to (join (Append to me!) (letter (Scanner) of (Chars)))\n        end\n    end\n    if <(Append to me!) = []> then\n        set [i0 v] to [0]\n    else\n        add (Append to me!) to [hall of fame v]\n    end\nend\n\ndelete (all) of [hall of fame v]\nset [☁ users \(encoded\) v] to []\n\nSearch For User ID\n\nwhen I receive [beat last level legit v]\ndelete (all) of [hall of fame v]\nDecode Usernames\nbroadcast (Load Data v)\n\n