infinite pen platformer
@Stage\n\n@game\n\nwhen flag clicked\nset [level v] to [1]\nset [zoom v] to ([atan v] of (0.02) )\nreset\nmake level\nforever\n    set [pen size v] to ((10) / (Zoom))\n    set pen size to (pen size)\n    erase all\n    grid\n    render map\n    set pen size to (pen size)\n    render player at (((x) - (cam x)) / (Zoom)) (((y) - (cam y)) / (Zoom)) ((20) / (Zoom))\n    broadcast (physics v)\n    broadcast (text v)\nend\n\ndefine make level\nset [i v] to [0]\ndelete all of [points v]\nadd square at [-50] [-100] [20] [120] [1]\nset [length of level v] to (pick random (20) to (50))\nset [start plat x v] to [-50]\nrepeat (length of level)\n    set [type v] to (pick random (pick random (1) to (pick random (2) to (3))) to (2))\n    add (((item ((i) + (1)) of [points v]) + (item ((i) + (3)) of [points v])) + (pen size)) to [points v]\n    if <(item ((i) + (5)) of [points v]) = [2]> then\n        add ((item ((i) + (2)) of [points v]) - (item ((i) + (4)) of [points v])) to [points v]\n    else\n        add ((item ((i) + (2)) of [points v]) + (item ((i) + (4)) of [points v])) to [points v]\n    end\n    if <(item ((i) + (5)) of [points v]) = [2]> then\n        add (pick random (75) to (100)) to [points v]\n    else\n        if <(type) = [2]> then\n            add (pick random (20) to (75)) to [points v]\n        else\n            add (pick random (20) to (100)) to [points v]\n        end\n    end\n    if <(type) = [2]> then\n        add (pick random (20) to (75)) to [points v]\n    else\n        if <(item ((i) + (5)) of [points v]) = [3]> then\n            add (pick random (200) to (300)) to [points v]\n            set [type v] to (pick random (1) to (2))\n        else\n            add (pick random (20) to (100)) to [points v]\n        end\n    end\n    if <(item ((i) + (5)) of [points v]) = [2]> then\n        add [1] to [points v]\n    else\n        add (type) to [points v]\n    end\n    change [i v] by (5)\nend\nadd square at ((item ((i) + (1)) of [points v]) + (item ((i) + (3)) of [points v])) ((item ((i) + (2)) of [points v]) + (item ((i) + (4)) of [points v])) [20] [20] [4]\nset [length of plat x v] to (((item ((i) + (1)) of [points v]) + (20)) - (start plat x))\n\ndefine add square at (x) (y) (height) (length) (type)\nadd (x) to [points v]\nadd (y) to [points v]\nadd (length) to [points v]\nadd (height) to [points v]\nadd (type) to [points v]\n\ndefine render player at (x) (y) (size)\nset pen color to (#00ffe5)\npen up\ngo to x: (x) y: (y)\npen down\ngo to x: ((x) + (size)) y: (y)\ngo to x: ((x) + (size)) y: ((y) + (size))\ngo to x: (x) y: ((y) + (size))\ngo to x: (x) y: (y)\npen up\n\ndefine reset\nset [y v] to [0]\nset [x v] to [0]\nset [cam x v] to (x)\nset [cam y v] to (y)\nset [sy v] to [0]\nset [sx v] to [0]\nparticles (x) (y) [10] [10] [10] no [30]\n\ndefine render map\nset [i v] to ((length of [particles v]) - (6))\nrepeat ((length of [particles v]) / (6))\n    pen up\n    set pen color to (#ff0000)\n    set pen size to ((item ((i) + (5)) of [particles v]) / ((10) / (pen size)))\n    set pen (color v) to (item ((i) + (6)) of [particles v])\n    go to x: (((item ((i) + (1)) of [particles v]) - (cam x)) / (Zoom)) y: (((item ((i) + (2)) of [particles v]) - (cam y)) / (Zoom))\n    pen down\n    pen up\n    replace item ((i) + (1)) of [particles v] with ((item ((i) + (1)) of [particles v]) + (item ((i) + (3)) of [particles v]))\n    replace item ((i) + (2)) of [particles v] with ((item ((i) + (2)) of [particles v]) + (item ((i) + (4)) of [particles v]))\n    replace item ((i) + (3)) of [particles v] with ((item ((i) + (3)) of [particles v]) * (0.99))\n    replace item ((i) + (4)) of [particles v] with ((item ((i) + (4)) of [particles v]) - (1))\n    if <(item ((i) + (2)) of [particles v]) < ((-700) * (Zoom))> then\n        repeat (6)\n            delete ((i) + (1)) of [particles v]\n        end\n    end\n    change [i v] by (-6)\nend\nset [i v] to [0]\nrepeat ((length of [points v]) / (5))\n    set pen size to (pen size)\n    set [type v] to (item ((i) + (5)) of [points v])\n    if <(type) = [1]> then\n        set pen color to (#8bc414)\n    else\n        if <(type) = [2]> then\n            set pen color to (#ff0000)\n        else\n            if <(type) = [3]> then\n                set pen color to (#eeff00)\n            else\n                if <(type) = [4]> then\n                    set pen color to (#000000)\n                end\n            end\n        end\n    end\n    set [plat height v] to (item ((i) + (4)) of [points v])\n    set [plat length v] to (item ((i) + (3)) of [points v])\n    set [plat x v] to (item ((i) + (1)) of [points v])\n    set [plat y v] to (item ((i) + (2)) of [points v])\n    pen up\n    add line (plat x) (plat y)\n    pen down\n    add line ((plat x) + (plat length)) (plat y)\n    add line ((plat x) + (plat length)) ((plat y) + (plat height))\n    add line (plat x) ((plat y) + (plat height))\n    add line (plat x) (plat y)\n    set pen size to (pen size)\n    change [i v] by (5)\nend\n\nwhen I receive [next level v]\nchange [☁ levels done v] by (1)\nchange [level v] by (1)\nmake level\nreset\n\ndefine add line (x) (y)\ngo to x: (((x) - (cam x)) / (Zoom)) y: (((y) - (cam y)) / (Zoom))\n\ndefine grid\nset [i v] to [-2000]\nset pen color to (#f9f9f9)\nrepeat ((Zoom) * (60))\n    pen up\n    go to x: (-240) y: (() - ((i) + ((cam y) / ((Zoom) * (2)))))\n    pen down\n    go to x: (240) y: (() - ((i) + ((cam y) / ((Zoom) * (2)))))\n    change [i v] by ((60) / (Zoom))\nend\nset [i v] to [-3000]\nset pen color to (#f9f9f9)\nrepeat ((Zoom) * (60))\n    pen up\n    go to x: (() - ((i) + ((cam x) / ((Zoom) * (2))))) y: (180)\n    pen down\n    go to x: (() - ((i) + ((cam x) / ((Zoom) * (2))))) y: (-180)\n    change [i v] by ((60) / (Zoom))\nend\n\ndefine particles (x) (y) (sx) (sy) (s) no (no)\nrepeat (pick random (no) to ((no) + (10)))\n    add (x) to [particles v]\n    add (y) to [particles v]\n    add (pick random (sx) to (() - (sx))) to [particles v]\n    add (pick random ((sy) + (5)) to ((sy) - (10))) to [particles v]\n    add (pick random (s) to ((s) + (10))) to [particles v]\n    add (pick random (0) to (100)) to [particles v]\nend\n\nwhen I receive [reset v]\nreset\n\n@physics\n\nwhen I receive [physics v]\nphysics <<key (left arrow v) pressed?> or <<key (a v) pressed?> or <<mouse down?> and <(mouse x) < (((x) - (cam x)) - (50))>>>> <<key (right arrow v) pressed?> or <<key (d v) pressed?> or <<mouse down?> and <(mouse x) > (((x) - (cam x)) + (50))>>>> <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<mouse down?> and <(mouse y) > (((y) - (cam y)) + (50))>>>>\n\ndefine update\nset [i v] to [0]\ndelete all of [collisions v]\nrepeat ((length of [points v]) / (5))\n    if <<(((x) + (20)) + ((pen size) * (Zoom))) > (item ((i) + (1)) of [points v])> and <((x) - ((pen size) * (Zoom))) < ((item ((i) + (1)) of [points v]) + (item ((i) + (3)) of [points v]))>> then\n        if <<(((y) + (20)) + ((pen size) * (Zoom))) > (item ((i) + (2)) of [points v])> and <((y) - ((pen size) * (Zoom))) < ((item ((i) + (2)) of [points v]) + (item ((i) + (4)) of [points v]))>> then\n            add (item ((i) + (5)) of [points v]) to [collisions v]\n            if <[collisions v] contains [3]?> then\n                set [sy v] to ((25) + (<key (up arrow v) pressed?> * (5)))\n            end\n            if <[collisions v] contains [4]?> then\n                broadcast (next level v)\n            end\n        end\n    end\n    change [i v] by (5)\nend\nif <<(y) < ((-700) * (Zoom))> or <[collisions v] contains [2]?>> then\n    broadcast (reset v)\nend\n\ndefine physics <<> <>> <^>\nchange [cam x v] by (round (((x) - (cam x)) / (20)))\nchange [cam y v] by (round (((y) - (cam y)) / (20)))\nif <<> then\n    change [sx v] by (-1)\nend\nif <>> then\n    change [sx v] by (1)\nend\nset [sx v] to ((sx) * (0.9))\nchange [x v] by (sx)\nupdate\nif <[collisions v] contains [1]?> then\n    change [x v] by ((sx) * (-1))\n    set [sx v] to [0]\nend\nchange [sy v] by (-1)\nchange [y v] by (sy)\nupdate\nif <[collisions v] contains [1]?> then\n    change [y v] by ((sy) * (-1))\n    set [sy v] to (<^> * (15))\nend\nif <<(mouse x) < [-100]> and <(mouse y) < [-140]>> then\n    show variable [zoom v]\nelse\n    hide variable [zoom v]\nend\n\n@Sprite2\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    set [ghost v] effect to (100)\nend\n\n@Sprite1\n\nwhen I receive [physics v]\nposition (((0) - (cam x)) / (Zoom)) (((100) - (cam y)) / (Zoom))\n\ndefine position (x) (y)\nset size to ((120) / (Zoom)) %\ngo to x: (x) y: (y)\nif <<(Level) = [1]> and <<(round (x)) = (round (x position))> and <(round (y)) = (round (y position))>>> then\n    show\n    stamp\n    hide\nend\n\n@text\n\nwhen flag clicked\ndelete all of [letter data v]\nadd [0024244000121232] to [letter data v]\nadd [a] to [letter data v]\nadd [0004042424333322223131202000] to [letter data v]\nadd [b] to [letter data v]\nadd [00202031000404242433] to [letter data v]\nadd [c] to [letter data v]\nadd [000404242433333131202000] to [letter data v]\nadd [d] to [letter data v]\nadd [000404242433333232020030] to [letter data v]\nadd [e] to [letter data v]\nadd [000404340222] to [letter data v]\nadd [f] to [letter data v]\nadd [0003031414242433002020323212] to [letter data v]\nadd [g] to [letter data v]\nadd [000402323034] to [letter data v]\nadd [h] to [letter data v]\nadd [003010140434] to [letter data v]\nadd [i] to [letter data v]\nadd [01101020203131340434] to [letter data v]\nadd [j] to [letter data v]\nadd [040003301234] to [letter data v]\nadd [k] to [letter data v]\nadd [00040030] to [letter data v]\nadd [l] to [letter data v]\nadd [0004042020444440] to [letter data v]\nadd [m] to [letter data v]\nadd [000404303034] to [letter data v]\nadd [n] to [letter data v]\nadd [01101020203131333324241414030301] to [letter data v]\nadd [o] to [letter data v]\nadd [04000424243333222202] to [letter data v]\nadd [p] to [letter data v]\nadd [34303414140303121232] to [letter data v]\nadd [q] to [letter data v]\nadd [040004242433320202303332] to [letter data v]\nadd [r] to [letter data v]\nadd [00303032320202040434] to [letter data v]\nadd [s] to [letter data v]\nadd [10140434] to [letter data v]\nadd [t] to [letter data v]\nadd [01101020203130340104] to [letter data v]\nadd [u] to [letter data v]\nadd [04202034] to [letter data v]\nadd [v] to [letter data v]\nadd [0410102424303044] to [letter data v]\nadd [w] to [letter data v]\nadd [04300034] to [letter data v]\nadd [x] to [letter data v]\nadd [202222342204] to [letter data v]\nadd [y] to [letter data v]\nadd [043434000030] to [letter data v]\nadd [z] to [letter data v]\nadd [003020242403] to [letter data v]\nadd [1] to [letter data v]\nadd [0314142424333332321111000030] to [letter data v]\nadd [2] to [letter data v]\nadd [03141424243333222231312020101001] to [letter data v]\nadd [3] to [letter data v]\nadd [20222202022424222232] to [letter data v]\nadd [4] to [letter data v]\nadd [340404020222223131303000] to [letter data v]\nadd [5] to [letter data v]\nadd [34242402020101101020203131222212] to [letter data v]\nadd [6] to [letter data v]\nadd [04343400] to [letter data v]\nadd [7] to [letter data v]\nadd [03141424243333323202020310010112102020313122] to [letter data v]\nadd [8] to [letter data v]\nadd [031414242433332212221203333232212110] to [letter data v]\nadd [9] to [letter data v]\nadd [01101020203131333324241414030301] to [letter data v]\nadd [0] to [letter data v]\n\ndefine write string (string) colours (o) (r) (b) (g) at (x) (y) w/ size (s) fancy? (f)\ndelete all of [letters decoded v]\nset pen color to (((((((o) * (256)) + (r)) * (256)) + (g)) * (256)) + (b))\nset pen size to (s)\nset [i v] to [0]\nrepeat (length of (string))\n    change [i v] by (1)\n    add (item ((item # of (letter (i) of (string)) in [letter data v]) - (1)) of [letter data v]) to [letters decoded v]\nend\nset [txtno v] to [1]\nset [keel v] to ((x) - ((length of (string)) * ((s) * (2.5))))\nrepeat (length of (string))\n    set [i v] to [0]\n    repeat ((length of (item (txtno) of [letters decoded v])) / (4))\n        if <(f) = [1]> then\n            set [fancy text v] to [0.5]\n            set pen color to (#000000)\n            repeat (2)\n                draw line (((keel) + ((letter ((i) + (1)) of (item (txtno) of [letters decoded v])) * (s))) - (fancy text)) (((y) + ((letter ((i) + (2)) of (item (txtno) of [letters decoded v])) * (s))) - (fancy text)) to (((keel) + ((letter ((i) + (3)) of (item (txtno) of [letters decoded v])) * (s))) - (fancy text)) (((y) + ((letter ((i) + (4)) of (item (txtno) of [letters decoded v])) * (s))) - (fancy text)) [1.2]\n                set pen color to (((((((o) * (256)) + (r)) * (256)) + (g)) * (256)) + (b))\n                set [fancy text v] to [0]\n            end\n        else\n            draw line ((keel) + ((letter ((i) + (1)) of (item (txtno) of [letters decoded v])) * (s))) ((y) + ((letter ((i) + (2)) of (item (txtno) of [letters decoded v])) * (s))) to ((keel) + ((letter ((i) + (3)) of (item (txtno) of [letters decoded v])) * (s))) ((y) + ((letter ((i) + (4)) of (item (txtno) of [letters decoded v])) * (s))) [1.4]\n        end\n        change [i v] by (4)\n    end\n    change [keel v] by ((s) * (5))\n    change [txtno v] by (1)\nend\n\nwhen I receive [text v]\nwrite string (join [cloud levels passed ] (☁ Levels Done)) colours [] [] [] [] at [-60] [-150] w/ size [1.8] fancy? []\nwrite string (join [level ] (Level)) colours [] [] [] [] at [100] [-150] w/ size [2] fancy? []\n\ndefine draw line (x) (y) to (x2) (y2) (s)\ngo to x: ((((x) * (s)) - (cam x)) / (Zoom)) y: ((((y) * (s)) - (cam y)) / (Zoom))\npen down\ngo to x: ((((x2) * (s)) - (cam x)) / (Zoom)) y: ((((y2) * (s)) - (cam y)) / (Zoom))\npen up\n\n@music\n\nwhen flag clicked\nforever\n    play sound [Qa v] until done\nend\n\n