Tera Trance- A scrolling platformer

Instructions: Welcome to Tera Trance, a scrolling\nplatformer.\nInstructions-\nJump on the flying apple to start\nArrow keys/WAS/mobile to move.\nR to reset.\nL to reduce lag, press L again to exit.

@Stage\n\n@PLAYER\n\ndefine change y by (y)\nset [move on sprite? v] to [0]\nchange [ypos v] by (y)\nchange [falling v] by (1)\nposition\nrepeat until <not <<touching (platforms v)?> or <touching (platforms2 v)?>>>\n    if <(y) > [0]> then\n        change [ypos v] by (-1)\n    else\n        change [ypos v] by (1)\n        set [falling v] to [0]\n    end\n    position\n    set [yspeed v] to [0]\nend\n\nwhen I receive [begin! v]\nbroadcast (music/enemy setup v)\nset [level v] to [1]\nforever\n    broadcast (reset v) and wait\n    broadcast (setup v) and wait\n    prepare\n    set [yspeed v] to [0]\n    repeat until <<(EXIT) = [win]> or <(EXIT) = [die]>>\n        Tick <<<key (d v) pressed?> or <key (right arrow v) pressed?>> or <<mouse down?> and <(mouse x) > [10]>>> <<<key (a v) pressed?> or <key (left arrow v) pressed?>> or <<mouse down?> and <(mouse x) < [-10]>>> <<<key (w v) pressed?> or <key (up arrow v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>>\n        if <(Lag?) = [0]> then\n            broadcast (tick v) and wait\n        else\n            broadcast (tick v)\n        end\n    end\n    if <(EXIT) = [win]> then\n        win\n    else\n        lose\n    end\nend\n\ndefine Tick <right> <left> <jump>\nswitch costume to (hitbox v)\nRead keys x velocity: [0.45] y velocity: [16] <jump> <left> <right>\nBounce physics without key: [20] with key: [30] <jump>\nif <(xv) > [1.3]> then\n    set [xv v] to [1.3]\nend\nif <(xv) < [-1.3]> then\n    set [xv v] to [-1.3]\nend\nchange [yspeed v] by (-1.7)\nchange y by (yspeed)\ntest die\nSCROLL ((xpos) - (CAMX)) ((ypos) - (CAMY)) [10]\nposition\nif <(y position) < [-184]> then\n    set [exit v] to [die]\nend\nif  then\n    set [exit v] to [hurt]\nend\nif <<(EXIT) = [hurt]> and <(invincible?) = [off]>> then\n    broadcast (hurt v)\nend\nanimate <<<left> or <right>> and <not <jump>>> <jump>\n\ndefine lose\nset [exit v] to []\nrepeat (5)\n    set [ghost v] effect to (100)\n    wait (0.1) seconds\n    clear graphic effects\n    wait (0.1) seconds\nend\nhide\nwait (0.5) seconds\nchange size by (-8)\n\ndefine position\ngo to x: ((xpos) - (CAMX)) y: (((ypos) - (CAMY)) - (0))\n\ndefine change x by (x)\nif <(x) > [0]> then\n    point in direction (90)\nelse\n    point in direction (-90)\nend\nchange [xpos v] by (x)\nposition\nif <<touching (platforms v)?> or <touching (platforms2 v)?>> then\n    repeat (10)\n        change [ypos v] by (1)\n        position\n        if <not <<touching (platforms v)?> or <touching (platforms2 v)?>>> then\n            stop [this script v]\n        end\n    end\n    change [ypos v] by (-10)\n    repeat until <not <<touching (platforms v)?> or <touching (platforms2 v)?>>>\n        if <(x) > [0]> then\n            change [xpos v] by (-1)\n        else\n            change [xpos v] by (((xv) / (5)) * (-1))\n        end\n        position\n    end\nend\nchange [xv v] by (() - ((xv) / (3)))\n\ndefine calcualte Frame\nif <(Frame) = [off]> then\n    set [frame v] to [on]\nend\nif <(Frame) = [on]> then\n    set [frame v] to [after]\nend\n\nwhen [r v] key pressed\nset [exit v] to [die]\n\nwhen flag clicked\nhide\n\nwhen I receive [music/enemy setup v]\nset [time v] to [0]\nset [camy v] to [0]\nset [camx v] to [0]\nrepeat until <<(CAMX) > [0]> and <(CAMY) > [4300]>>\n    wait (1) seconds\n    change [time v] by (1)\nend\nset [game finished v] to [1]\nhide\nbroadcast (Show final score v) and wait\n\nwhen I receive [movement on sprtie v]\nchange [xpos v] by (([. v] of [platforms2 v]) * (3))\n\nwhen I receive [frame it v]\nset [frame script? v] to [1]\nif <(Frame) = [8]> then\n    set [frame v] to [1]\nelse\n    change [frame v] by (1)\nend\nwait (0.035) seconds\nset [frame script? v] to [0]\n\ndefine test die\nif  then\n    set [exit v] to [die]\nend\n\ndefine win\nhide\nset [camx v] to [0]\nset [camy v] to [0]\nchange [level v] by (1)\n\nwhen I receive [hurt v]\nif <<(CAMX) > [0]> and <(invincible?) = [off]>> then\n    set [invincible? v] to [on]\n    set [color v] effect to (84)\n    set [yspeed v] to [10]\n    repeat (15)\n        change [xpos v] by (((direction) / (90)) * (-8))\n    end\n    change [lives v] by (-1)\n    wait (0.2) seconds\n    clear graphic effects\n    set [exit v] to []\n    set [invincible? v] to [off]\nend\nif <(LIVES) = [0]> then\n    set [exit v] to [die]\nend\n\nwhen [1 v] key pressed\nif <(username) = [jamw7]> then\n    change [camy v] by (360)\nend\n\nwhen [2 v] key pressed\nif <(username) = [jamw7]> then\n    change [camy v] by (360)\n    change [camy v] by (600)\n    change [camx v] by (0)\nend\n\nwhen [l v] key pressed\nif <(lag.) = [0]> then\n    show variable [lag? v]\n    set [lag. v] to [1]\nelse\n    hide variable [lag? v]\n    set [lag. v] to [0]\nend\n\nwhen flag clicked\nset size to (100) %\nset [game finished v] to [0]\nbroadcast (Trailor v) and wait\nbroadcast (green flag v) and wait\nbroadcast (begin! v) and wait\n\nwhen I receive [green flag v]\nset [checkx v] to [0]\nset [checky v] to [0]\nhide\ngo to [front v] layer\ngo [backward v] (1) layers\n\ndefine prepare\nhide variable [lag? v]\nset [lag. v] to [0]\nset [lag? v] to [0]\nset [. v] to [1]\nset [camx v] to (CHECKX)\nset [camy v] to (CHECKY)\nset [lives v] to [3]\nset [exit v] to []\nset [xpos v] to (CHECKX)\nset [ypos v] to (CHECKY)\nset [invincible? v] to [off]\nset [freeze? v] to [0]\nset [xv v] to [0]\nset [frame script? v] to [0]\nset [yspeed v] to [0]\nset [falling v] to [0]\nswitch costume to (hitbox v)\nclear graphic effects\ngo to [front v] layer\nif <(GAME FINISHED) = [0]> then\n    show\nend\ngo to x: (0) y: (0)\nset rotation style [left-right v]\npoint in direction (90)\n\ndefine Bounce physics without key: (wk) with key: (withk) <jump>\nif <touching (bounce v)?> then\n    set [yspeed v] to ((wk) + (<jump> * ((withk) - (wk))))\nend\n\ndefine Read keys x velocity: (xv) y velocity: (yv) <jump> <left> <right>\nif <right> then\n    change [xv v] by (xv)\n    calcualte Frame\nelse\n    if <left> then\n        change [xv v] by (() - (xv))\n        calcualte Frame\n    else\n        set [frame v] to [off]\n    end\nend\nif <not <(xv) = [0]>> then\n    change x by ((xv) * (7))\nend\nif <jump> then\n    if <(falling) < [4]> then\n        set [yspeed v] to (yv)\n    end\nend\n\ndefine SCROLL (x) (y) (delay)\nchange [camx v] by (round ((x) / (delay)))\nchange [camy v] by (round ((y) / ((delay) / (2))))\nif <<<(CAMX) < [0]> and <(xpos) > [-215]>> and <(CAMY) < [250]>> then\n    set [camx v] to [0]\nend\nif <(CAMY) < [-35]> then\n    set [camy v] to [-35]\nend\n\ndefine animate <left/right> <up>\nif <<left/right> and <not <(Frame) = [15]>>> then\n    if <(Frame script?) = [0]> then\n        broadcast (frame it v)\n    end\nelse\n    set [frame v] to [1]\nend\nif <(falling) < [4]> then\n    set [jump? v] to [0]\nelse\n    set [jump? v] to [1]\nend\nif <(jump?) = [0]> then\n    switch costume to (join [walk] (Frame))\nelse\n    if <(yspeed) > [0]> then\n        switch costume to (jump v)\n    else\n        switch costume to (fall v)\n    end\nend\nif <touching (exit point v)?> then\n    set [exit v] to [win]\nend\n\nwhen I receive [music/enemy setup v]\n\n    play sound [City Lights v] until done\nend\n\n@platforms\n\nwhen I receive [tick v]\nposition ((x) - (CAMX)) ((y) - (CAMY))\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\ndefine clone at x: (x) y: (y)\nhide\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nwhen I receive [reset v]\ngo to [back v] layer\ngo [forward v] (1) layers\nclear graphic effects\nhide\ndelete this clone\n\nwhen I receive [setup v]\ngo to x: (0) y: (0)\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (1 v)\n    repeat (2)\n        clone at x: [480] y: []\n    end\n    clone at x: [] y: [360]\n    clone at x: [-950] y: [90]\n    clone at x: [-480] y: []\n    clone at x: [960] y: [250]\n    clone at x: [450] y: [460]\n    clone at x: [700] y: []\n    clone at x: [480] y: []\n    clone at x: [600] y: [240]\n    clone at x: [] y: [500]\n    clone at x: [480] y: []\n    clone at x: [300] y: [400]\n    clone at x: [600] y: [100]\n    clone at x: [320] y: [-20]\n    clone at x: [570] y: [-300]\n    clone at x: [-100] y: [-250]\n    clone at x: [480] y: []\n    clone at x: [690] y: [500]\n    clone at x: [600] y: [50]\n    clone at x: [100] y: [650]\n    clone at x: [-80] y: [500]\n    clone at x: [730] y: []\n    clone at x: [890] y: [420]\nend\n\nwhen I receive [setup v]\n\nhide\ndelete this clone\n\nchange [y v] by (20)\n\nchange [x v] by (20)\n\nwhen I receive [trailor v]\nhide\n\n@Tour Guide\n\nwhen I receive [setup v]\nif <not <(check#) = [0]>> then\n    switch costume to ((cost) + (1))\nelse\n    switch costume to (0 v)\nend\nset [ghost effect v] to [100]\nshow\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\n\nwhen I receive [tick v]\nif x> [3840] and y> [2250] [] [] [+] check? []\nif x> [-100] and y> [0] [] [] [+] check? []\nif x> [945] and y> [448] [] [] [+] check? []\nif x> [333] and y> [100000000000] [-1000] [280] [-] check? []\nif x> [-370] and y> [740] [] [] [+] check? [1]\nif x> [660] and y> [900] [] [] [+] check? []\nif x> [1800] and y> [1350] [] [] [+] check? []\nif x> [2780] and y> [1387] [] [] [+] check? [1]\nif x> [2727] and y> [1000000] [2720] [1530] [-] check? []\nif x> [10000] and y> [1900] [4700] [1800] [-] check? [1]\nif x> [6000] and y> [2000] [] [] [+] check? []\nif x> [6490] and y> [3150] [] [] [+] check? [1]\nif <(ghost effect) < [101]> then\n    change [ghost effect v] by (1)\nend\nset [ghost v] effect to (ghost effect)\n\ndefine if x> (x) and y> (y) (x>) (y>) (+/-) check? (on/off)\nif <(+/-) = [+]> then\n    if <<<(CAMX) > (x)> and <(CAMY) > (y)>> and <not <[stop points v] contains (join (join (x) [, ]) (y))?>>> then\n        next costume\n        change [cost v] by (1)\n        set [ghost effect v] to [-125]\n        add (join (join (x) [, ]) (y)) to [stop points v]\n        if <(on/off) = [1]> then\n            set [checkx v] to (x)\n            set [checky v] to (y)\n            change [check# v] by (1)\n        end\n    end\nelse\n    if <<<<(x) > (CAMX)> and <(y) > (CAMY)>> and <<(CAMX) > (x>)> and <(CAMY) > (y>)>>> and <not <[stop points v] contains (join (join (x) [, ]) (y))?>>> then\n        next costume\n        change [cost v] by (1)\n        set [ghost effect v] to [-125]\n        add (join (join (x) [, ]) (y)) to [stop points v]\n        if <(on/off) = [1]> then\n            set [checkx v] to (x>)\n            set [checky v] to (y>)\n            change [check# v] by (1)\n        end\n    end\nend\n\nwhen I receive [begin! v]\nshow\nset [cost v] to [0]\nset [check# v] to [0]\ndelete all of [stop points v]\n\nwhen I receive [trailor v]\nhide\n\n@moving enimies\n\nwhen I receive [tick v]\npos (((x) + (round (x_))) - (CAMX)) ((y) - (CAMY))\nif <not <(costume [number v]) = [9]>> then\n    change [x_ v] by ((2) * (.))\n    cost.\n    set rotation style [left-right v]\n    if <([abs v] of (x_) ) > [100]> then\n        change dir.\n    end\n    if <touching (player v)?> then\n        if <touching (stomper v)?> then\n            switch costume to (milk-e v)\n        else\n            set [exit v] to [hurt]\n        end\n    end\nend\n\nnext costume\n\ndefine pos (x) (y)\ngo to x: (x) y: (y)\nif <<<(x) = (x position)> and <(y) = (y position)>> and <not <(costume [number v]) = [9]>>> then\n    show\nelse\n    hide\nend\n\ndefine clone at: (x) (y) (cost)\nswitch costume to (milk1 v)\nchange [x v] by (x)\nchange [y v] by (y)\ncreate clone of (_myself_ v)\nif <(cost) = [milk]> then\n    switch costume to (milk1 v)\nend\n\nwhen I receive [setup v]\nswitch costume to (milk1 v)\nset [status v] to [0]\nset [. v] to [1]\nset [x v] to [0]\nset [y v] to [0]\nset [x_ v] to [0]\nset [y_ v] to [0]\nclone at: [2550] [1547] []\nclone at: [1967] [747] []\nclone at: [796] [-491] []\nclone at: [1256] [783] []\nclone at: [136] [340] []\nclone at: [901] [886] []\nclone at: [490] [2] []\nclone at: [488] [3] []\nclone at: [-288] [305] []\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [oohhh... v]\n\ndefine cost.\nif <not <(costume [number v]) = [8]>> then\n    next costume\nelse\n    switch costume to (milk1 v)\nend\n\ndefine change dir.\nif <(x_) > [0]> then\n    point in direction (90)\n    set [. v] to [-1]\nelse\n    point in direction (-90)\n    set [. v] to [1]\nend\n\ndefine Physics.\n\nwhen I receive [trailor v]\nhide\n\n@bacteria\n\ndefine pos (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 [tick v]\npos ((x) - (CAMX)) (((y) - (CAMY)) + ())\nset rotation style [all around v]\nif <(pick random (1) to (7)) = [5]> then\n    set [yspeed v] to (() - (yspeed))\nend\nturn right ((pick random (15) to (-15)) + ((yspeed) * (15))) degrees\nif <touching (player v)?> then\n    set [exit v] to [hurt]\nend\nnext costume\n\nset [x v] to [4849]\nset [y v] to [1803]\n\nwhen I receive [reset v]\nset [yspeed v] to [0]\nset [_x v] to [0]\nset [_y v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nset [x v] to [0]\nset [y v] to [0]\ndelete this clone\n\ndefine clone (x) (y) (intensity)\nchange [x v] by (x)\nchange [y v] by (y)\nset [yspeed v] to [0]\nset [_x v] to [0]\nset [_y v] to [0]\nrepeat (intensity)\n    create clone of (_myself_ v)\nend\n\nwhen I receive [setup v]\nclone [4850] [1750] [5]\nclone [749] [105] [10]\nclone [950] [360] [4]\nclone [166] [] [6]\nclone [66] [909] [8]\nclone [-190] [] [9]\n\ndefine touch\nif <touching (platforms v)?> then\n    change [_y v] by (1)\n    set [yspeed v] to [0]\n    if <(pick random (1) to (25)) = [1]> then\n        set [yspeed v] to [7]\n    end\nelse\n    change [yspeed v] by (-0.5)\n    change [_y v] by (yspeed)\nend\n\n@Still enimies\n\nwhen I receive [tick v]\npos ((x) - (CAMX)) ((y) - (CAMY))\nif <touching (player v)?> then\n    if <(costume [number v]) = [1]> then\n        set [exit v] to [die]\n    else\n        if <(costume [number v]) = [2]> then\n            set [exit v] to [hurt]\n        else\n            set [exit v] to [hurt]\n        end\n    end\nend\n\ndefine pos (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\ndefine clone at: (x) (y) (cost:) (direc)\nchange [x v] by (x)\nchange [y v] by (y)\nset size to (40) %\nif <not <(direc) = []>> then\n    point in direction (direc)\nend\nif <(cost:) = [h.]> then\n    switch costume to (hedgehog2 v)\nelse\n    if <(cost:) = [t]> then\n        switch costume to (takeout-c v)\n    else\n        if <(cost:) = [milk]> then\n            set size to (60) %\n            switch costume to (milk v)\n        else\n            switch costume to (egg-f v)\n        end\n    end\nend\ncreate clone of (_myself_ v)\n\nwhen I receive [setup v]\nset rotation style [left-right v]\nset [x v] to [0]\nset [y v] to [0]\nset [x_ v] to [0]\nset [y_ v] to [0]\nif <(LEVEL) = [1]> then\n    clone at: ((840) + ()) [260] [h.] []\n    repeat (15)\n        clone at: [-30] [0] [h.] []\n    end\n    clone at: [190] [448] [h.] []\n    clone at: [2350] [725] [t] [-90]\n    clone at: [259] [355] [h.] []\n    clone at: [350] [450] [milk] [90]\n    clone at: [358] [90] [h.] []\n    clone at: [1200] [-160] [t] [-90]\n    clone at: [-221] [-146] [h.] []\n    clone at: [1163] [189] [t] []\n    clone at: [2250] [1544] [] []\nend\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [oohhh... v]\nset [touch control v] to [1]\nswitch costume to (milk-e v)\nwait (.5) seconds\nset [touch control v] to [0]\nset [status v] to [die]\n\nchange [x v] by (50)\n\nwhen I receive [trailor v]\nhide\n\n@bounce\n\nwhen I receive [tick v]\nset rotation style [all around v]\nposition ((x) - (CAMX)) ((y) - (CAMY))\npoint in direction ((90) + ((20) * ([sin v] of ((timer) * (100)) )))\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\ndefine clone at x: (x) y: (y) (cost)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\nif <(cost) = [1]> then\n    switch costume to (costume1 v)\nelse\n    switch costume to (1 v)\nend\nif  then\nend\ncreate clone of (_myself_ v)\n\nwhen I receive [reset v]\ngo to [back v] layer\ngo [forward v] (2) layers\nclear graphic effects\nhide\ndelete this clone\n\nwhen I receive [setup v]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (LEVEL)\n    clone at x: [300] y: [250] []\n    clone at x: [-550] y: [] []\n    clone at x: [-342] y: [220] []\n    clone at x: [1280] y: [340] []\n    clone at x: [1312] y: [370] []\n    clone at x: [1323] y: [615] []\n    clone at x: [-160] y: [230] []\n    clone at x: [2522] y: [-141] []\n    clone at x: [1201] y: [385] []\n    clone at x: [-564] y: [296] [1]\n    clone at x: [2329] y: [1239] [1]\n    clone at x: [-540] y: [304] [1]\nelse\nend\n\nwhen I receive [trailor v]\nhide\n\n@platforms2\n\nwhen I receive [tick v]\npos (((x) + (x_)) - (CAMX)) ((y) - (CAMY))\nchange [x_ v] by ((3) * (.))\nif <([abs v] of (x_) ) > [160]> then\n    if <(x_) > [0]> then\n        set [. v] to [-1]\n    else\n        set [. v] to [1]\n    end\nend\n\ndefine pos (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\ndefine clone at: (x) (y) (cost)\nchange [x v] by (x)\nchange [y v] by (y)\ncreate clone of (_myself_ v)\n\nwhen I receive [setup v]\nset [. v] to [1]\nset [x v] to [0]\nset [y v] to [0]\nset [x_ v] to [0]\nset [y_ v] to [0]\nif <(LEVEL) = [1]> then\n    clone at: [660] [360] []\n    clone at: [-740] [360] []\n    clone at: [4000] [1550] []\nend\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [trailor v]\nhide\n\n@thumbnail\n\nwhen flag clicked\nhide\n\n@TRAILOR BACKGROUND\n\nwhen I receive [trailor v]\nswitch costume to (costume1 v)\ngo to [front v] layer\ngo [backward v] (1) layers\nset [slide v] to [0]\nshow\nrepeat until <(slide) = [5]>\n    broadcast (tick2 v)\n    wait (4.5) seconds\n    if <(slide) = [5]> then\n        hide\n        stop [this script v]\n    end\n    ghost [1]\n    change [slide v] by (1)\n    next costume\n    ghost [-1]\nend\nhide\n\ndefine ghost (-/+)\nrepeat (30)\n    change [ghost v] effect by ((-/+) * (3))\nend\n\nwhen I receive [green flag v]\nhide\n\n@GAME border\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [setup v]\nswitch costume to (costume1 v)\ngo to x: (0) y: (0)\nshow\n\nwhen I receive [end point v]\nswitch costume to (costume2 v)\n\nwhen I receive [switch v]\nswitch costume to (costume3 v)\nwait (2) seconds\nnext costume\n\n@STOMPER\n\nwhen I receive [tick v]\nif <([direction v] of [player v]) = [90]> then\n    go to x: (([x position v] of [player v]) - (-6)) y: (([y position v] of [player v]) - (30))\nelse\n    go to x: (([x position v] of [player v]) - (6)) y: (([y position v] of [player v]) - (30))\nend\nif <touching (platforms2 v)?> then\n    set [mov- v] to [on]\n    broadcast (movement on sprtie v)\nelse\n    set [mov- v] to [off]\nend\n\nwhen I receive [trailor v]\nhide\n\nwhen I receive [begin! v]\nshow\nset [ghost v] effect to (100)\n\n@Sprite1\n\nwhen I receive [trailor v]\nhide variable [☁ highscore v]\nhide variable [time v]\nhide\n\nwhen I receive [show final score v]\nshow variable [☁ highscore v]\nshow\ngo to [front v] layer\ngo [backward v] (1) layers\nshow variable [time v]\nif <(TIME) < (☁ highscore)> then\n    set [☁ highscore v] to (TIME)\nend\n\nwhen flag clicked\nhide variable [time v]\nhide\n\n