Candy || A scrolling Platformer (entry for @Jranknom)
@Stage\n\nwhen [m v] key pressed\nset [mouse v] to (join ((mouse x) + (Scroll x)) (join [,] ((mouse y) + (Scroll y))))\n\nwhen flag clicked\nhide variable [time v]\nswitch backdrop to (backdrop1 v)\nset [time v] to [0]\nforever\n    if <(Time out) = [on]> then\n        wait (1) seconds\n        change [time v] by (1)\n    end\nend\n\nwhen I receive [you win v]\nshow variable [time v]\n\n@Player\n\nwhen flag clicked\nforever\n    if <<key (up arrow v) pressed?> or <<(mouse y) > (y position)> and <mouse down?>>> then\n        switch costume to (up v)\n    else\n        switch costume to (normal v)\n    end\n    if <<key (right arrow v) pressed?> or <<(mouse x) > (x position)> and <mouse down?>>> then\n        switch costume to (right v)\n    end\n    if <<key (left arrow v) pressed?> or <<(mouse x) < (x position)> and <mouse down?>>> then\n        switch costume to (left v)\n    end\n    if <<<key (up arrow v) pressed?> and <key (right arrow v) pressed?>> or <<<(mouse x) > (x position)> and <(mouse y) > (y position)>> and <mouse down?>>> then\n        switch costume to (up/right v)\n    end\n    if <<<key (up arrow v) pressed?> and <key (left arrow v) pressed?>> or <<<(mouse x) < (x position)> and <(mouse y) > (y position)>> and <mouse down?>>> then\n        switch costume to (up/left v)\n    end\nend\n\nwhen flag clicked\nbroadcast (Green flag v) and wait\nbroadcast (Play game v) and wait\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\n\nwhen I receive [play game v]\nset [level v] to [1]\nforever\n    if <(Time out) = [on]> then\n        broadcast (reset v) and wait\n        broadcast (Setup v) and wait\n        Game on\n        repeat until <(Exit) > []>\n            Tick\n            broadcast (Tick v) and wait\n        end\n        if <(Exit) = [win]> then\n            Game - win\n        else\n            Game - die\n        end\n    end\nend\n\ndefine Game on\nset [x v] to [0]\nset [y v] to [0]\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nset [sx v] to [0]\nset [sy v] to [0]\nset [in air v] to [0]\nset [exit v] to []\npoint in direction (90)\nset size to (30) %\nset [ghost v] effect to (0)\nshow\n\ndefine Tick\nif <not <touching (water \(chocolate\) v)?>> then\n    if <<key (left arrow v) pressed?> or <<(mouse x) < (x position)> and <mouse down?>>> then\n        if <(speed) = [off]> then\n            change [sx v] by (-4)\n        end\n        if <(speed) = [on]> then\n            change [sx v] by (-7)\n        end\n    end\n    if <<key (right arrow v) pressed?> or <<(mouse x) > (x position)> and <mouse down?>>> then\n        if <(speed) = [off]> then\n            change [sx v] by (4)\n        end\n        if <(speed) = [on]> then\n            change [sx v] by (7)\n        end\n    end\n    set [sx v] to ((SX) * (0.8))\nend\nif <touching (water \(chocolate\) v)?> then\n    if <<key (left arrow v) pressed?> or <<(mouse x) < (x position)> and <mouse down?>>> then\n        change [sx v] by (-1)\n    end\n    if <<key (right arrow v) pressed?> or <<(mouse x) > (x position)> and <mouse down?>>> then\n        change [sx v] by (1)\n    end\n    set [sx v] to ((SX) * (0.8))\nend\nif <([abs v] of (SX) ) > [0.9]> then\n    Change Player x (round (SX))\nend\nif <not <touching (water \(chocolate\) v)?>> then\n    if <<key (up arrow v) pressed?> or <<(mouse y) > (y position)> and <mouse down?>>> then\n        if <(Jump boost) = [off]> then\n            if <(In Air) < [4]> then\n                set [sy v] to [10]\n            end\n        end\n        if <(Jump boost) = [on]> then\n            if <(In Air) < [4]> then\n                set [sy v] to [13]\n            end\n        end\n    end\nend\nif <touching (water \(chocolate\) v)?> then\n    if <<key (up arrow v) pressed?> or <<(mouse y) > (y position)> and <mouse down?>>> then\n        set [sy v] to [3]\n    end\nend\nif <not <touching (water \(chocolate\) v)?>> then\n    change [sy v] by (-1)\nend\nif <touching (water \(chocolate\) v)?> then\n    if <<key (down arrow v) pressed?> or <<(mouse y) < (y position)> and <mouse down?>>> then\n        change [sy v] by (-0.3)\n    end\nend\nif <touching (sorting \(mogul\) v)?> then\n    set [sy v] to [20]\nend\nChange Player by (SY)\nTest - die\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 <(Scroll y) < [0]> then\n    set [scroll y v] to [0]\nend\nPotition\nif <(y) < [-180]> then\n    set [exit v] to [die]\nend\n\ndefine Change Player by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nPotition\nrepeat until <not <touching (platforms 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    Potition\n    set [sy v] to [0]\nend\n\ndefine Potition\ngo to x: ((x) - (Scroll x)) y: ((y) - (Scroll y))\n\ndefine Change Player x (sx)\nchange [x v] by (sx)\nPotition\nif <touching (platforms v)?> then\n    repeat (12)\n        change [y v] by (1)\n        Potition\n        if <not <touching (platforms v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    if <<key (up arrow v) pressed?> or <<(mouse y) > (y position)> and <mouse down?>>> 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 (platforms v)?>>\n        if <(sx) > [0]> then\n            change [x v] by (-1)\n        else\n            change [x v] by (1)\n        end\n        Potition\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 Test - die\nif <touching (enemys v)?> then\n    set [exit v] to [die]\nend\nif <touching (danger v)?> then\n    set [exit v] to [die]\nend\n\ndefine Game - win\nset [ghost v] effect to (100)\nhide\nchange [level v] by (1)\nwait (1) seconds\n\nwhen I receive [you win v]\nhide\n\nwhen flag clicked\nforever\n    play sound [vexento-masked-heroes-1-AHM56EBq6 \(1\) v] until done\nend\n\n@Platforms\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPotition ((x) - (Scroll x)) ((y) - (Scroll y))\n\nwhen I receive [setup v]\nhide\nset [y v] to [0]\nset [x v] to [0]\nif <(Level) = [1]> then\n    switch costume to (0 v)\n    Clone at X [0] Y [0]\n    Clone at X [0] Y [250]\n    Clone at X [50] Y [300]\n    Clone at X [-20] Y [300]\n    Clone at X [690] Y [70]\n    Clone at X [730] Y [100]\n    Clone at X [790] Y [110]\n    Clone at X [860] Y [110]\n    Clone at X [900] Y [150]\n    Clone at X [100] Y [150]\nend\n\ndefine Potition (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 [reset v]\ndelete this clone\n\ndefine Clone at X (x) Y (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nwhen I receive [you win v]\nhide\n\n@ART platforms\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPotition ((x) - (Scroll x)) ((y) - (Scroll y))\n\nwhen I receive [setup v]\nhide\nset [y v] to [0]\nset [x v] to [0]\nif <(Level) = [1]> then\n    switch costume to (0 v)\n    Clone at X [0] Y [0]\n    Clone at X [0] Y [250]\n    Clone at X [50] Y [300]\n    Clone at X [-20] Y [300]\n    Clone at X [690] Y [70]\n    Clone at X [730] Y [100]\n    Clone at X [790] Y [110]\n    Clone at X [850] Y [110]\n    Clone at X [900] Y [150]\n    Clone at X [100] Y [150]\nend\n\ndefine Potition (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 [reset v]\ndelete this clone\n\ndefine Clone at X (x) Y (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nwhen I receive [you win v]\nhide\n\nwhen flag clicked\nforever\n    go to [back v] layer\nend\n\n@danger\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPotition ((x) - (Scroll x)) ((y) - (Scroll y))\n\nwhen I receive [setup v]\nhide\nset [y v] to [0]\nset [x v] to [0]\nif <(Level) = [1]> then\n    switch costume to (0 v)\nend\n\ndefine Potition (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 [reset v]\ndelete this clone\n\ndefine Clone at X (x) Y (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nwhen I receive [you win v]\nhide\n\n@collectabels (m&m)\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPotition ((x) - (Scroll x)) ((y) - (Scroll y))\nif <touching (player v)?> then\n    change [collected v] by (1)\n    if <(COLLECTED) = (Collected max)> then\n        broadcast (Open portal v)\n    end\n    delete this clone\nend\n\nwhen I receive [setup v]\nhide\nset [collected v] to [0]\nset [collected max v] to [0]\nset [y v] to [0]\nset [x v] to [0]\nif <(Level) = [1]> then\n    switch costume to (m&m v)\n    Clone at X [137] Y [-5]\n    Clone at X [177] Y [-5]\n    Clone at X [217] Y [-5]\n    Clone at X [257] Y [-5]\n    Clone at X [297] Y [-5]\n    Clone at X [63] Y [270]\n    Clone at X [23] Y [290]\n    Clone at X [-17] Y [310]\n    Clone at X [-57] Y [330]\n    Clone at X [-97] Y [350]\n    Clone at X [156] Y [630]\n    Clone at X [156] Y [670]\n    Clone at X [156] Y [710]\n    Clone at X [156] Y [750]\n    Clone at X [156] Y [790]\n    Clone at X [597] Y [798]\n    Clone at X [597] Y [838]\n    Clone at X [597] Y [878]\n    Clone at X [597] Y [918]\n    Clone at X [597] Y [958]\n    Clone at X [597] Y [998]\n    Clone at X [597] Y [1038]\n    Clone at X [597] Y [1078]\n    Clone at X [597] Y [1118]\n    Clone at X [832] Y [815]\n    Clone at X [872] Y [815]\n    Clone at X [912] Y [815]\n    Clone at X [952] Y [815]\n    Clone at X [992] Y [815]\n    Clone at X [1032] Y [815]\n    Clone at X [1558] Y [1082]\n    Clone at X [1558] Y [1122]\n    Clone at X [1558] Y [1162]\n    Clone at X [1558] Y [1202]\n    Clone at X [1652] Y [1248]\n    Clone at X [1652] Y [1288]\n    Clone at X [1860] Y [1207]\n    Clone at X [1900] Y [1207]\n    Clone at X [1940] Y [1207]\n    Clone at X [1980] Y [1207]\n    Clone at X [2020] Y [1207]\n    Clone at X [2060] Y [1207]\n    Clone at X [2100] Y [1207]\n    Clone at X [2140] Y [1207]\n    Clone at X [2180] Y [1207]\n    Clone at X [2220] Y [1207]\n    Clone at X [2260] Y [1207]\n    Clone at X [2300] Y [1207]\n    Clone at X [2340] Y [1207]\n    Clone at X [2380] Y [1207]\n    Clone at X [2420] Y [1207]\n    Clone at X [2460] Y [1207]\n    Clone at X [2500] Y [1207]\n    Clone at X [2540] Y [1207]\n    Clone at X [2580] Y [1207]\n    Clone at X [2620] Y [1207]\n    Clone at X [2660] Y [1207]\n    Clone at X [2700] Y [1207]\n    Clone at X [2740] Y [1207]\n    Clone at X [2780] Y [1207]\n    Clone at X [2820] Y [1207]\n    Clone at X [2860] Y [1217]\n    Clone at X [2900] Y [1237]\n    Clone at X [2940] Y [1257]\n    Clone at X [2980] Y [1277]\n    Clone at X [3020] Y [1297]\n    Clone at X [3060] Y [1307]\n    Clone at X [3100] Y [1307]\n    Clone at X [3206] Y [1463]\n    Clone at X [3246] Y [1463]\n    Clone at X [3206] Y [1503]\n    Clone at X [3246] Y [1503]\n    Clone at X [3206] Y [1543]\n    Clone at X [3246] Y [1543]\nelse\nend\nset [x v] to [-99999]\n\ndefine Potition (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 [reset v]\ndelete this clone\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 [you win v]\nhide\n\nwhen flag clicked\nset size to (30) %\nforever\n    next costume\nend\n\nwhen I start as a clone\nforever\n    next costume\nend\n\n@water (chocolate)\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nchange [up/down lava v] by (2.5)\nPosition ((x) - (Scroll x)) (((y) - (Scroll y)) + (([cos v] of (UP/DOWN LAVA) ) * (5)))\n\nwhen I receive [setup v]\nhide\nset [y v] to [0]\nset [x v] to [0]\nset [up/down lava v] to [0]\nif <(Level) = [1]> then\n    switch costume to (0 v)\n    Clone at X [0] Y [0]\n    Clone at X [0] Y [250]\n    Clone at X [50] Y [300]\n    Clone at X [-20] Y [300]\n    Clone at X [690] Y [70]\nend\n\ndefine Potition (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 [reset v]\ndelete this clone\n\ndefine Clone at X (x) Y (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nwhen I receive [you win v]\nhide\n\nwhen flag clicked\nforever\n    go to [back v] layer\nend\n\nwhen I receive [tick v]\nPotition ((x) - (Scroll x)) ((y) - (Scroll y))\n\n@sorting (mogul)\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPotition ((x) - (Scroll x)) ((y) - (Scroll y))\n\nwhen I receive [setup v]\nhide\nset [y v] to [0]\nset [x v] to [0]\nif <(Level) = [1]> then\n    switch costume to (0 v)\n    Clone at X [0] Y [0]\n    Clone at X [0] Y [250]\n    Clone at X [50] Y [300]\n    Clone at X [-20] Y [300]\n    Clone at X [690] Y [70]\n    Clone at X [730] Y [100]\nend\n\ndefine Potition (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 [reset v]\ndelete this clone\n\ndefine Clone at X (x) Y (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nwhen I receive [you win v]\nhide\n\n@enemys\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPotition ((x) - (Scroll x)) ((y) - (Scroll y))\n\nwhen I receive [setup v]\nhide\nset [y v] to [0]\nset [x v] to [0]\nif <(Level) = [1]> then\n    switch costume to (blank v)\n    Clone at X [2250] Y [1185]\nend\n\ndefine Potition (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 [reset v]\ndelete this clone\n\ndefine Clone at X (x) Y (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nwhen I receive [you win v]\nhide\n\nwhen flag clicked\nforever\n    repeat (70)\n        change [x v] by (3)\n    end\n    repeat (70)\n        change [x v] by (-3)\n    end\nend\n\nwhen I start as a clone\nforever\n    repeat (70)\n        change [x v] by (3)\n    end\n    repeat (70)\n        change [x v] by (-3)\n    end\nend\n\n@exit\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPotition ((x) - (Scroll x)) ((y) - (Scroll y))\nif <touching (player v)?> then\n    broadcast (you win v)\nend\n\nwhen I receive [setup v]\nhide\nset [collected v] to [0]\nset [collected max v] to [0]\nset [y v] to [0]\nset [x v] to [0]\nif <(Level) = [1]> then\n    switch costume to (exit v)\n    Clone at X [4050] Y [1870]\nend\n\ndefine Potition (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 [reset v]\ndelete this clone\n\ndefine Clone at X (x) Y (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen I receive [you win v]\nhide\n\nwhen flag clicked\nset size to (50) %\n\n@end screen\n\nwhen flag clicked\nset [time out v] to [on]\ngo to x: (0) y: (0)\nhide\n\nwhen I receive [you win v]\nset [time out v] to [off]\nshow\n\nwhen flag clicked\ngo to [front v] layer\nforever\n    go to [front v] layer\nend\n\n@Shop\n\nwhen flag clicked\nswitch costume to (shop \(close\) v)\nforever\n    if <(costume [number v]) = [1]> then\n        set [shop v] to [Close]\n        set [ghost v] effect to (0)\n        go to x: (-200) y: (-149)\n        if <touching (mouse-pointer v)?> then\n            set size to (110) %\n        else\n            set size to (100) %\n        end\n        if <<touching (mouse-pointer v)?> and <mouse down?>> then\n            switch costume to (shop \(open\) v)\n        end\n    else\n        set [shop v] to [Open]\n        set [ghost v] effect to (15)\n        go to x: (0) y: (0)\n        set size to (100) %\n        if <<not <touching (mouse-pointer v)?>> and <mouse down?>> then\n            switch costume to (shop \(close\) v)\n        end\n    end\nend\n\n@Speed\n\nwhen flag clicked\nswitch costume to (costume1 v)\nset [speed v] to [off]\nset size to (70) %\ngo to x: (18) y: (7)\nhide\ngo to [front v] layer\nforever\n    go to [front v] layer\n    if <(Shop) = [Open]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen this sprite clicked\nif <(COLLECTED) > [19]> then\n    if <(costume [number v]) = [1]> then\n        switch costume to (costume2 v)\n        change [collected v] by (-20)\n        set [speed v] to [on]\n    end\nend\n\n@Jump Boost\n\nwhen flag clicked\nswitch costume to (costume1 v)\nset [jump boost v] to [off]\nset size to (70) %\ngo to x: (16) y: (54)\nhide\ngo to [front v] layer\nforever\n    go to [front v] layer\n    if <(Shop) = [Open]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen this sprite clicked\nif <(COLLECTED) > [29]> then\n    if <(costume [number v]) = [1]> then\n        switch costume to (costume2 v)\n        change [collected v] by (-30)\n        set [jump boost v] to [on]\n    end\nend\n\n@1\n\nwhen flag clicked\ngo to x: (-202) y: (166)\nset [collected v] to [0]\nswitch costume to (0 v)\nforever\n    go to [front v] layer\n    switch costume to (letter (1) of (COLLECTED))\nend\n\n@2\n\nwhen flag clicked\ngo to x: (-190) y: (166)\nset [collected v] to [0]\nswitch costume to (0 v)\nforever\n    go to [front v] layer\n    switch costume to (letter (2) of (COLLECTED))\n    if <(length of (COLLECTED)) > [1]> then\n        show\n    else\n        hide\n    end\nend\n\n@3\n\nwhen flag clicked\ngo to x: (-178) y: (166)\nset [collected v] to [0]\nswitch costume to (0 v)\nforever\n    switch costume to (letter (3) of (COLLECTED))\n    if <(length of (COLLECTED)) > [2]> then\n        show\n    else\n        hide\n    end\nend\n\n@Logo counter collected\n\nwhen flag clicked\nforever\n    go to x: (-225) y: (168)\n    go to [front v] layer\nend\n\n@Thumbnail\n\nwhen flag clicked\ngo to x: (0) y: (0)\ngo to [front v] layer\nset [ghost v] effect to (100)\nforever\n    go to x: (0) y: (0)\n    go to [front v] layer\nend\n\n
                  -----------✨-Candy-✨-----------\n                       - A scrolling platformer -\n\n→ Arrow keys or mobile\n\n→ collect m&ms\n\n→ Get the shiny candy \n\n→ Love, fav and follow\n\n#21 on trending :0 ??? (on tutorials) (24/11/2020)