☄︎. *. ⋆ Candy - A platformer ⊹₊⋆
@Stage\n\nwhen flag clicked\nforever\n    play sound [We Don't Talk About Bruno \(Instrumental\) v] until done\nend\n\n@Ground\n\nwhen flag clicked\nswitch costume to (costume1 v)\nforever\n    go to [front v] layer\n    go [backward v] (5) layers\n    set [level v] to (costume [number v])\n    go to x: (0) y: (0)\nend\n\nwhen I receive [next level v]\nnext costume\nbroadcast (next levl v)\n\nwhen flag clicked\nforever\n    set [level v] to (costume [number v])\nend\n\nwhen flag clicked\nif <(costume [number v]) = [4]> then\n    broadcast (once v)\nend\n\nwhen I receive [star v]\nswitch costume to (costume1 v)\n\nwhen I receive [start v]\nswitch costume to (costume22 v)\n\n@Player\n\nwhen [c v] key pressed\nnext costume\n\nwhen flag clicked\nset [xvel v] to [0]\nset [yvel v] to [0]\nset [level v] to [1]\ngo to x: (-180) y: (-50)\nforever\n    Run physics [0.9] [0.9] [-1] [15]\n    if <<<key (down arrow v) pressed?> or <key (s v) pressed?>> or <<mouse down?> and <(y position) > (mouse y)>>> then\n        if <not <<touching color (#4c86ff)?> or <touching color (#437de0)?>>> then\n            switch costume to (costume2 v)\n        else\n            switch costume to (costume1 v)\n        end\n    else\n        switch costume to (costume1 v)\n    end\nend\n\ndefine Run physics (speed) (friction) (gravity) (jump height)\nchange [y v] by (gravity)\nif <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(mouse x) > (x position)>>> then\n    change [x v] by (speed)\nend\nif <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(x position) > (mouse x)>>> then\n    change [x v] by ((speed) * (-1))\nend\nset [x v] to ((X) * (friction))\nchange x by (X)\nif <touching (ground v)?> then\n    change y by (1)\nend\nif <touching (ground v)?> then\n    change y by (1)\nend\nif <touching (ground v)?> then\n    change y by (1)\nend\nif <touching (ground v)?> then\n    change y by (1)\nend\nif <touching (ground v)?> then\n    change y by (-4)\n    change x by ((X) * (-1))\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>> then\n        set [y v] to ((jump height) - (3.5))\n        if <[0] < (X)> then\n            set [x v] to [-6]\n        else\n            set [x v] to [6]\n        end\n    else\n        set [x v] to [0]\n    end\nend\nchange y by (Y)\nif <touching (ground v)?> then\n    change y by ((Y) * (-1))\n    set [y v] to [0]\nend\nchange y by (-1)\nif <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>> then\n    if <touching (ground v)?> then\n        set [y v] to (jump height)\n    end\nend\nchange y by (1)\n\nwhen I receive [ded v]\ngo to x: (-189) y: (90)\nset [ghost v] effect to (0)\nbroadcast (start v)\n\nwhen I start as a clone\nrepeat (10)\n    change size by (-5)\n    change [ghost v] effect by (5)\nend\ndelete this clone\n\nwhen I receive [next level v]\ngo to x: (-180) y: (-50)\n\nwhen flag clicked\nrepeat until <(Level) = [22]>\n    if <[220] < (x position)> then\n        broadcast (Next level v) and wait\n        wait until <not <[220] < (x position)>>\n    end\n    if <<<(y position) < [-170]> or <touching (spikes v)?>> or <<touching (lava v)?> or <touching (saw v)?>>> then\n        broadcast (Ded v) and wait\n    end\n    if <touching (bouncy v)?> then\n        set [y v] to [20]\n    end\nend\n\nwhen flag clicked\nforever\n    if <<touching color (#54ceff)?> or <touching color (#63d2ff)?>> then\n        if <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(x position) > (mouse x)>>> then\n            change [x v] by (-1.3)\n        end\n        if <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(mouse x) > (x position)>>> then\n            change [x v] by (1.3)\n        end\n        if <<<key (down arrow v) pressed?> or <key (s v) pressed?>> or <<mouse down?> and <(y position) > (mouse y)>>> then\n            change [y v] by (-1.3)\n        end\n        if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>> then\n            change [y v] by (1.3)\n        end\n        set [x v] to ((X) * (0.81))\n        set [y v] to ((Y) * (0.81))\n        change [y v] by (((Y) / (14.9)) + (0.1))\n    end\n    set size to (125) %\nend\n\nwhen I receive [respawn v]\ngo to x: (-180) y: (-50)\nset [ghost v] effect to (0)\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    go [backward v] (1) layers\nend\n\nwhen flag clicked\nforever\n    create clone of (_myself_ v)\nend\n\nwhen flag clicked\nforever\n    if <[220] < (x position)> then\nend\n\nwhen flag clicked\nforever\n    if <touching (bouncy v)?> then\n        play sound [Mario_Jump_-_Gaming_Sound_Effect v] until done\n    end\nend\n\nwhen flag clicked\nforever\n    if <<<(y position) < [-170]> or <touching (spikes v)?>> or <<touching (lava v)?> or <touching (saw v)?>>> then\nend\n\nwhen flag clicked\nforever\n    if <[2] = (costume [number v])> then\n        set [x v] to [0]\n        wait until <not <[2] = (costume [number v])>>\n    end\nend\n\nplay sound [Ding Sound Effect v] until done\nset x to (-220)\n\nplay sound [Roblox Death Sound  OOF Sound Effect v] until done\n\nwhen flag clicked\ngo to x: (-183) y: (82)\n\nwhen I receive [next levl v]\ngo to x: (-189) y: (90)\n\nwhen flag clicked\nshow\n\n@Sprite1\n\nwhen flag clicked\ngo to x: (0) y: (0)\nshow\nwait (1) seconds\nglide (1) secs to x: (0) y: (-50)\nglide (.55) secs to x: (0) y: (355)\nhide\n\nwhen flag clicked\nforever\n    go to [front v] layer\nend\n\n