Endless platformer
@Stage\n\nwhen [m v] key pressed\nif <(username) = [vatsalnewar]> then\n    set [mouse v] to (join (mouse x) (join [, ] (mouse y)))\n    show variable [mouse v]\nend\n\ndefine brodcast\nset [layer_idx v] to [1]\nrepeat (length of [layers v])\n    broadcast (item (layer_idx) of [layers v])\n    change [layer_idx v] by (1)\nend\n\nwhen flag clicked\nhide variable [mouse v]\nset [timer v] to [0]\nset [touching v] to [0]\nforever\n    brodcast\nend\n\nwhen I receive [start timer v]\nstart timer [30]\ndelete (item # of (power up) in [power-ups v]) of [power-ups v]\nset [power up v] to []\n\ndefine start timer (timer)\nset [timer v] to (timer)\nrepeat (timer)\n    wait until <(page) = [game]>\n    change [timer v] by (-1)\n    wait (1) seconds\nend\n\n@blank\n\n@ball\n\nwhen flag clicked\nset [y v] to [100]\nhide\npoint in direction (90)\nset [loading v] to [1]\nbroadcast (start loading v)\nbroadcast (green flag v) and wait\nbroadcast (play game v) and wait\n\nbroadcast (green flag v) and wait\nbroadcast (play game v) and wait\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [play game v]\nforever\n    broadcast (reset v) and wait\n    broadcast (setup v) and wait\n    broadcast (hide platforms v)\n    game on\n    repeat until <(exit) > []>\n        if <<(loading) = [0]> and <(page) = [game]>> then\n            tick\n        end\n        change y by (-10)\n        broadcast (tick v) and wait\n    end\nend\n\ndefine game on\nset size to (100) %\nset [sx v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nset [sy v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nbroadcast (game on v)\nset [ghost v] effect to (0)\n\ndefine tick\npoint in direction (90)\nswitch costume to (hitbox v)\nchange [sx v] by ((([right v] of [controls v]) - ([left v] of [controls v])) * (SPEED))\nset [sx v] to ((sx) * (0.8))\nif <([abs v] of (sx) ) > [0.9]> then\n    change player x by (round (sx))\n    change [original direction v] by ((round (sx)) * (2))\nend\nif <([up v] of [controls v]) = [1]> then\n    if <(in air) < [4]> then\n        start sound [Jump v]\n        set [sy v] to (jump)\n    end\nend\nif <(sy) > [-20]> then\n    change [sy v] by (((0) - (GRAVITY)) + (GLIDE))\nend\nchange player y by (sy)\nposition\ntest-die\nset [scroll x v] to (x)\nif <(scroll x) < [-200]> then\n    set [scroll x v] to [-200]\nend\nchange [scroll y v] by (round (((y) - (scroll y)) / (10)))\nposition\nif <(y) < [-280]> then\n    start sound [Oops v]\n    set [exit v] to [die]\nend\npoint in direction (original direction)\nswitch costume to (normal v)\n\ndefine change player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nposition\ntest-die\nrepeat until <not <touching (platform v)?>>\n    if <(sy) > [0]> then\n        change [y v] by (-1)\n    else\n        change [y v] by (1)\n        set [in air v] to [0]\n    end\n    position\n    set [sy v] to [0]\nend\n\ndefine position\ngo to x: ((x) - (scroll x)) y: ((y) - (scroll y))\nset [touching v] to (round <touching color (#867551)?>)\n\ndefine change player x by (sx)\nchange [x v] by (sx)\nposition\ntest-die\nif <touching (platform v)?> then\n    repeat (12)\n        change [y v] by (1)\n        position\n        if <not <touching (platform v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    if <<([up v] of [controls v]) = [1]> and <[1] = [1]>> then\n        if <(sx) > [0]> then\n            set [sx v] to [-16]\n        else\n            set [sx v] to [16]\n        end\n        set [in air v] to [0]\n    else\n        set [sx v] to [0]\n    end\n    repeat until <not <touching (platform 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\nend\n\ndefine test-die\nif <touching (danger v)?> then\n    start sound [Oops v]\n    set [exit v] to [die]\nend\n\ndefine game over\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\nwhen I receive [end loading v]\nshow\nset [loading v] to [0]\n\nwhen flag clicked\ngo to [front v] layer\n\nif <(scroll y) < [0]> then\n    set [scroll y v] to [0]\nend\n\nwhen I receive [tick v]\nset [score v] to ((x) / (10))\nif <(SCORE) > (☁ high score)> then\n    set [☁ high score v] to (SCORE)\nend\n\n@platform\n\nwhen I receive [green flag v]\nswitch costume to (join [0] [])\nset [max costume v] to (costume [number v])\n\nwhen I receive [tick v]\nposition ((x) - (scroll x)) ((y) - (scroll y))\n\nwhen I receive [setup v]\nwait (1) seconds\ngo to [front v] layer\nset [ghost v] effect to (100)\nshow\nset [x v] to [0]\nset [y v] to [0]\nsetup\nbroadcast (setup decor v)\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine clone at x (x) y (y)\nset [color v] effect to (0)\nchange [x v] by (x)\nchange [y v] by (y)\nswitch costume to (costume-decor)\nrepeat (3)\n    if <<touching color (#8be39b)?> or <touching color (#af996b)?>> then\n        change [x v] by (50)\n    end\nend\ncreate clone of (_myself_ v)\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 setup\ndelete all of [costumes v]\ndelete all of [x-spaces v]\ndelete all of [y-spaces v]\nset [costume-decor v] to [1]\nswitch costume to (1 1 v)\nclone at x [0] y [-100]\nrepeat (length)\n    set [costume# v] to (costume [number v])\n    set [costume-decor v] to (pick random (1) to (max costume))\n    add (costume-decor) to [costumes v]\n    add (((item (costume#) of [length v]) / (2)) + (pick random (0) to (400))) to [x-spaces v]\n    add (((item (costume#) of [width v]) / (2)) + (pick random (-200) to (100))) to [y-spaces v]\n    clone at x (item (length of [x-spaces v]) of [x-spaces v]) y (item (length of [y-spaces v]) of [y-spaces v])\nend\n\nwhen flag clicked\nset [length v] to [100]\n\nwhen I receive [hide platforms v]\n\nset [ghost v] effect to (100)\n\n@decor\n\nwhen I receive [green flag v]\nshow\nswitch costume to (join [0] [])\nset [max costume v] to (costume [number v])\n\nwhen I receive [tick v]\nposition ((x) - (scroll x)) ((y) - (scroll y))\n\nwhen I receive [setup decor v]\nshow\nset [x v] to [0]\nset [y v] to [0]\nsetup\nbroadcast (setup danger v)\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine clone at x (x) y (y)\ngo to [back v] layer\nchange [x v] by (x)\nchange [y v] by (y)\ncreate clone of (_myself_ v)\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    if <(loading) = [1]> then\n        hide\n    else\n        show\n    end\nelse\n    hide\nend\n\ndefine setup\nset [# v] to [1]\nswitch costume to (1 1 v)\nclone at x [0] y [-100]\nrepeat (length)\n    switch costume to (item (#) of [costumes v])\n    clone at x (item (#) of [x-spaces v]) y (item (#) of [y-spaces v])\n    change [# v] by (1)\nend\n\n@power-up_shop\n\nwhen flag clicked\ngo to [front v] layer\ngo to x: (0) y: (-200)\nset [id v] to [1]\nswitch costume to (parachute v)\ncreate clone of (_myself_ v)\nset [id v] to [2]\nswitch costume to (enable v)\ncreate clone of (_myself_ v)\nset [id v] to [0]\nswitch costume to (screen v)\n\nwhen I receive [tick v]\nif <(page) = [power]> then\n    show\nelse\n    hide\nend\n\nwhen I receive [check power uo v]\nif <(id) = [1]> then\n    switch costume to (check)\nend\nif <(id) = [2]> then\n    if <(check) = (power up)> then\n        switch costume to (enable2 v)\n    else\n        switch costume to (enable v)\n    end\nend\nglide (0.5) secs to x: (0) y: (0)\n\nwhen I receive [back v]\nglide (0.2) secs to x: (0) y: (-200)\n\nwhen this sprite clicked\nif <(id) = [2]> then\n    if <(costume [name v]) = [enable]> then\n        set [power up v] to (check)\n        broadcast (start timer v)\n    else\n        set [power up v] to []\n    end\n    if <(costume [name v]) = [enable]> then\n        next costume\n    else\n        switch costume to (enable v)\n    end\nend\n\nwhen I receive [screen v]\nif <(id) = [0]> then\n    go to [front v] layer\nend\n\nwhen I receive [power v]\nif <(id) > [0]> then\n    go to [front v] layer\nend\n\nadd [skateboard] to [power-ups v]\n\nset [power up v] to []\n\n@thumbnail\n\nwhen flag clicked\nshow\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\ngo to [front v] layer\n\nshow\ngo to x: (0) y: (0)\nset [ghost v] effect to (0)\ngo to [front v] layer\n\nset [☁ high score v] to [0]\n\n@controls\n\nwhen I receive [end loading v]\nforever\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        set [right v] to [1]\n    else\n        set [right v] to [0]\n    end\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        set [left v] to [1]\n    else\n        set [left v] to [0]\n    end\n    if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n        set [up v] to [1]\n    else\n        set [up v] to [0]\n    end\n    if <<key (down arrow v) pressed?> or <key (s v) pressed?>> then\n        set [down v] to [1]\n    else\n        set [down v] to [0]\n    end\n    if <<key (space v) pressed?> and <(power up) = [parachute]>> then\n        set [glide v] to [1.5]\n    else\n        set [glide v] to [0]\n    end\n    if <(power up) = [drink]> then\n        set [speed v] to [3]\n    else\n        set [speed v] to [2]\n    end\n    if <(power up) = [skateboard]> then\n        set [jump v] to [25]\n    else\n        set [jump v] to [16]\n    end\n    if <(power up) = [gravity drink]> then\n        set [gravity v] to [1]\n    else\n        set [gravity v] to [2]\n    end\nend\n\n@loading\n\ndefine go to x (x) y (y) and activate pen with color (color) and size (size)\nset pen size to (size)\nset pen (color v) to (color)\npen up\ngo to x: ((x) + (pen x)) y: (y)\npoint in direction (45)\npen down\nmove (100) steps\nchange [pen x v] by (size)\n\ndefine start (times) (start x) (start y) (size)\nset [pen x v] to [0]\nrepeat (times)\n    go to x (start x) y (start y) and activate pen with color [1] and size (size)\n    go to x (start x) y (start y) and activate pen with color [7] and size (size)\nend\n\ndefine draw (time) frames starting from x (x) y (y and size) size (size) saturation (sat) brightness (brightness)\nset pen (saturation v) to (sat)\nset pen (brightness v) to (brightness)\nset [start x v] to (x)\nrepeat (time)\n    start [100] (start x) (y and size) (size)\n    change [start x v] by (1)\nend\n\nwhen flag clicked\nhide\nset [pen: clone id v] to [1]\nclone\n\nwhen I start as a clone\nshow\nif <(pen: clone id) = [1]> then\n    switch costume to (pen v)\n    set pen color to (#fb0000)\n    erase all\n    draw [70] frames starting from x [-500] y [-30] size [20] saturation [50] brightness [100]\nelse\n    point in direction (90)\n    go to x: (0) y: (0)\n    if <(pen: clone id) = [2]> then\n        go to [front v] layer\n        switch costume to (screen v)\n        repeat (2)\n            repeat (3)\n                wait (0.25) seconds\n                next costume\n            end\n            repeat (3)\n                wait (0.25) seconds\n                switch costume to ((costume [number v]) - (1))\n            end\n        end\n    else\n        switch costume to (load v)\n        point in direction (90)\n        glide with speed (loading time)\n        broadcast (end loading v)\n    end\nend\n\ndefine glide with speed (speed)\nrepeat ((360) / (speed))\n    change x by (speed)\nend\n\ndefine clone\nrepeat (3)\n    create clone of (_myself_ v)\n    change [pen: clone id v] by (1)\nend\n\nwhen I receive [end loading v]\nerase all\nhide\n\nwhen flag clicked\nset [loading time v] to [5]\n\n@power-ups\n\nwhen I receive [green flag v]\nshow\nswitch costume to (join [0] [])\nset [max costume v] to (costume [number v])\n\nwhen I receive [tick v]\nposition (((x) - (scroll x)) - (x space)) (((y) - (scroll y)) - (y space))\nif <<touching (ball v)?> or <touching (robot v)?>> then\n    add (costume [name v]) to [power-ups v]\n    delete this clone\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine clone at x (x) y (y)\ngo to [front v] layer\nchange [x v] by (x)\nchange [y v] by (y)\ncreate clone of (_myself_ v)\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 setup\nset [power up v] to []\ndelete all of [power-ups v]\nset [# v] to [1]\nrepeat (length)\n    if <<(item (#) of [costumes v]) = [7]> or <(item (#) of [costumes v]) = [8]>> then\n        switch costume to (pick random (2) to (mc))\n        determine x and y\n    else\n        switch costume to (blank v)\n    end\n    clone at x (item (#) of [x-spaces v]) y (item (#) of [y-spaces v])\n    change [# v] by (1)\nend\n\nwhen flag clicked\nswitch costume to (join [0] [])\nset [mc v] to (costume [number v])\n\nwhen I receive [setup decor v]\nshow\nset [x v] to [0]\nset [y v] to [0]\nsetup\n\ndefine determine x and y\nif <(item (#) of [costumes v]) = [7]> then\n    set [x space v] to [100]\n    set [y space v] to [85]\nelse\n    if <(item (#) of [costumes v]) = [8]> then\n        set [x space v] to [5]\n        set [y space v] to [230]\n    end\nend\n\n@timer\n\nwhen flag clicked\nhide\ngo to x: (-135) y: (-137)\ngo to [front v] layer\nset [timer: clone id v] to [1]\nrepeat (2)\n    create clone of (_myself_ v)\n    change [timer: clone id v] by (1)\nend\n\nwhen I start as a clone\nshow\ngo to [front v] layer\n\nwhen I receive [tick v]\nset size to (20) %\nif <(timer: clone id) = [1]> then\n    go to x: (-30) y: (162)\n    switch costume to ([floor v] of ((round (timer)) / (10)) )\nelse\n    switch costume to (round (timer))\n    go to x: ((-30) + ((size) - ((size) / (3)))) y: (162)\nend\nif <(timer) > [0]> then\n    show\nelse\n    hide\nend\n\n@warning\n\nwhen flag clicked\nshow\nset [ghost v] effect to (100)\nswitch costume to (costume2 v)\nrepeat (2)\n    create clone of (_myself_ v)\n    next costume\nend\n\nwhen I receive [warning v]\nif <(costume [number v]) = [1]> then\n    set [ghost v] effect to (100)\n    go to x: (0) y: (-100)\n    animate [5]\nend\n\ndefine animate (speed)\ngo to [front v] layer\nrepeat ((100) / (speed))\n    change [ghost v] effect by ((speed) * (-1))\n    change y by (speed)\nend\nwait (1) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\nwhen I receive [tick v]\nif <(costume [number v]) = [2]> then\n    if <(power up) > []> then\n        set [ghost v] effect to (0)\n    else\n        set [ghost v] effect to (100)\n    end\nend\nif <(costume [number v]) = [3]> then\n    set [ghost v] effect to (0)\n    if <(power up) > []> then\n        set y to (-42)\n    else\n        set y to (0)\n    end\nend\n\n@vision\n\nwhen flag clicked\ngo to x: (0) y: (0)\ngo to [back v] layer\n\nwhen I receive [tick v]\nchange [ghost effect v] by (((ghost effect) - ((100) + ((touching) * (-50)))) / (-10))\nset [ghost v] effect to (ghost effect)\n\n@power-up_items\n\nwhen flag clicked\nhide\nset [shop_screen y v] to [0]\nsetup\n\nwhen I start as a clone\nforever\n    if <(page) = [power]> then\n        show\n    else\n        hide\n    end\nend\n\ndefine setup\npoint in direction (90)\nclone at x [-160] y [90] costume [1]\nclone at x [-40] y [90] costume [2]\nclone at x [90] y [90] costume [3]\nclone at x [-160] y [-20] costume [4]\n\ndefine clone at x (x) y (y) costume (costume)\nswitch costume to (costume)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen I receive [tick v]\ngo to [front v] layer\ngo to x: (x) y: ((y) - (shop_screen y))\nif <[power-ups v] contains (costume [name v])?> then\n    set [color v] effect to (0)\nelse\n    set [color v] effect to ([tan v] of (-90) )\nend\n\nwhen this sprite clicked\nif <<(power up) = []> and <[power-ups v] contains (costume [name v])?>> then\n    set [check v] to (costume [name v])\n    broadcast (check power uo v)\nelse\n    if <(power up) > []> then\n        broadcast (warning v)\n    end\n    set size to (100) %\n    point in direction (90)\n    turn [20] [5]\n    turn [-20] [5]\nend\n\ndefine turn (degrees) (speed)\nrepeat (speed)\n    turn right ((degrees) / (speed)) degrees\n    change size by ((degrees) / (speed))\nend\n\n@robot\n\nwhen I receive [tick v]\nif <([right v] of [controls v]) = [1]> then\n    set [dir v] to [1]\nelse\n    if <([left v] of [controls v]) = [1]> then\n        set [dir v] to [-1]\n    end\nend\ngo to (ball v)\nif <[4] > (costume [number v])> then\n    point in direction (dir)\n    set rotation style [left-right v]\n    switch costume to (body v)\n    if <<<<key (space v) pressed?> and <[3] < ([in air v] of [ball v])>> and <(power up) = [parachute]>> or <<<([up v] of [controls v]) = [1]> or <[3] < ([in air v] of [ball v])>> and <(power up) = [skateboard]>>> then\n        switch costume to (join [body] (power up))\n    end\nelse\n    go to [front v] layer\n    turn right (((direction) - ((90) + (<<([right v] of [controls v]) = [1]> or <([left v] of [controls v]) = [1]>> * ((([right v] of [controls v]) - ([left v] of [controls v])) * (10))))) / (-5)) degrees\n    set rotation style [all around v]\n    switch costume to (join [head] (dir))\nend\nif <(page) = [game]> then\n    show\nelse\n    hide\nend\n\nwhen flag clicked\nhide\nswitch costume to (head-1 v)\ncreate clone of (_myself_ v)\nnext costume\n\nwhen I receive [end loading v]\nshow\n\n@power-up_button\n\nwhen flag clicked\nhide\n\nwhen this sprite clicked\nif <not <(costume [name v]) = [screen]>> then\n    set [page v] to (costume [name v])\n    broadcast (costume [name v])\n    if <(costume [number v]) = [1]> then\n        next costume\n    else\n        switch costume to (power v)\n    end\nend\n\nwhen I start as a clone\ngo to [front v] layer\nswitch costume to (screen v)\ngo to x: (0) y: (0)\nforever\n    if <(page) = [power]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen I receive [green flag v]\nshow\nset [page v] to [game]\nswitch costume to (power v)\ngo to x: (190) y: (150)\ncreate clone of (_myself_ v)\nrepeat (10)\n    go to [front v] layer\nend\n\nwhen this sprite clicked\nif <(costume [name v]) = [screen]> then\n    broadcast (back v)\nend\n\n@high score\n\nwhen flag clicked\nset size to (20) %\nswitch costume to (0 v)\nhide\ngo to x: (-135) y: (-137)\ngo to [front v] layer\nset [timer: clone id v] to [1]\nrepeat (10)\n    create clone of (_myself_ v)\n    change [timer: clone id v] by (1)\nend\n\nwhen I start as a clone\nshow\ngo to [front v] layer\n\nwhen I receive [tick v]\nset y to (162)\nset x to ((-130) + (((size) * ((2) / (3))) * (timer: clone id)))\nchange costume to (letter (timer: clone id) of (round (☁ high score)))\nif <(power up) > []> then\n    change y by (-42)\nend\nchange size by ((0.2) * ((20) - (size)))\n\ndefine change costume to (costume)\nif <not <(costume [name v]) = (costume)>> then\n    switch costume to (costume)\n    set size to (25) %\nend\n\n@parallax\n\nwhen I receive [tick v]\ngo to [back v] layer\ngo to x: ((((x) - ((scroll x) / (2))) mod ((480) * (2))) - (480)) y: ((scroll y) / (-10))\n\nwhen flag clicked\nhide\nset [x v] to [480]\ncreate clone of (_myself_ v)\nset [x v] to [0]\n\nwhen I receive [end loading v]\nshow\n\n
Hi guys! It's been so long since I made a platformer game, so I decided to make one!\nPS- This game is RANDOMLY generated!\n\nIndex:\nWhat is this game?\nPower-ups\nOther information\nCredits\nNew updates\n\n\nWhat is this game?\nThis is an endless platformer with randomly generated levels. There may be some impossible levels that may be solved with some power-ups.\nThe theme of this game is forest\n\nPower-ups\nThere are some power-ups scattered in the levels. Find them and store them. PS- They last for only 30 seconds after you enable them. Some power-ups you may find are:\ni) Parachute- Press space to glide safely down\nii) Energy drink- Makes you faster\niii) Gravity potion- Decreases gravity\niv) Skateboard- Helps you to jump higher\nTo enable the power-ups, click on the top-right button and select the power-up you want to use by clicking on 'enable'.\n\nOther information:\nYou can wall jump\nThere may be glitches. To wall jump, instead of pressing the up button continuously, press it and let go many times. This decreases the chance to glitch out of a wall.\nAlso, if you touch the brown parts, your vision gets low.\n\nCredits:\nCredit to @griffpatch for his tutorial on platform and text animation\nCredit to me for the art and code\nCredit to me for the robot animation\nInspired  by youtuber Sam Hogan\n\nNew updates:\nHigh scores\nNumber animation (thnx to @griffpatch)\n