[RESHARE] Welcome To Platformers - A Scrolling Platformer

Instructions: With bug fixes and more.\n------------------------------------------------------------------------\nUse arrow keys to move. You can wall jump.\nSpikes are bad.\nTrampolines let you bounce higher.\nCollect coins.\nPlease report any glitches back to me. \nIt is a new game.\n

@Stage\n\n@Collectables\n\ndefine show total\nset [collect display v] to (join (COLLECTED) (join [ of ] (COLLECTED MAX)))\n\ndefine Clone at x: (x) y: (y)\nset [x v] to (x)\nset [y v] to (y)\nchange [collected max v] by (1)\ncreate clone of (_myself_ v)\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [setup v]\nif <(RECORDER) = [play]> then\n    switch costume to (dot2 v)\nelse\n    switch costume to (dot v)\nend\nset [collected v] to [0]\nset [collected max v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    Clone at x: (-100) y: (-100)\nelse\n    if <(LEVEL) = [2]> then\n        Clone at x: (3000) y: (0)\n    else\n        if <(LEVEL) = [3]> then\n            Clone at x: (0) y: (0)\n            Clone at x: (-100) y: (0)\n            Clone at x: (-200) y: (0)\n            Clone at x: (-200) y: (100)\n            Clone at x: (-200) y: (200)\n            Clone at x: (-200) y: (300)\n            Clone at x: (-200) y: (400)\n            Clone at x: (-200) y: (500)\n            Clone at x: (-200) y: (600)\n            Clone at x: (200) y: (0)\n            Clone at x: (200) y: (100)\n            Clone at x: (500) y: (300)\n            Clone at x: (700) y: (300)\n            Clone at x: (700) y: (300)\n            Clone at x: (850) y: (300)\n            Clone at x: (850) y: (400)\n            Clone at x: (850) y: (500)\n            Clone at x: (850) y: (600)\n            Clone at x: (850) y: (700)\n            Clone at x: (850) y: (800)\n            Clone at x: (850) y: (900)\n            Clone at x: (1000) y: (950)\n            Clone at x: (1200) y: (950)\n            Clone at x: (1200) y: (950)\n            Clone at x: (1600) y: (1000)\n            Clone at x: (1700) y: (1050)\n            Clone at x: (2000) y: (1000)\n            Clone at x: (2100) y: (1150)\n            Clone at x: (2200) y: (1150)\n            Clone at x: (2300) y: (1150)\n            Clone at x: (2400) y: (1150)\n            Clone at x: (2500) y: (1150)\n            Clone at x: (2600) y: (1150)\n            Clone at x: (850) y: (0)\n            Clone at x: (850) y: (-50)\n            Clone at x: (950) y: (-50)\n            Clone at x: (1050) y: (-50)\n            Clone at x: (1150) y: (-50)\n            Clone at x: (1250) y: (-50)\n            Clone at x: (1250) y: (-50)\n            Clone at x: (950) y: (150)\n            Clone at x: (950) y: (250)\n            Clone at x: (1050) y: (250)\n            Clone at x: (1150) y: (250)\n            Clone at x: (1250) y: (250)\n            Clone at x: (1350) y: (250)\n            Clone at x: (950) y: (550)\n            Clone at x: (950) y: (600)\n            Clone at x: (950) y: (650)\n            Clone at x: (950) y: (750)\n            Clone at x: (950) y: (850)\n        end\n    end\nend\nset [x v] to [-99999]\nshow total\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) (((y) + ((5) * ([sin v] of (((x) + (TICK)) * (10)) ))) - (SCROLL Y))\nif <touching (player v)?> then\n    change [collected v] by (1)\n    show total\n    if <(COLLECTED) = (COLLECTED MAX)> then\n        broadcast (Open Portal v)\n    end\n    delete this clone\nend\n\ndefine position (x) (y)\nset size to (200) %\ngo to x: (x) y: (y)\nset size to (100) %\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\n@Danger\n\ndefine New Platform (costume) at x: (x) y: (y)\ncreate clone of (_myself_ v)\nset [x v] to (x)\nset [y v] to (y)\nswitch costume to (costume)\n\nwhen I receive [post tick v]\nif <(EDITOR) > [0]> then\n    if <<mouse down?> and <touching (mouse-pointer v)?>> then\n        Drag ((x) - (mouse x)) ((y) - (mouse y)) orig (x) (y)\n    end\nend\n\ndefine Drag (ox) (oy) orig (x) (y)\nrepeat until <not <mouse down?>>\n    set [x v] to ((ox) + (mouse x))\n    set [y v] to ((oy) + (mouse y))\n    position ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nend\nDebug Position [0] [0]\nshow variable [mouse v]\n\ndefine Debug Position (ox) (oy)\nset [mouse v] to (join (costume [name v]) (join [ at x,y: ] (join ((x) - (ox)) (join [, ] ((y) - (oy))))))\n\nNew Platform [Spike1] at x: [2319] y: [954]\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\ndefine position (x) (y)\nset size to (200) %\ngo to x: (x) y: (y)\nset size to (100) %\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\nwhen I receive [setup v]\nhide\nset [x v] to [-99999]\nif <(LEVEL) = [1]> then\n    New Platform [nothing] at x: [0] y: [0]\nelse\n    if <(LEVEL) = [2]> then\n        New Platform [2 2] at x: [500] y: [23]\n        New Platform [Test4] at x: [1000] y: [-5]\n    else\n        if <(LEVEL) = [3]> then\n            New Platform [Spears] at x: [1200] y: [100]\n        end\n    end\nend\n\n@Enemies\n\ndefine move enemy <clamp?>\nset [x v] to (round ((orig x) + ((move x) * ([abs v] of (((((TICK) / (div)) + (offset)) mod (2)) - (1)) ))))\nset [y v] to (round ((orig y) + ((move y) * ([abs v] of (((((TICK) / (div)) + (offset)) mod (2)) - (1)) ))))\nPosition\nif <clamp?> then\n    if <<(visible) > [0]> and <touching (platforms v)?>> then\n        repeat (12)\n            change [y v] by (1)\n            Position\n            if <not <touching (platforms v)?>> then\n                stop [this script v]\n            end\n        end\n    end\nend\n\ndefine Position\nposition at ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\ndefine Stuck! (x) (y)\nset [distance v] to [2]\nrepeat (12)\n    set [angle v] to [0]\n    repeat (8)\n        set [x v] to ((x) + ((distance) * ([sin v] of (angle) )))\n        set [y v] to ((y) + ((distance) * ([cos v] of (angle) )))\n        Position\n        if <<(visible) > [0]> and <not <touching (platforms v)?>>> then\n            stop [this script v]\n        end\n        change [angle v] by (45)\n    end\n    change [distance v] by (2)\nend\nset [x v] to (x)\nset [y v] to (y)\nPosition\n\ndefine New Enemy (costume) at x, y: (x) (y)\ncreate clone of (_myself_ v)\nset rotation style [left-right v]\nswitch costume to (costume)\nset [type v] to [1]\nset [x v] to (x)\nset [y v] to (y)\nset [orig x v] to (x)\nset [orig y v] to (y)\n\ndefine then glide (time) secs to x: (x) y: (y)\nset [type v] to [2]\nset [orig x v] to (x)\nset [orig y v] to (y)\nset [move x v] to ((x) - (x))\nset [move y v] to ((y) - (y))\nset [div v] to ((30) * (time))\nset [offset v] to [0]\n\ndefine then rotate (time) secs\nset rotation style [all around v]\nset [type v] to [4]\nset [div v] to ((360) / ((time) * (30)))\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [setup v]\nhide\nset [type v] to []\nif <(LEVEL) = [1]> then\nelse\n    if <(LEVEL) = [2]> then\nend\n\nNew Enemy [Big Green] at x, y: [159] [40]\nthen glide [2.5] secs to x: [308] y: [40]\nNew Enemy [Big Green] at x, y: [1920] [-75]\nthen glide [3] secs to x: [1741] y: [-75]\n\nwhen I receive [post tick v]\nif <(type) > []> then\n    if <<(type) = [2]> or <(type) = [3]>> then\n        move enemy <(type) = [2]>\n    else\n        if <(type) = [4]> then\n            point in direction ((TICK) * (div))\n        end\n    end\n    Position\n    if <touching (player v)?> then\n        set [exit v] to [die]\n    end\nend\n\ndefine position at (x) (y)\nset size to (200) %\ngo to x: (x) y: (y)\nset size to (100) %\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\n    set [visible v] to [1]\nelse\n    hide\n    set [visible v] to [0]\nend\n\n@Joystick\n\nwhen flag clicked\nhide\nshow list [share v]\ndelete all of [share v]\nhide variable [user v]\nset [rec tick v] to []\nset [joy timer v] to [1]\nset [joy orig x v] to []\nset size to (130) %\ngo to x: (-174) y: (-116)\nswitch costume to (background v)\ncreate clone of (_myself_ v)\nswitch costume to (joystick v)\n\nwhen I receive [joystick v]\ntick\n\nwhen I receive [setup v]\ngo to [front v] layer\n\nwhen I receive [reset v]\ngo to [front v] layer\n\ndefine tick\nif <(RECORDER) = [play]> then\n    if <(rec tick) > []> then\n        if <(item (rec idx) of [recording v]) = (rec tick)> then\n            play (item ((rec idx) + (1)) of [recording v])\n        end\n        change [rec tick v] by (1)\n    end\nelse\n    if <<mouse down?> and <(EDITOR) < [1]>> then\n        if <(Joy Timer) > [-20]> then\n            set [ghost v] effect to (50)\n            if <(Joy Timer) > [0]> then\n                show\n            end\n        end\n        set [joy timer v] to [-20]\n        if <(Joy Orig X) = []> then\n            set [joy orig x v] to (mouse x)\n            set [joy orig y v] to (mouse y)\n            go to (mouse-pointer v)\n        end\n    else\n        change [joy timer v] by (1)\n        if <(Joy Timer) < [0]> then\n            change [ghost v] effect by (20)\n        else\n            if <(Joy Timer) = [0]> then\n                hide\n            end\n        end\n        if <not <(Joy Orig X) = []>> then\n            go to x: (Joy Orig X) y: (Joy Orig Y)\n            set [joy orig x v] to []\n        end\n    end\n    if <(costume [number v]) = [2]> then\n        set [joy x v] to [0]\n        set [joy y v] to [0]\n        if <mouse down?> then\n            go to x: (Joy Orig X) y: (Joy Orig Y)\n            point towards (mouse-pointer v)\n            set [power v] to (distance to [mouse-pointer v])\n            if <(power) > ((size) / (4))> then\n                set [power v] to ((size) / (4))\n            end\n            move (power) steps\n            if <(power) > [14]> then\n                if <<(direction) > [-60]> and <(direction) < [60]>> then\n                    set [joy y v] to [1]\n                else\n                    if <<(direction) < [-120]> or <(direction) > [120]>> then\n                        set [joy y v] to [-1]\n                    end\n                end\n                if <<(direction) > [30]> and <(direction) < [150]>> then\n                    set [joy x v] to [1]\n                else\n                    if <<(direction) > [-150]> and <(direction) < [-30]>> then\n                        set [joy x v] to [-1]\n                    end\n                end\n            else\n                set [digital dir v] to []\n            end\n        else\n            set [power v] to [0]\n            set [digital dir v] to []\n        end\n        if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n            set [joy y v] to [1]\n        end\n        if <<key (down arrow v) pressed?> or <key (s v) pressed?>> then\n            set [joy y v] to [-1]\n        end\n        if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n            set [joy x v] to [-1]\n        end\n        if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n            set [joy x v] to [1]\n        end\n    end\n    if <(RECORDER) = [record]> then\n        if <not <<(rec x) = (Joy X)> and <(rec y) = (Joy Y)>>> then\n            record\n        end\n        change [rec tick v] by (1)\n    end\nend\n\nwhen I receive [recording - start v]\nset [rec x v] to [0]\nset [rec y v] to [0]\nset [rec tick v] to [0]\nset [rec idx v] to [1]\nset [joy x v] to [0]\nset [joy y v] to [0]\nif <(RECORDER) = [record]> then\n    delete all of [recording v]\n    hide variable [user v]\nend\n\ndefine record\nadd (rec tick) to [recording v]\nif <(Joy X) > [0]> then\n    if <(Joy Y) > [0]> then\n        add [9] to [recording v]\n    else\n        if <(Joy Y) = [0]> then\n            add [6] to [recording v]\n        else\n            add [3] to [recording v]\n        end\n    end\nelse\n    if <(Joy X) = [0]> then\n        if <(Joy Y) > [0]> then\n            add [8] to [recording v]\n        else\n            if <(Joy Y) = [0]> then\n                add [5] to [recording v]\n            else\n                add [2] to [recording v]\n            end\n        end\n    else\n        if <(Joy Y) > [0]> then\n            add [7] to [recording v]\n        else\n            if <(Joy Y) = [0]> then\n                add [4] to [recording v]\n            else\n                add [1] to [recording v]\n            end\n        end\n    end\nend\nset [rec x v] to (Joy X)\nset [rec y v] to (Joy Y)\nset [rec tick v] to [0]\n\ndefine play (a)\nif <(a) < [4]> then\n    set [joy y v] to [-1]\nelse\n    if <(a) < [7]> then\n        set [joy y v] to [0]\n    else\n        set [joy y v] to [1]\n    end\nend\nif <((a) mod (3)) = [1]> then\n    set [joy x v] to [-1]\nelse\n    if <((a) mod (3)) = [2]> then\n        set [joy x v] to [0]\n    else\n        set [joy x v] to [1]\n    end\nend\nset [rec tick v] to [0]\nchange [rec idx v] by (2)\n\nset [recorder v] to [record]\n\nset [recorder v] to [play]\n\ndefine Save Recording\nset [encode v] to []\nset [rec idx v] to [1]\nrepeat ((length of [recording v]) / (2))\n    set [i v] to (item (rec idx) of [recording v])\n    change [rec idx v] by (1)\n    repeat until <(i) < [100]>\n        set [encode v] to (join (encode) (join [99] (item (rec idx) of [recording v])))\n        change [i v] by (-99)\n    end\n    if <(length of (i)) < [2]> then\n        set [encode v] to (join (encode) [0])\n    end\n    set [encode v] to (join (encode) (join (i) (item (rec idx) of [recording v])))\n    change [rec idx v] by (1)\nend\n\nwhen I receive [recording - save  v]\nSave Recording\nreplace item ((LEVEL) * (2)) of [saves v] with (encode)\ndelete all of [share v]\nadd [Griffpatch will manually add your recording to the project soon...] to [share v]\nadd (encode) to [share v]\nhide list [share v]\nset [i v] to [1]\nset [rec idx v] to []\nrepeat until <(i) > (length of (encode))>\n    if <(length of (rec idx)) = [256]> then\n        wait (0.15) seconds\n        set [☁ snapshot v] to (rec idx)\n        set [rec idx v] to []\n    end\n    set [rec idx v] to (join (rec idx) (letter (i) of (encode)))\n    change [i v] by (1)\nend\nwait (0.15) seconds\nif <(length of (rec idx)) > [0]> then\n    set [☁ snapshot v] to (rec idx)\nend\n\ndelete all of [share v]\nadd (encode) to [share v]\nhide list [share v]\n\nwhen I receive [level chosen v]\nshow list [share v]\ndelete all of [share v]\nif <(RECORDER) = [record]> then\n    hide variable [user v]\nend\n\ndefine Load Recording\ndelete all of [recording v]\nset [encode v] to (item ((LEVEL) * (2)) of [saves v])\nset [user v] to (join [Recording by ] (item (((LEVEL) * (2)) - (1)) of [saves v]))\nshow variable [user v]\nset [i v] to [1]\nrepeat ((length of (encode)) / (3))\n    add ((0) + (join (letter (i) of (encode)) (letter ((i) + (1)) of (encode)))) to [recording v]\n    add ((0) + (letter ((i) + (2)) of (encode))) to [recording v]\n    change [i v] by (3)\nend\n\nwhen I receive [recording - load v]\ndelete all of [recording v]\nLoad Recording\n\nwhen [z v] key pressed\n\nchange [rec tick v] by (-1)\n\n@Exit\n\nwhen I receive [open portal v]\nswitch costume to (open v)\n\ndefine Clone at x: (x) y: (y)\nset [x v] to (x)\nset [y v] to (y)\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [setup v]\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (closed v)\n    Clone at x: (4800) y: (400)\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (closed v)\n        Clone at x: (3700) y: (1000)\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (closed v)\n            Clone at x: (2700) y: (1000)\n        else\n            switch costume to (closed v)\n            Clone at x: (100000000000000000000) y: (-50)\n            set [x v] to [-99999]\n        end\n    end\nend\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <<(costume [name v]) = [Open]> and <touching (player v)?>> then\n    set [exit v] to [win]\nend\n\ndefine position (x) (y)\nset size to (200) %\ngo to x: (x) y: (y)\nset size to (100) %\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\n@Player\n\ndefine Show Time\nset [time v] to ((round (time100)) / (100))\nif <(letter ((length of (TIME)) - (1)) of (TIME)) = [.]> then\n    set [time v] to (join (TIME) [0])\nelse\n    if <not <(letter ((length of (TIME)) - (2)) of (TIME)) = [.]>> then\n        set [time v] to (join (TIME) [.00])\n    end\nend\n\nwhen I receive [green flag v]\nhide\npoint in direction (-90)\ngo to [front v] layer\nset [debug v] to [0]\n\nwhen I receive [play game v]\nset [resettime v] to [0]\nforever\n    broadcast (reset v) and wait\n    set [tick v] to [0]\n    set [time100 v] to (resetTime)\n    set [state v] to []\n    Game On\n    broadcast (setup v) and wait\n    broadcast (tick v) and wait\n    broadcast (Recording - start v) and wait\n    show\n    repeat until <(EXIT) > []>\n        change [tick v] by (1)\n        if <(state) > []> then\n            change [time100 v] by (3.33333)\n        end\n        Show Time\n        if <(debug) > [0]> then\n            wait until <key (space v) pressed?>\n            wait until <not <key (space v) pressed?>>\n        end\n        broadcast (Joystick v)\n        broadcast (begin loop v)\n        broadcast (pre-tick v)\n        broadcast (local tick v)\n        broadcast (tick v)\n        broadcast (post tick v)\n        wait (0) seconds\n    end\n    if <(EXIT) = [win]> then\n        Game - Win\n    else\n        Game - Die\n    end\nend\n\nbroadcast (post tick v) and wait\n\ndefine Game On\nset [x v] to [-200]\nset [y v] to [0]\n\n    set [x v] to [1656]\n    set [y v] to [850]\nend\nset [scroll x v] to (x)\nset [scroll y v] to (y)\nset [sx v] to [0]\nset [sy v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nset [impulse y v] to []\nset size to (100) %\nset [ghost v] effect to (0)\n\ndefine Position\ngo to x: ((x) - (SCROLL X)) y: ((y) - (SCROLL Y))\n\ndefine Tick\nif <(IMPULSE Y) > []> then\n    Touching Platform: out (1)\nend\nHandle Platforms (x) (y)\nif <(EXIT) > []> then\n    stop [this script v]\nend\nif <(IMPULSE Y) > []> then\n    change [sx v] by (IMPULSE X)\n    change [sy v] by (IMPULSE Y)\n    set [impulse y v] to []\n    set [in air v] to [10]\nelse\n    if <([joy y v] of [joystick v]) > [0]> then\n        if <<(in air) < [2]> or <<(sy) > [8]> and <(in air) < [4]>>> then\n            set [sy v] to [15]\n        end\n    end\nend\nchange [sy v] by (-2)\nif <(sy) < [-24]> then\n    set [sy v] to [-24]\nend\nChange Player y by (sy)\nset [sx v] to (((sx) * (0.8)) + ((PLATFORM SX) * (0.2)))\nif <([joy x v] of [joystick v]) < [0]> then\n    change [sx v] by (-2)\n    set [state v] to [1]\nend\nif <([joy x v] of [joystick v]) > [0]> then\n    change [sx v] by (2)\n    set [state v] to [1]\nend\nif <([abs v] of ((sx) - (PLATFORM SX)) ) > [1.5]> then\n    Change Player x by (round (sx))\nelse\n    Change Player x by (round (PLATFORM SX))\nend\nif <(x) < [-230]> then\n    set [x v] to [-230]\nend\nPosition\nTest - Die\n\ndefine Change Player x by (sx)\nchange [x v] by (sx)\nPosition\nif <touching (platforms v)?> then\n    repeat (12)\n        change [y v] by (1)\n        Position\n        if <not <touching (platforms v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    repeat until <not <touching (platforms 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\n    if <<([joy y v] of [joystick v]) > [0]> and <(in air) > [6]>> then\n        change y by (2)\n        if <touching (platforms v)?> then\n            set [sx v] to [0]\n        else\n            set [sx v] to (((sx) / ([abs v] of (sx) )) * (-18))\n            set [sy v] to [15]\n            set [in air v] to [0]\n        end\n    else\n        set [sx v] to [0]\n    end\n    if <touching color (#5fff03)?> then\n        broadcast (animation v)\n    end\nend\n\ndefine Game - Die\nset [exit v] to []\nrepeat (5)\n    hide\n    wait (0.1) seconds\n    show\n    wait (0.1) seconds\nend\nhide\nwait (0.5) seconds\n\ndefine Change Player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nPosition\nif <touching (platforms v)?> then\n    if <touching color (#5fff03)?> then\n        broadcast (animation v)\n    end\n    if <(sy) > [0]> then\n        Touching Platform: out (-1)\n    else\n        Touching Platform: out (1)\n    end\nend\n\ndefine Test - Die\nif <touching (danger v)?> then\n    set [exit v] to [die]\nend\n\ndefine Touching Platform: out (out)\nchange [y v] by (out)\nPosition\nrepeat until <not <touching (platforms v)?>>\n    change [y v] by (out)\n    Position\nend\nset [sy v] to [0]\nif <(out) > [0]> then\n    set [in air v] to [0]\nend\n\ndefine Game - Win\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\nbroadcast (Game Won v)\n\nwhen I receive [local tick v]\nTick\nScroll Stage\n\nwhen I receive [begin loop v]\nset [platform sx v] to [0]\nset [platform sy v] to [0]\n\ndefine Handle Platforms (x) (y)\nchange [y v] by (PLATFORM SY)\nPosition\nif <touching (platforms v)?> then\n    set [distance v] to [1]\n    repeat (8)\n        set [angle v] to [0]\n        repeat (8)\n            set [x v] to (round ((x) + ((distance) * ([sin v] of (angle) ))))\n            set [y v] to (round ((y) + ((distance) * ([cos v] of (angle) ))))\n            Position\n            if <not <touching (platforms v)?>> then\n                stop [this script v]\n            end\n            change [angle v] by (45)\n        end\n        change [distance v] by (1)\n    end\n    set [x v] to (x)\n    set [y v] to (y)\n    Position\n    set [exit v] to [die]\nend\n\ndefine Scroll Stage\nset [scroll x v] to (x)\nif <(SCROLL X) < [0]> then\n    set [scroll x v] to [0]\nend\nchange [scroll y v] by (round (((y) - (SCROLL Y)) / (10)))\nif <((y) - (SCROLL Y)) < [-100]> then\n    set [scroll y v] to ((y) + (100))\nend\nif <(SCROLL Y) < [0]> then\n    set [scroll y v] to [0]\nend\nPosition\nif <(y) < [-180]> then\n    set [exit v] to [die]\nend\n\nset [editor v] to [1]\n\nset [resettime v] to (time100)\nchange [level v] by (1)\nwait (1) seconds\n\nwhen I receive [game won v]\nstop [other scripts in sprite v]\n\nset [editor v] to [0]\n\nset [recorder v] to [record]\n\n@Platforms\n\ndefine z get direction (dx) (dy)\nif <(dy) = [0]> then\n    if <(dx) > [0]> then\n        set [p dir v] to [90]\n    else\n        set [p dir v] to [-90]\n    end\nelse\n    set [p dir v] to ([atan v] of ((dx) / (dy)) )\n    if <(dy) < [0]> then\n        if <(dx) > [0]> then\n            change [p dir v] by (180)\n        else\n            if <(dx) < [0]> then\n                change [p dir v] by (-180)\n            else\n                set [p dir v] to [180]\n            end\n        end\n    end\nend\nset [p radius v] to (([sqrt v] of (((dx) * (dx)) + ((dy) * (dy))) ) / (2))\n\nwhen I receive [pre-tick v]\nif <(typ) > [0]> then\n    if <(typ) = [1]> then\n        Type 1 move ((p radius) * ([cos v] of (((TICK) * (p timer)) + (p offset)) ))\n    else\n        if <(typ) = [2]> then\n            if <(p timer) > [0]> then\n                change [p timer v] by (-1)\n                if <(p timer) = [0]> then\n                    switch costume to (tramp v)\n                end\n            else\n                position (((x) - (SCROLL X)) - (3)) (((y) - (SCROLL Y)) + (2))\n                if <touching (player v)?> then\n                    position (((x) - (SCROLL X)) + (3)) (((y) - (SCROLL Y)) + (2))\n                    if <touching (player v)?> then\n                        switch costume to (extend v)\n                        set [impulse x v] to ((p radius) * ([sin v] of (p dir) ))\n                        set [impulse y v] to ((p radius) * ([cos v] of (p dir) ))\n                        set [p timer v] to (p offset)\n                    end\n                end\n                position ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n            end\n        else\n            if <(typ) = [3]> then\n                pre-tick Cloud\n            end\n        end\n    end\nend\n\ndefine reposition (x) (y)\nif <(visible) = [1]> then\n    position ((x) - (SCROLL X)) (((y) - (SCROLL Y)) + (4))\n    if <touching (player v)?> then\n        set [platform sx v] to ((x) - (x))\n        set [platform sy v] to ((y) - (y))\n        if <(p offset) < [0]> then\n            set [p offset v] to (((0) - ((TICK) * (p timer))) mod (360))\n        end\n    else\n        position ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n        if <touching (player v)?> then\n            set [platform sx v] to ((x) - (x))\n            set [platform sy v] to ((y) - (y))\n        end\n    end\n    position ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nend\nset [x v] to (x)\nset [y v] to (y)\n\nwhen I receive [post tick v]\nif <(EDITOR) > [0]> then\n    if <<mouse down?> and <touching (mouse-pointer v)?>> then\n        Drag ((x) - (mouse x)) ((y) - (mouse y)) orig (x) (y)\n    end\nend\n\ndefine Drag (ox) (oy) orig (x) (y)\nrepeat until <not <mouse down?>>\n    set [x v] to ((ox) + (mouse x))\n    set [y v] to ((oy) + (mouse y))\n    position ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nend\nchange [origin x v] by ((x) - (x))\nchange [origin y v] by ((y) - (y))\nif <(typ) = [1]> then\n    Debug Position ((p radius) * ([sin v] of (p dir) )) ((p radius) * ([cos v] of (p dir) ))\nelse\n    Debug Position [0] [0]\nend\nshow variable [mouse v]\n\ndefine New Platform (costume) at x: (x) y: (y)\ncreate clone of (_myself_ v)\nset [x v] to (x)\nset [y v] to (y)\nset [origin x v] to (x)\nset [origin y v] to (y)\nset [typ v] to [0]\nset [p timer v] to [0]\nswitch costume to (costume)\n\ndefine Type 1 move (dist)\nif <(p offset) < [0]> then\n    reposition (x) (y)\nelse\n    reposition ((origin x) - (round ((dist) * ([sin v] of (p dir) )))) ((origin y) - (round ((dist) * ([cos v] of (p dir) ))))\nend\n\ndefine Debug Position (ox) (oy)\nset [mouse v] to (join (costume [name v]) (join [ at x,y: ] (join ((origin x) - (ox)) (join [, ] ((origin y) - (oy))))))\n\ndefine New Glider (costume) start xy: (x) (y) to xy: (x2) (y2) time: (time)\nNew Platform (costume) at x: (x) y: (y)\nset [typ v] to [1]\nz get direction ((x2) - (x)) ((y2) - (y))\nset [p timer v] to ((360) / ((time) * (30)))\nchange [origin x v] by (round ((p radius) * ([sin v] of (p dir) )))\nchange [origin y v] by (round ((p radius) * ([cos v] of (p dir) )))\nset [p offset v] to [0]\n\ndefine New Trampoline xy: (x) (y) power (sy)\nNew Platform [tramp] at x: (x) y: (y)\nset [typ v] to [2]\nset [p dir v] to (dir)\nset [p radius v] to (sy)\nset [p offset v] to [20]\n\nchange [p timer v] by (-1)\n\ndefine pre-tick Cloud\nif <(p timer) > [0]> then\n    if <(y) > ((origin y) - (10))> then\n        reposition (x) ((y) - (1))\n        change [ghost v] effect by (8)\n    else\n        if <(p timer) = (p offset)> then\n            switch costume to (blank v)\n        end\n        change [p timer v] by (-1)\n        if <(p timer) = [0]> then\n            switch costume to (p radius)\n            if <touching (player v)?> then\n                switch costume to (blank v)\n                set [p timer v] to [1]\n            end\n        end\n    end\nelse\n    position ((x) - (SCROLL X)) (((y) - (SCROLL Y)) + (3))\n    if <touching (player v)?> then\n        set [p timer v] to (p offset)\n    else\n        if <(y) < (origin y)> then\n            reposition (x) ((y) + (1))\n            change [ghost v] effect by (-8)\n        end\n    end\n    position ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nend\n\ndefine New Temporary Platform (costume) at x: (x) y: (y) wait (seconds)\nNew Platform (costume) at x: (x) y: (y)\nset [typ v] to [3]\nset [p offset v] to (seconds)\nset [p radius v] to (costume [name v])\n\ndefine ... wait for touching\nset [p offset v] to [-1]\n\nNew Platform [1 2] at x: [500] y: [0]\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\ndefine position (x) (y)\nset size to (150) %\ngo to x: (x) y: (y)\nset size to (100) %\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\nwhen I receive [setup v]\nclear graphic effects\nset [typ v] to [-1]\nset [visible v] to [0]\nset [p timer v] to [0]\nset [visible v] to [1]\nset [x v] to [-99999]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    New Platform [1 1] at x: [0] y: [0]\n    New Platform [1 2] at x: [500] y: [0]\n    New Platform [1 3] at x: [1000] y: [0]\n    New Platform [1 4] at x: [1500] y: [0]\n    New Platform [1 5] at x: [2000] y: [0]\n    New Platform [1 6] at x: [2500] y: [0]\n    New Platform [1 7] at x: [3000] y: [0]\n    New Platform [1 8] at x: [3500] y: [300]\n    New Platform [1 9] at x: [4000] y: [300]\n    New Platform [1 10] at x: [4500] y: [300]\nelse\n    if <(LEVEL) = [2]> then\n        New Platform [2 1] at x: [0] y: [0]\n        New Platform [2 2] at x: [500] y: [0]\n        New Platform [2 3] at x: [1000] y: [0]\n        New Trampoline xy: [970] [-110] power [30]\n        New Platform [2 4] at x: [1500] y: [0]\n        New Temporary Platform [cloud] at x: [1500] y: [0] wait [45]\n        New Temporary Platform [cloud] at x: [1650] y: [0] wait [45]\n        New Temporary Platform [cloud] at x: [1800] y: [0] wait [45]\n        New Platform [2 5] at x: [2000 ] y: [0]\n        New Glider [Floating Island] start xy: [1900] [-50] to xy: [2100] [-50] time: [2.5]\n        New Platform [2 6] at x: [2500] y: [0]\n        New Glider [Floating Island] start xy: [2400] [-70] to xy: [3100] [-70] time: [7.5]\n        ... wait for touching\n        New Platform [2 7] at x: [3000] y: [0]\n        New Platform [2 8] at x: [3500] y: [0]\n        New Trampoline xy: [3700] [-90] power [70]\n    else\n        if <(LEVEL) = [3]> then\n            New Glider [move] start xy: [-200] [1000] to xy: [-200] [-50] time: [15]\n            pre-tick Cloud\n            New Temporary Platform [3 1] at x: [0  ] y: [0] wait [20]\n            New Platform [3 2] at x: [0 ] y: [0]\n            New Glider [3 3] start xy: [100] [100] to xy: [300] [100] time: [3]\n            New Glider [3 4] start xy: [100] [60] to xy: [300] [60] time: [2]\n            New Glider [3 5] start xy: [100] [20] to xy: [300] [20] time: [1.5]\n            New Platform [3 6] at x: [600] y: [300]\n            New Platform [3 7] at x: [1000] y: [300]\n            New Platform [3 8] at x: [1000] y: [0]\n            New Trampoline xy: [1100] [-100] power [70]\n            New Platform [3 9] at x: [1200] y: [320]\n            New Platform [3 10] at x: [950] y: [550]\n            New Glider [3 11] start xy: [1000] [-100] to xy: [1000] [800] time: [10]\n            New Platform [3 12] at x: [1200] y: [1000]\n            New Platform [3 13] at x: [1600] y: [1000]\n            New Platform [3 13] at x: [2000] y: [1000]\n            New Platform [3 13] at x: [2400] y: [1000]\n            New Glider [move2] start xy: [2400] [1000] to xy: [1600] [1000] time: [20]\n        end\n    end\nend\n\n@Splash\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide variable [collect display v]\nhide variable [time v]\nShow Buttons [Splash]\n\nwhen I start as a clone\ngo to [front v] layer\nshow\nforever\n    repeat until <touching (mouse-pointer v)?>\n        wait (0) seconds\n    end\n    set [brightness v] effect to (10)\n    set size to (110) %\n    repeat until <not <touching (mouse-pointer v)?>>\n        if <mouse down?> then\n            set [level v] to (id)\n            if <(costume [name v]) = [Playback]> then\n                set [recorder v] to [play]\n                broadcast (Recording - Load v) and wait\n            else\n                set [recorder v] to [record]\n            end\n            broadcast (Level Chosen v)\n        end\n        wait (0) seconds\n    end\n    set [brightness v] effect to (0)\n    set size to (100) %\nend\n\nwhen I receive [level chosen v]\ndelete this clone\n\ndefine Save High Score\nshow\nif <(RECORDER) = [record]> then\n    switch costume to (level complete v)\n    if <(TIME) > [5]> then\n        if <(LEVEL) = [1]> then\n            if <(TIME) < (☁ Best #1)> then\n                set [☁ best #1 v] to (TIME)\n                switch costume to (best score v)\n                broadcast (Recording - Save  v) and wait\n            end\n        else\n            if <(LEVEL) = [2]> then\n                if <(TIME) < (☁ Best #2)> then\n                    set [☁ best #2 v] to (TIME)\n                    switch costume to (best score v)\n                    broadcast (Recording - Save  v) and wait\n                end\n            else\n                if <(LEVEL) = [3]> then\n                    if <(TIME) < (☁ Best #3)> then\n                        set [☁ best #3 v] to (TIME)\n                        switch costume to (best score v)\n                        broadcast (Recording - Save  v) and wait\n                    end\n                end\n            end\n        end\n    end\nelse\n    switch costume to (best score v)\nend\n\nwhen I receive [game won v]\nSave High Score\nShow Buttons (costume [name v])\n\ndefine Show Buttons (splash costume)\nClone Buttons\ngo to x: (0) y: (0)\nset [id v] to [0]\nswitch costume to (splash costume)\nset [recorder v] to [record]\nrepeat until <(LEVEL) > []>\n    wait (0) seconds\nend\nhide\nbroadcast (green flag v) and wait\nshow variable [collect display v]\nshow variable [time v]\nbroadcast (play game v)\n\nset [☁ best #1 v] to [99.99]\nset [☁ best #2 v] to [99.99]\nset [☁ best #3 v] to [99.99]\n\nhide variable [☁ best #1 v]\nhide variable [☁ best #2 v]\nhide variable [☁ best #3 v]\n\ndefine Clone Buttons\ngo to [front v] layer\nshow\nset [level v] to []\nClone Button [1] x: [-100]\nClone Button [2] x: [30]\nClone Button [3] x: [160]\n\ndefine Clone Button (id) x: (x)\nset [id v] to (id)\nswitch costume to (id)\ngo to x: (x) y: (-130)\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nforever\n    hide variable [☁ best #1 v]\n    hide variable [☁ best #2 v]\n    hide variable [☁ best #3 v]\nend\n\n@Back\n\nwhen I receive [tick v]\ngo to [back v] layer\ngo to x: ((((SCROLL X) * (-0.5)) mod (480)) - (240)) y: ((SCROLL Y) * (-0.5))\n\n@Pie Flavor\n\nwhen I receive [animation v]\nif <(piepie) = [0]> then\n    show\n    go to x: (0) y: (0)\n    broadcast (pie sound v)\n    set [piepie v] to [1]\nend\n\nwhen flag clicked\nset [piepie v] to [0]\nhide\nswitch costume to (asdf frame 1 v)\n\nwhen I receive [pie sound v]\nstart sound [Pie Flavor v]\nrepeat (134)\n    next costume\nend\nwait (1) seconds\nhide\n\n@City Lights2\n\nwhen flag clicked\nhide\nforever\n    play sound [City Lights v] until done\nend\n\n