Happiness || A scrolling platformer
@Stage\n\nwhen [m v] key pressed\nset [mouse v] to (join ((mouse x) + (SCROLL X)) (join [, ] ((mouse y) + (SCROLL Y))))\nshow variable [mouse v]\n\nwhen I receive [intro v]\nswitch backdrop to (backdrop2 v)\n\nwhen I receive [play game v]\nswitch backdrop to (blue sky 2  v)\nstop all sounds\nstart sound [Tobu - Candyland v]\n\n@Blank\n\n@Player\n\nwhen flag clicked\nbroadcast (Green Flag v) and wait\nbroadcast (Intro v)\n\nbroadcast (Play Game v) and wait\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\nset [deaths: v] to [0]\n\nwhen I receive [play game v]\nset [easter egg costume switch v] to [1]\nset [level: v] to [1]\nset [checkpoint v] to [0]\nforever\n    broadcast (RESET v)\n    broadcast (Set up v)\n    Game On\n    repeat until <(EXIT) > [50]>\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\nend\n\ndefine Game On\nif <(Checkpoint) = [0]> then\n    set [x v] to [0]\n    set [y v] to [0]\nelse\n    set [x v] to (item (Checkpoint) of [check point x v])\n    set [y v] to (item (Checkpoint) of [check point y v])\nend\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nset [speed y v] to [0]\nset [sx v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nset size to (100) %\nset [ghost v] effect to (0)\nshow\n\ndefine Tick\nif <<<mouse down?> and <(mouse x) < [0]>> or <<key (left arrow v) pressed?> or <key (a v) pressed?>>> then\n    point in direction (90)\n    change [sx v] by (-3)\nend\nif <<<mouse down?> and <(mouse x) > [0]>> or <<key (right arrow v) pressed?> or <key (d v) pressed?>>> then\n    point in direction (-90)\n    change [sx v] by (3)\nend\nset [sx v] to ((sx) * (0.8))\nif <([abs v] of (sx) ) > [0.9]> then\n    Change Player X by (round (sx))\nend\nif <<<mouse down?> and <(mouse y) > [0]>> or <<key (up arrow v) pressed?> or <key (w v) pressed?>>> then\n    if <(In air) < [4]> then\n        set [speed y v] to [16]\n    end\nend\nif <(Speed y) > [-18]> then\n    change [speed y v] by (-2)\nend\nChange Player y by (Speed y)\nTest - die\nLeprechaun?\nwho am i?\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\nPosition\nif <(y) < [-180]> then\n    set [exit v] to [die]\nend\n\ndefine Change Player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nPosition\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 [speed y v] to [0]\nend\n\ndefine Change Player X by (sx)\nchange [x v] by (sx)\nPosition\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 <<<mouse down?> and <(mouse y) > [0]>> or <<key (up arrow v) pressed?> or <key (w v) pressed?>>> 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 Game - Die\nset [exit v] to []\nrepeat (5)\n    broadcast (red flash v)\n    hide\n    wait (0.1) seconds\n    show\n    wait (0.1) seconds\nend\nhide\nwait (0.5) seconds\nchange [deaths: v] by (1)\n\ndefine Test - die\nif <touching (danger\( lava spikes etc\) v)?> then\n    set [exit v] to [die]\nend\n\ndefine Game - win\nrepeat (50)\n    point towards (exit portal v)\n    turn right (65) degrees\n    move ((distance to [exit portal v]) / (2)) steps\n    change size by (-1)\n    change [ghost v] effect by (2)\nend\nhide\nif <(Level:) < [6]> then\n    change [level: v] by (1)\n    wait (1) seconds\nelse\n    set [level: v] to [bonus]\nend\n\ndefine Position\ngo to x: ((x) - (SCROLL X)) y: ((y) - (SCROLL Y))\n\ndefine Leprechaun?\nif <touching (pot of gold v)?> then\n    set [easter egg costume switch v] to [2]\nend\n\ndefine who am i?\nif <(easter egg costume switch) = [2]> then\n    switch costume to (1 mian2 v)\nelse\n    switch costume to (1 mian v)\nend\n\n@Platform\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [set up v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nshow variable [deaths: v]\nshow variable [level: v]\nif <(Level:) = [1]> then\n    switch costume to (level 1 1 v)\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\nelse\n    if <(Level:) = [2]> then\n        switch costume to (level 1 21 v)\n        Clone at x: [450] y: [0]\n    end\nend\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\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\n@danger( lava spikes etc)\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [set up v]\nhide\ngo to [back v] layer\nset [x v] to [0]\nset [y v] to [0]\nif <(Level:) = [1]> then\n    switch costume to (level 1 1 v)\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\nelse\n    switch costume to (level 1 18 v)\nend\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\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\n@Text & fake objects\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [set up v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(Level:) = [1]> then\n    switch costume to (level 1 1 v)\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\n    Clone at x: [450] y: [0]\nelse\n    if <(Level:) = [2]> then\n        switch costume to (level 1 5 v)\n        Clone at x: [450] y: [0]\n    end\nend\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\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\n@exit portal\n\nwhen I receive [green flag v]\nhide\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]\n    set [checkpoint v] to [0]\nend\n\nwhen I receive [set up v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(Level:) = [1]> then\n    switch costume to (open v)\n    Clone at x: [8623] y: [-57]\nelse\n    Clone at x: [100000] y: [10000]\nend\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\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)\n\n@clouds\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nswitch costume to (pick random (1) to (3))\ngo to x: (300) y: (pick random (195) to (125))\nshow\nrepeat until <(x position) < [-250]>\n    change x by (-3)\nend\nrepeat (5)\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nwhen I receive [play game v]\nchange [ghost v] effect by (15)\nhide\nforever\n    create clone of (_myself_ v)\n    wait (2) seconds\n    create clone of (_myself_ v)\n    wait (6) seconds\nend\n\n@sun shine\n\ngo to x: (165) y: (133)\n\nwhen flag clicked\nhide\n\nwhen I receive [play game v]\nshow\n\n@Sprite1\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\nwhen I receive [tick v]\nshow\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\nwhen I receive [reset v]\ndelete this clone\n\nwhen flag clicked\nhide\nhide variable [level: v]\nhide variable [deaths: v]\n\n@check piont\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <touching (player v)?> then\n    set [ghost affect v] to [0]\n    start sound [Connect v]\n    switch costume to (flag2 v)\n    set [ghost v] effect to (0)\n    broadcast (Checkpoint  v)\n    repeat until <(ghost affect) = [100]>\n        change [ghost v] effect by (1)\n        change [ghost affect v] by (1)\n    end\n    set [checkpoint v] to [1]\n    delete this clone\nend\n\nwhen I receive [set up v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nset [clone v] to [0]\nswitch costume to (flag v)\nif <(Level:) = [1]> then\n    Clone at x: [1959] y: [178]\n    set [x v] to [-999999999999999999999999]\nelse\n    set [x v] to [-999999999999999999999999]\nend\n\nClone at x: [4320] y: [-76]\nClone at x: [6644] y: [-72]\nClone at x: [8443] y: [100000]\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\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 [clone v] by (1)\ncreate clone of (_myself_ v)\n\nif <(Checkpoint) = [0]> then\n    set [checkpoint v] to [1]\nend\n\nif <(Checkpoint) = [3]> then\n    set [checkpoint v] to [4]\n    delete this clone\nend\n\ndelete this clone\n\n@Sprite2\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [checkpoint  v]\ngo to x: (35) y: (176)\nshow\nrepeat (5)\n    change y by (-5)\nend\nrepeat until <touching (_edge_ v)?>\n    change y by (-5)\nend\nhide\n\n@Sprite3\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [red flash v]\nhide\nwait (0.1) seconds\nshow\nwait (0.1) seconds\nhide\n\n@Pot of gold\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\n\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\nwhen I receive [set up v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(Level:) = [1]> then\n    switch costume to (open v)\n    Clone at x: [3335] y: [2000000]\nelse\n    Clone at x: [3335] y: [2000000]\nend\n\ndefine Position (x) (y)\n\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)\n\n@button\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <<touching (player v)?> and <(costume [number v]) = [1]>> then\n    change [☁ votes v] by (1)\n    switch costume to (costume2 v)\n    stop [this script v]\nend\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 Clone at x: (x) y: (y)\nset [x v] to (x)\nset [y v] to (y)\n\nwhen I receive [set up v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(Level:) = [1]> then\n    Clone at x: [100000] y: [10000]\nelse\n    go to [back v] layer\n    Clone at x: [437] y: [-87]\nend\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [green flag v]\nhide\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nwhen I receive [tick v]\nif <touching (player v)?> then\n    show variable [☁ votes v]\nelse\n    hide variable [☁ votes v]\nend\n\n@Sprite4\n\nwhen flag clicked\nshow\nset [ghost v] effect to (100)\ngo to [front v] layer\n\nhide variable [level: v]\nhide variable [deaths: v]\nshow\nset [ghost v] effect to (1)\ngo to [front v] layer\n\nset [ghost v] effect to (0)\n\n@Sprite5\n\nwhen I receive [intro v]\nhide\nset [clone position v] to [1]\nrepeat (12)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nswitch costume to (CLone position)\ngo to x: (item (CLone position) of [clone position v]) y: (item (CLone position) of [clone position y v])\nchange [clone position v] by (1)\n\ndefine touch test\nshow\nif <touching (spot light  v)?> then\n    show\nelse\n    hide\nend\n\nwhen I start as a clone\nforever\n    touch test\nend\n\nwhen I receive [show your self v]\nstop [other scripts in sprite v]\ndelete this clone\n\n@XXX_FIRE_XXX \n\nwhen I receive [show your self v]\ngo to x: (0) y: (-100)\npoint in direction (90)\nset size to (100) %\nshow\nturn right (8) degrees\nrepeat until <(direction) = [90]>\n    turn right (8) degrees\n    change size by (2)\nend\nrepeat (4)\n    wait (0.1) seconds\n    change size by (20)\n    wait (0.1) seconds\n    change size by (-20)\nend\nrepeat until <(x position) > [350]>\n    change x by (5)\nend\nhide\nwait (0.5) seconds\nbroadcast (Play Game v)\n\nwhen I receive [intro v]\nhide\n\nwhen I receive [show your self v]\nrepeat until <(y position) = [-10]>\n    change y by (2)\nend\n\n@spot light \n\nwhen flag clicked\n\nbroadcast (Intro v)\n\nwhen I receive [intro v]\nstart sound [Xeogenesis  - TheFatRat v]\n\nwhen I receive [intro v]\nshow\npoint in direction (90)\nrepeat until <(direction) = [120]>\n    turn right (0.5) degrees\nend\nrepeat until <(direction) = [60]>\n    turn left (0.5) degrees\nend\nrepeat until <(direction) = [90]>\n    turn right (1) degrees\nend\nbroadcast (show your self v)\n\nwhen I receive [play game v]\nhide\n\n@check piont2\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <touching (player v)?> then\n    set [ghost affect v] to [0]\n    start sound [Connect v]\n    switch costume to (flag2 v)\n    set [ghost v] effect to (0)\n    broadcast (Checkpoint  v)\n    repeat until <(ghost affect) = [100]>\n        change [ghost v] effect by (1)\n        change [ghost affect v] by (1)\n    end\n    set [checkpoint v] to [2]\n    delete this clone\nend\n\nwhen I receive [set up v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nset [clone v] to [0]\nswitch costume to (flag v)\nif <(Level:) = [1]> then\n    Clone at x: [4320] y: [-76]\n    set [x v] to [-999999999999999999999999]\nelse\n    set [x v] to [-999999999999999999999999]\nend\n\nClone at x: [1959] y: [178]\nClone at x: [6644] y: [-72]\nClone at x: [8443] y: [100000]\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\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 [clone v] by (1)\ncreate clone of (_myself_ v)\n\nif <(Checkpoint) = [3]> then\n    set [checkpoint v] to [4]\n    delete this clone\nend\n\ndelete this clone\n\n@check piont3\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <touching (player v)?> then\n    set [ghost affect v] to [0]\n    start sound [Connect v]\n    switch costume to (flag2 v)\n    set [ghost v] effect to (0)\n    broadcast (Checkpoint  v)\n    repeat until <(ghost affect) = [100]>\n        change [ghost v] effect by (1)\n        change [ghost affect v] by (1)\n    end\n    set [checkpoint v] to [3]\n    delete this clone\nend\n\nwhen I receive [set up v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nset [clone v] to [0]\nswitch costume to (flag v)\nif <(Level:) = [1]> then\n    Clone at x: [6644] y: [-72]\n    set [x v] to [-999999999999999999999999]\nelse\n    set [x v] to [-999999999999999999999999]\nend\n\nClone at x: [1959] y: [178]\nClone at x: [4320] y: [-76]\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\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 [clone v] by (1)\ncreate clone of (_myself_ v)\n\nif <(Checkpoint) = [0]> then\n    set [checkpoint v] to [1]\nend\n\nClone at x: [8443] y: [100000]\n\nif <(Checkpoint) = [3]> then\n    set [checkpoint v] to [4]\n    delete this clone\nend\n\ndelete this clone\n\n
WASD, arrow keys, or tap and drag to move\n----------------------------------------------------------\nOne long level with several checkpoints\n---------------------------------------------------------\nATTENTION: this is not my best work it is a rushed game in order to finish before several contest due dates\n----------------------------------------------------------\nThis is my contest entry \n-------------------------------------------------------------\nDon't forget to ❤️, ⭐️ and follow