Journey a Scrolling Platformer

Instructions: Woah... 1000+ views in a week!\n\nScrolling Platformer with my own Engine :D\n\nInstructions\n-Use the arrow keys to move\n-Avoid spikes and saws\n-Checkpoints are the weird circle things\n\n@krishtheking123 ❤️⭐\n@Benelem12 ❤️⭐\n@i_am_very_silly ❤️\n@Lazy_otter2_0 ❤️

@Stage\n\nwhen flag clicked\nforever\n    play sound [Avicii - Levels v] until done\nend\n\n@nothing\n\n@Check points\n\nwhen I receive [green flag clicked v]\nhide\n\ndefine Create Checkpoint (x) (y)\nchange [x v] by ((x) * (460))\nset [y v] to (y)\nswitch costume to (big ring grey v)\ncreate clone of (_myself_ v)\nswitch costume to (small ring grey v)\ncreate clone of (_myself_ v)\n\nwhen I receive [play game v]\nset [x v] to [0]\nset [y v] to [0]\nCreate Checkpoint [7.9] [155]\nCreate Checkpoint [2.85] [-40]\n\nwhen I receive [checkpoint v]\nif <<(costume [number v]) < [3]> and <(distance to [player v]) < [50]>> then\n    switch costume to ((costume [number v]) + (2))\n    set [last checkpoint x v] to (x)\n    set [last checkpoint y v] to (y)\nend\n\nwhen I start as a clone\ngo to x: ((x) - (Scrollx)) y: ((y) - (Scrolly))\nshow\n\nwhen I receive [tick v]\nset size to (200) %\ngo to x: ((x) - (Scrollx)) y: ((y) - (Scrolly))\nSet size\n\ndefine Set size\nif <(costume [number v]) = [1]> then\n    set size to ((50) + (([sin v] of ((sine timer) * (95)) ) * (10))) %\nelse\n    if <(costume [number v]) = [2]> then\n        set size to ((50) + (([cos v] of ((sine timer) * (95)) ) * (10))) %\n    else\n        if <(costume [number v]) = [3]> then\n            set size to ((50) + (([sin v] of ((sine timer) * (95)) ) * (20))) %\n        else\n            if <(costume [number v]) = [4]> then\n                set size to ((50) + (([cos v] of ((sine timer) * (95)) ) * (20))) %\n            end\n        end\n    end\nend\n\nwhen I receive [end v]\ndelete this clone\n\n@Game\n\nwhen flag clicked\nbroadcast (Green Flag Clicked v) and wait\nbroadcast (Play Game v)\nset [timer v] to [0]\nforever\n    wait (0.05) seconds\n    change [timer v] by (0.1)\nend\n\nwhen I receive [end v]\nstop [other scripts in sprite v]\n\n@Player\n\ndefine Set Costume\nif <<<key (right arrow v) pressed?> or <key (d v) pressed?>> and <<key (up arrow v) pressed?> or <key (w v) pressed?>>> then\n    switch costume to (right up v)\nelse\n    if <<<key (left arrow v) pressed?> or <key (a v) pressed?>> and <<key (up arrow v) pressed?> or <key (w v) pressed?>>> then\n        switch costume to (left up v)\n    else\n        if <<<key (left arrow v) pressed?> or <key (a v) pressed?>> and <(ym) < [0]>> then\n            switch costume to (left down v)\n        else\n            if <<<key (right arrow v) pressed?> or <key (d v) pressed?>> and <(ym) < [0]>> then\n                switch costume to (right down v)\n            else\n                if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n                    switch costume to (right v)\n                else\n                    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n                        switch costume to (left v)\n                    else\n                        if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                            switch costume to (up v)\n                        else\n                            if <(ym) < [0]> then\n                                switch costume to (down v)\n                            else\n                                switch costume to (idle v)\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [play game v]\nbroadcast (Next Level v) and wait\nbroadcast (Re-write FPS v)\nset [counter v] to [0]\nshow\ngo to [front v] layer\nforever\n    change [counter v] by (1)\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        X Movement: change x: [1]\n    end\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        X Movement: change x: [-1]\n    end\n    set [xm v] to ((xm) * (0.9))\n    change x by (xm)\n    if <touching (ground v)?> then\n        change y by (1)\n        if <touching (ground v)?> then\n            change y by (1)\n            if <touching (ground v)?> then\n                change y by (1)\n                if <touching (ground v)?> then\n                    change y by (1)\n                    if <touching (ground v)?> then\n                        change y by (-4)\n                        change x by ((0) - (xm))\n                        if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                            Y Movement: set y: [14]\n                            if <(xm) > [0]> then\n                                X movement: set x: [-10]\n                            else\n                                X movement: set x: [10]\n                            end\n                        else\n                            set [xm v] to [0]\n                        end\n                    end\n                end\n            end\n        end\n    end\n    Y movement: change y: [-1]\n    change y by (ym)\n    if <touching (ground v)?> then\n        change y by ((0) - (ym))\n        set [ym v] to [0]\n    end\n    change y by (-1)\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> and <<touching (ground v)?> or <touching (water v)?>>> then\n        Y Movement: set y: [12]\n    end\n    change y by (1)\n    if <<touching (spikes v)?> or <touching (traps/moving traps v)?>> then\n        broadcast (Dead v) and wait\n        Setup\n    end\n    if <(y position) < [-175]> then\n        broadcast (Dead v) and wait\n        Setup\n    end\n    change [x v] by (xm)\n    change [y v] by (ym)\n    set [scrollx v] to (x)\n    if <(x) < [0]> then\n        set [scrollx v] to [0]\n    else\n        if <(x) > [5450]> then\n            set [scrollx v] to [5450]\n        else\n            set x to (0)\n        end\n    end\n    set y to (y)\n    if <touching (check points v)?> then\n        broadcast (CheckPoint v)\n    end\n    if <(timer) > [1]> then\n        reset timer\n        set [fps v] to (counter)\n        set [counter v] to [0]\n        broadcast (Re-write FPS v)\n    end\n    if <(x position) > [240]> then\n        broadcast (END v)\n    end\n    Set Costume\n    broadcast (Tick v)\nend\n\nwhen I receive [green flag clicked v]\nset [last checkpoint x v] to [0]\nset [last checkpoint y v] to [0]\nset [level v] to [1]\nhide\nSetup\n\ndefine Setup\nset [xm v] to [0]\nset [ym v] to [0]\nset [x v] to (Last Checkpoint X)\nset [y v] to (Last Checkpoint Y)\nset [scrollx v] to [0]\nset [scrolly v] to [0]\nset [trap speed v] to [3]\ngo to x: (0) y: (0)\n\ndefine X Movement: change x: (x)\nif <touching (water v)?> then\n    change [xm v] by ((x) / (3))\nelse\n    change [xm v] by (x)\nend\n\ndefine X movement: set x: (x)\nif <touching (water v)?> then\n    set [xm v] to ((x) / (3))\nelse\n    set [xm v] to (x)\nend\n\ndefine Y movement: change y: (y)\nif <touching (water v)?> then\n    change [ym v] by ((y) / (3))\nelse\n    change [ym v] by (y)\nend\n\ndefine Y Movement: set y: (y)\nif <touching (water v)?> then\n    set [ym v] to ((y) / (3))\nelse\n    set [ym v] to (y)\nend\n\ndefine Get out of Ground\nrepeat until <not <touching (ground v)?>>\n    if <(ym) > [0]> then\n        change y by (-1)\n    else\n        change y by (1)\n    end\nend\nset [ym v] to [0]\n\nwhen I receive [play game v]\nset [sine timer v] to [0]\nforever\n    change [sine timer v] by (0.03)\nend\n\nhide\nchange [level v] by (1)\nSetup\nbroadcast (Next Level v) and wait\nshow\n\nwhen I receive [end v]\nhide\nstop [this script v]\n\nwhen I start as a clone\nswitch costume to (clone v)\nrepeat (25)\n    go to x: ((x) - (Scrollx)) y: ((y) - (Scrolly))\n    change [ghost v] effect by (4)\n    change size by (-4)\nend\ndelete this clone\n\nwhen I receive [play game v]\nforever\n    create clone of (_myself_ v)\n    wait (0.05) seconds\nend\n\n@Ground\n\nwhen I receive [tick v]\nset size to (200) %\ngo to x: ((x) - (Scrollx)) y: ((y) - (Scrolly))\nset size to (100) %\n\ndefine Create Ground (x)\nchange [x v] by ((x) * (460))\nset [y v] to [0]\ncreate clone of (_myself_ v)\nnext costume\n\nwhen I receive [next level v]\nif <(Level) = [1]> then\n    Create Ground [0]\n    repeat (3)\n        Create Ground [1]\n    end\n    Create Ground [0.7]\n    repeat (5)\n        Create Ground [1]\n    end\n    Create Ground [1.07]\n    repeat (3)\n        Create Ground [1]\n    end\nend\n\nwhen I receive [green flag clicked v]\nhide\nswitch costume to (level 1 1 v)\nset [x v] to [0]\nset [y v] to [0]\n\nwhen I start as a clone\ngo to x: ((x) - (Scrollx)) y: ((y) - (Scrolly))\nshow\n\nwhen I receive [end v]\ndelete this clone\n\n@Detail\n\nwhen I receive [green flag clicked v]\nhide\ngo to [back v] layer\nswitch costume to (level 1 1 v)\nset [x v] to [0]\nset [y v] to [0]\n\nwhen I receive [tick v]\nset size to (200) %\ngo to x: ((x) - (Scrollx)) y: ((y) - (Scrolly))\nset size to (100) %\n\ndefine Create Ground (x)\nchange [x v] by ((x) * (460))\nset [y v] to [0]\ncreate clone of (_myself_ v)\nnext costume\n\nwhen I receive [next level v]\nif <(Level) = [1]> then\n    Create Ground [0]\n    repeat (3)\n        Create Ground [1]\n    end\n    Create Ground [0.7]\n    repeat (5)\n        Create Ground [1]\n    end\n    Create Ground [1.07]\n    repeat (2)\n        Create Ground [1]\n    end\nend\n\nwhen I start as a clone\ngo to x: ((x) - (Scrollx)) y: ((y) - (Scrolly))\nshow\n\nwhen I receive [end v]\ndelete this clone\n\n@Traps/Moving Traps\n\nwhen I receive [tick v]\nif <(id) = [clone]> then\n    set size to (200) %\n    go to x: ((x) - (Scrollx)) y: ((y) - (Scrolly))\n    turn right ((Trap Speed) * (2)) degrees\n    set size to (100) %\n    change [x v] by ((((endX) - (starX)) / ([abs v] of ((endX) - (starX)) )) * (Trap Speed))\n    change [y v] by ((((endY) - (startY)) / ([abs v] of ((endY) - (startY)) )) * (Trap Speed))\n    if <<(x) = (endX)> or <<<(x) > (endX)> and <(left/right) = [1]>> or <<(x) < (endX)> and <(left/right) = [-1]>>>> then\n        set [x v] to (endX)\n        set [endx v] to (starX)\n        set [starx v] to (x)\n        if <(left/right) = [1]> then\n            set [left/right v] to [-1]\n        else\n            set [left/right v] to [1]\n        end\n    end\n    if <<(y) = (endY)> or <<<(y) > (endY)> and <(up/down) = [1]>> or <<(y) < (endY)> and <(up/down) = [-1]>>>> then\n        set [y v] to (endY)\n        set [endy v] to (startY)\n        set [starty v] to (y)\n        if <(up/down) = [1]> then\n            set [up/down v] to [-1]\n        else\n            set [up/down v] to [1]\n        end\n    end\nend\n\ndefine Create Trap (x) (y) movement (xmove) (ymove)\nchange [x v] by ((x) * (460))\nset [y v] to (y)\nset [starx v] to (x)\nset [starty v] to (y)\nset [endx v] to ((x) + (xmove))\nset [endy v] to ((y) + (ymove))\nset [left/right v] to [0]\nset [up/down v] to [0]\nif <not <(xmove) = [0]>> then\n    set [left/right v] to [1]\nend\nif <not <(ymove) = [0]>> then\n    set [up/down v] to [1]\nend\nset [id v] to [clone]\ncreate clone of (_myself_ v)\nset [id v] to [sprite]\n\nwhen I receive [next level v]\nif <(Level) = [1]> then\n    Create Trap [4.6] [-90] movement [0] [0]\n    Create Trap [0.4] [-90] movement [0] [0]\n    Create Trap [0.4] [-50] movement [0] [150]\n    Create Trap [0.2] [-90] movement [200] [0]\n    Create Trap [1.2] [80] movement [0] [0]\n    Create Trap [0.3] [-80] movement [0] [0]\n    Create Trap [0.3] [80] movement [0] [0]\n    Create Trap [0.3] [-80] movement [0] [0]\n    Create Trap [3.3] [-80] movement [0] [0]\nend\n\nwhen I receive [green flag clicked v]\nhide\nswitch costume to (trap v)\nset [x v] to [0]\nset [y v] to [0]\n\nwhen I start as a clone\ngo to x: ((x) - (Scrollx)) y: ((y) - (Scrolly))\nshow\n\nwhen [m v] key pressed\nset [mouse v] to (join ((((Scrollx) + (mouse x)) - (x)) / (460)) (join [, ] ((Scrolly) + (mouse y))))\n\nwhen I receive [end v]\ndelete this clone\n\n@Spikes\n\nwhen I receive [tick v]\nset size to (200) %\ngo to x: ((x) - (Scrollx)) y: ((y) - (Scrolly))\nset size to (100) %\n\ndefine Create Spikes (x)\nchange [x v] by ((x) * (460))\nset [y v] to [0]\ncreate clone of (_myself_ v)\nnext costume\n\nwhen I receive [next level v]\nif <(Level) = [1]> then\n    Create Spikes [0]\n    repeat (3)\n        Create Spikes [1]\n    end\n    Create Spikes [0.7]\n    repeat (5)\n        Create Spikes [1]\n    end\n    Create Spikes [1.07]\n    repeat (2)\n        Create Spikes [1]\n    end\nend\n\nwhen I receive [green flag clicked v]\nhide\nswitch costume to (level 1 1 v)\nset [x v] to [0]\nset [y v] to [0]\n\nwhen I start as a clone\ngo to x: ((x) - (Scrollx)) y: ((y) - (Scrolly))\nshow\n\nwhen I receive [end v]\ndelete this clone\n\n@Water\n\nwhen I receive [tick v]\nset size to (200) %\ngo to x: ((x) - (Scrollx)) y: (((y) + (([sin v] of (((sine timer) + (sine)) * (50)) ) * (25))) - (Scrolly))\ngo to [back v] layer\nset size to (100) %\n\ndefine Create Water (x)\nset [sine v] to [1]\nchange [x v] by ((x) * (460))\nset [y v] to [0]\ncreate clone of (_myself_ v)\nrepeat (2)\n    change [sine v] by (0.5)\n    go [forward v] (1) layers\n    create clone of (_myself_ v)\nend\nnext costume\n\nwhen I receive [next level v]\nif <(Level) = [1]> then\n    Create Water [6.7]\n    Create Water [0.7]\nend\n\nwhen I receive [green flag clicked v]\nhide\nswitch costume to (level 1 1 v)\nset [x v] to [0]\nset [y v] to [0]\n\nwhen I start as a clone\ngo to x: ((x) - (Scrollx)) y: ((y) - (Scrolly))\nset [brightness v] effect to ((sine) * (10))\nshow\n\nwhen I receive [end v]\ndelete this clone\n\n@Effects\n\nwhen I receive [green flag clicked v]\nset [ghost v] effect to (100)\nset [brightness v] effect to (100)\ngo to x: (0) y: (0)\nshow\n\nwhen I receive [dead v]\ngo to [front v] layer\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nbroadcast (_Dead2 v)\n\nwhen I receive [_dead2 v]\nwait (0.5) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\nwhen I receive [play game v]\nset [ghost v] effect to (0)\nrepeat (50)\n    change [ghost v] effect by (2)\n    go to [front v] layer\nend\n\nwhen I receive [end v]\nhide\n\n@FPS\n\nwhen I receive [green flag clicked v]\nset [end v] to [false]\nerase all\nhide\nset [font width v] to [22]\nset [font height v] to [40]\nset [text.spacing v] to [20]\nset [text.left v] to [-240]\nset [text.right v] to [240]\nset [text.scale v] to [75]\nmeasure char widths\n\nwhen I receive [re-write fps v]\nRe-write FPS\n\nwhen I receive [delete previous fps v]\ndelete this clone\n\nwhen I start as a clone\nshow\n\ndefine Re-write FPS\nif <(end) = [false]> then\n    broadcast (Delete Previous FPS v)\n    Write text: (join [FPS: ] (FPS)) at: [-220] [160] with color of [Black]\nelse\n    broadcast (Delete Previous FPS v)\nend\n\nwhen I receive [end v]\nset [end v] to [true]\nstop [other scripts in sprite v]\ndelete this clone\n\ndefine measure char widths\nset size to (Text.Scale) %\ndelete all of [char widths v]\nswitch costume to (char a v)\nshow\nset y to (0)\nforever\n    set x to (240)\n    repeat until <not <touching (_edge_ v)?>>\n        change x by (-1)\n    end\n    add (((240) - (x position)) + (20)) to [char widths v]\n    next costume\n    if <(costume [name v]) = [end marker dot]> then\n        hide\n        stop [this script v]\n    end\nend\n\ndefine Write text: (text) at: (x) (y) with color of (color)\nrepeat (2)\n    go to x: (x) y: (y)\n    set [i v] to [1]\n    clear graphic effects\n    if < (color) contains [Orange]?> then\n        set [color v] effect to (15)\n    else\n        if < (color) contains [Lime Green]?> then\n            set [color v] effect to (40)\n        else\n            if < (color) contains [Green]?> then\n                set [color v] effect to (65)\n            else\n                if < (color) contains [Turquoise]?> then\n                    set [color v] effect to (80)\n                else\n                    if < (color) contains [Blue]?> then\n                        set [color v] effect to (120)\n                    else\n                        if < (color) contains [Yellow]?> then\n                            set [color v] effect to (28)\n                        else\n                            if < (color) contains [Purple]?> then\n                                set [color v] effect to (150)\n                            else\n                                if < (color) contains [Pink]?> then\n                                    set [color v] effect to (170)\n                                else\n                                    if < (color) contains [Black]?> then\n                                        set [brightness v] effect to (-100)\n                                    else\n                                        if < (color) contains [White]?> then\n                                            set [brightness v] effect to (100)\n                                        else\n                                            if < (color) contains [Brown]?> then\n                                                set [color v] effect to (20)\n                                                set [brightness v] effect to (-25)\n                                            end\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    if < (color) contains [Dark]?> then\n        change [brightness v] effect by (-50)\n    end\n    if < (color) contains [Light]?> then\n        change [brightness v] effect by (50)\n    end\n    repeat (length of (text))\n        set [letter v] to (letter (i) of (text))\n        if <(letter) = [ ]> then\n            change x by ((Text.Spacing) * (scale))\n            change [i v] by (1)\n        else\n            set [x v] to (x position)\n            set [j v] to (i)\n            repeat until <<(letter (j) of (text)) = [ ]> or <(j) > (length of (text))>>\n                switch costume to (join [char ] (letter (j) of (text)))\n                change [x v] by ((item (costume [number v]) of [char widths v]) * (scale))\n                change [j v] by (1)\n            end\n            if <(x) > [230]> then\n                set x to (x)\n                change y by ((0) - ((font height) * (scale)))\n            end\n            repeat until <(i) = (j)>\n                set [letter v] to (letter (i) of (text))\n                switch costume to (join [char ] (letter (i) of (text)))\n                set size to (Text.Scale) %\n                create clone of (_myself_ v)\n                change x by ((item (costume [number v]) of [char widths v]) * (scale))\n                change [i v] by (1)\n            end\n        end\n    end\nend\n\n@World Record Button\n\ndefine Fancy to size (size)\nchange size by (((size) - (size)) / (10))\n\nwhen I receive [green flag clicked v]\nhide\ngo to x: (210) y: (150)\n\nwhen I receive [play game v]\n\nshow\nforever\n    if <touching (mouse-pointer v)?> then\n        Fancy to size [125]\n    else\n        Fancy to size [100]\n    end\nend\n\nwhen this sprite clicked\nbroadcast (END v)\nhide\n\n@High Scores\n\nwhen I receive [green flag clicked v]\n\nwhen I receive [end v]\ndecode highscores\nset [i v] to [1]\nrepeat (high score length)\n    if <(Timer) < (item (i) of [high scores v])> then\n        insert (Timer) at (i) of [high scores v] \n        insert (username) at (i) of [high score names v] \n        set [i v] to [1]\n        repeat (high score length)\n            if <(item (i) of [high score names v]) = (username)> then\n                delete (i) of [high score names v]\n                delete (i) of [high scores v]\n                encode highscores\n                stop [this script v]\n            end\n            change [i v] by (1)\n        end\n        delete ((high score length) + (1)) of [high scores v]\n        delete ((high score length) + (1)) of [high score names v]\n        encode highscores\n        stop [this script v]\n    end\n    change [i v] by (1)\nend\n\ndefine get username\nset [username v] to []\nset [i v] to [1]\nrepeat (10)\n    set [username v] to (join (username) (letter (i) of (username)))\n    change [i v] by (1)\n    if <(i) > (length of (username))> then\n        stop [this script v]\n    end\nend\n\nget username\ndelete all of [all characters v]\nset [all characters v] to [ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_\[\]]\nset [i v] to [1]\nrepeat (length of (all characters))\n    add (letter (i) of (all characters)) to [all characters v]\n    change [i v] by (1)\nend\nset [high score length v] to [8]\ndelete all of [high scores v]\ndelete all of [high score names v]\nrepeat (high score length)\n    add [999999] to [high scores v]\n    add [\[BLANK\]] to [high score names v]\nend\ndecode highscores\n\ndefine encode highscores\nif <(connected?) = [true]> then\n    set [cloud data v] to []\n    set [counter v] to [1]\n    repeat (high score length)\n        encode name (item (counter) of [high score names v])\n        encode score (item (counter) of [high scores v])\n        change [counter v] by (1)\n    end\n    set [☁ highscores v] to (cloud data)\nend\n\ndefine encode name (name)\nset [i v] to [1]\nrepeat (length of (name))\n    set [character number v] to (item # of (letter (i) of (name)) in [all characters v])\n    if <(character number) < [10]> then\n        set [character number v] to (join [0] (character number))\n    end\n    set [cloud data v] to (join (cloud data) (character number))\n    change [i v] by (1)\nend\nrepeat ((10) - (length of (name)))\n    set [cloud data v] to (join (cloud data) [00])\nend\n\ndefine encode score (score)\nset [time v] to (score)\nrepeat until <(length of (time)) = [5]>\n    set [time v] to (join [0] (time))\nend\nset [cloud data v] to (join (cloud data) (time))\n\ndefine decode highscores\nif <(cloud data) = [0]> then\n    set [connected? v] to [false]\nelse\n    set [i v] to [1]\n    set [connected? v] to [true]\n    set [cloud data v] to (☁ Highscores)\n    set [counter v] to [1]\n    repeat (high score length)\n        decode name\n        decode score\n        replace item (counter) of [high score names v] with (decoded name)\n        replace item (counter) of [high scores v] with (decoded score)\n        change [counter v] by (1)\n    end\nend\n\ndefine decode name\nset [decoded name v] to []\nrepeat (10)\n    set [character number v] to (join (letter (i) of (cloud data)) (letter ((i) + (1)) of (cloud data)))\n    if <(character number) > [0]> then\n        set [character v] to (item (character number) of [all characters v])\n        set [decoded name v] to (join (decoded name) (character))\n    end\n    change [i v] by (2)\nend\n\ndefine decode score\nset [decoded score v] to []\nrepeat (5)\n    set [decoded score v] to (join (decoded score) (letter (i) of (cloud data)))\n    change [i v] by (1)\nend\n\ndelete all of [high scores v]\ndelete all of [high score names v]\nrepeat (high score length)\n    add [99999] to [high scores v]\n    add [\[BLANK\]] to [high score names v]\nend\nset [connected? v] to [true]\nencode highscores\n\n@High Score Display\n\nwhen I receive [end v]\n\nerase all\nhide\nset [font width v] to [22]\nset [font height v] to [40]\nset [text.spacing v] to [20]\nset [text.left v] to [-240]\nset [text.right v] to [240]\nset [text.scale v] to [75]\nmeasure char widths\nWrite text: [High Scores:] at: [-50] [160] with color of [Black]\nCreate HighScores\n\ndefine Create HighScores\nset [index v] to [1]\nset [text.scale v] to [65]\nrepeat ([high score length v] of [high scores v])\n    Write text: (join (index) (join [. ] (join (item (index) of [high score names v]) (join [   ] (item (index) of [high scores v]))))) at: [-170] ((155) - ((index) * ((font height) - (8)))) with color of [Black]\n    change [index v] by (1)\nend\n\ndefine measure char widths\nset size to (Text.Scale) %\ndelete all of [char widths v]\nswitch costume to (char a v)\nshow\nset y to (0)\nforever\n    set x to (240)\n    repeat until <not <touching (_edge_ v)?>>\n        change x by (-1)\n    end\n    add (((240) - (x position)) + (12)) to [char widths v]\n    next costume\n    if <(costume [name v]) = [end marker dot]> then\n        hide\n        stop [this script v]\n    end\nend\n\ndefine Write text: (text) at: (x) (y) with color of (color)\nrepeat (2)\n    go to x: (x) y: (y)\n    set [i v] to [1]\n    clear graphic effects\n    if < (color) contains [Orange]?> then\n        set [color v] effect to (15)\n    else\n        if < (color) contains [Lime Green]?> then\n            set [color v] effect to (40)\n        else\n            if < (color) contains [Green]?> then\n                set [color v] effect to (65)\n            else\n                if < (color) contains [Turquoise]?> then\n                    set [color v] effect to (80)\n                else\n                    if < (color) contains [Blue]?> then\n                        set [color v] effect to (120)\n                    else\n                        if < (color) contains [Yellow]?> then\n                            set [color v] effect to (28)\n                        else\n                            if < (color) contains [Purple]?> then\n                                set [color v] effect to (150)\n                            else\n                                if < (color) contains [Pink]?> then\n                                    set [color v] effect to (170)\n                                else\n                                    if < (color) contains [Black]?> then\n                                        set [brightness v] effect to (-100)\n                                    else\n                                        if < (color) contains [White]?> then\n                                            set [brightness v] effect to (100)\n                                        else\n                                            if < (color) contains [Grey]?> then\n                                                set [brightness v] effect to (-30)\n                                            else\n                                                if < (color) contains [Brown]?> then\n                                                    set [color v] effect to (20)\n                                                    set [brightness v] effect to (-25)\n                                                end\n                                            end\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    if < (color) contains [Dark]?> then\n        change [brightness v] effect by (-50)\n    end\n    if < (color) contains [Light]?> then\n        change [brightness v] effect by (50)\n    end\n    repeat (length of (text))\n        set [letter v] to (letter (i) of (text))\n        if <(letter) = [ ]> then\n            change x by ((Text.Spacing) * (scale))\n            change [i v] by (1)\n        else\n            set [x v] to (x position)\n            set [j v] to (i)\n            repeat until <<(letter (j) of (text)) = [ ]> or <(j) > (length of (text))>>\n                switch costume to (join [char ] (letter (j) of (text)))\n                change [x v] by ((item (costume [number v]) of [char widths v]) * (scale))\n                change [j v] by (1)\n            end\n            if <(x) > [230]> then\n                set x to (x)\n                change y by ((0) - ((font height) * (scale)))\n            end\n            repeat until <(i) = (j)>\n                set [letter v] to (letter (i) of (text))\n                switch costume to (join [char ] (letter (i) of (text)))\n                set size to (Text.Scale) %\n                stamp\n                change x by ((item (costume [number v]) of [char widths v]) * (scale))\n                change [i v] by (1)\n            end\n        end\n    end\nend\n\n@END\n\nwhen flag clicked\nhide\n\nwhen I receive [end v]\nshow\nstop [all v]\n\n@Thumb\n\nwhen flag clicked\nset [ghost v] effect to (100)\ngo to [front v] layer\n\n