scrolling platformer  

Instructions: arrow keys,mouse pointer or mobile\n\nPlease join my contest: https://scratch.mit.edu/projects/548542331/\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n#Games #Games #Games #Games #Games #Games #Games #Games #Games #Games #Games #Games #Games #Games #Games #Games #Games #Games 

@Stage\n\n@Thumbnail\n\nwhen flag clicked\ngo to [front v] layer\nrepeat (40)\n    change [ghost v] effect by (3)\nend\n\nswitch costume to (th v)\nshow\npoint in direction (90)\ngo to x: (0) y: (0)\nclear graphic effects\n\ngo to [back v] layer\nhide\n\nwhen flag clicked\nforever\n    play sound [Unlimited v] until done\nend\n\n@Sun\n\nwhen flag clicked\nforever\n    show\n    go to [front v] layer\n    set size to (100) %\n    clear graphic effects\n    set x to (0)\n    set y to (0)\n    point in direction (90)\n    go to x: (0) y: (0)\nend\n\n@Sprite2\n\nwhen [space v] key pressed\nwait until <not <key (space v) pressed?>>\nrepeat until <key (space v) pressed?>\n    show\nend\nhide\n\nwhen flag clicked\nhide\n\n@Effec\n\nwhen I start as a clone\nshow\ngo to [back v] layer\nif <(CloneID) = [1]> then\n    hide\n    set [color v] effect to (0)\n    set [coloreffec v] to (pick random (2) to (3))\n    go to (player v)\n    set [y v] to (([y position v] of [player v]) - (150))\n    fly\n    boom\nelse\n    change [color v] effect by (pick random (0) to (100))\n    set [xv v] to (pick random (-12) to (12))\n    set [yv v] to (pick random (0) to (20))\n    show\n    repeat until <(y position) < [-170]>\n        Physics\n    end\nend\ndelete this clone\n\ndefine boom\nbroadcast (boom v)\nset [cloneid v] to [2]\nrepeat (10)\n    create clone of (_myself_ v)\nend\n\ndefine Physics\nset size to ((190) + ((Yv) * (8))) %\nchange [yv v] by (-1)\nset [xv v] to ((Xv) * (0.92))\nset [yv v] to ((Yv) * (0.92))\nchange x by (Xv)\nchange y by (Yv)\n\nwhen I start as a clone\nif <(CloneID) = [2]> then\n    wait (0.5) seconds\n    repeat (25)\n        change [ghost v] effect by (30)\n    end\n    delete this clone\nend\n\nwhen flag clicked\nhide\ndelete this clone\n\ndefine fly\nrepeat (16)\n    change [y v] by (14)\n    set y to (Y)\n    if <(y position) > [-175]> then\n        show\n    end\nend\n\nwhen I receive [die v]\nhide\nset [cloneid v] to [1]\nrepeat (5)\n    create clone of (_myself_ v)\nend\n\n@Platforms\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((Platforms: x) - (SCROLL X)) ((Platforms: y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [platforms: x v] to [0]\nset [platforms: y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1-1 v)\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\nend\nif <(LEVEL) = [2]> then\n    switch costume to (level 2-1 v)\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [450] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\nend\nif <(LEVEL) = [3]> then\n    switch costume to (end! v)\nend\n\nClone At x: [360] y: [0]\nClone At x: [360] y: [0]\nClone At x: [360] y: [0]\nClone At x: [360] y: [0]\nClone At x: [360] y: [0]\nClone At x: [360] y: [0]\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 [platforms: x v] by (x)\nchange [platforms: y v] by (y)\nnext costume\n\nwhen flag clicked\nset [level v] to [1]\n\nswitch backdrop to (backdrop1 v)\n\nwhen flag clicked\nforever\n    if <(LEVEL) = [3]> then\n        switch costume to (end! v)\n    end\nend\n\n@Exit Portal\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nset [collected max v] to [1]\nPosition ((Exit Portal: x) - (SCROLL X)) ((Exit Portal: y) - (SCROLL Y))\nif <<(costume [name v]) = [OPENED]> and <touching (player v)?>> then\n    set [exit v] to [Win]\nend\nforever\n    if <(COLLECTED) = (COLLECTED MAX)> then\n        switch costume to (opened v)\n    else\n        switch costume to (closed v)\n    end\nend\n\nwhen I receive [setup v]\nhide\nset [collected max v] to [1]\nset [exit portal: x v] to [0]\nset [exit portal: y v] to [0]\nif <(LEVEL) = [1]> then\n    Clone At x: [2450] y: [100]\nelse\n    set [collected max v] to [2]\n    Clone At x: [2237] y: [240]\nend\nif <(LEVEL) = [2]> then\n    hide\nend\n\ndefine Position (x) (y)\ngo [backward v] (99) layers\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 [exit portal: x v] to (x)\nset [exit portal: y v] to (y)\n\nwhen I receive [open portal v]\nswitch costume to (opened v)\n\nwhen I receive [tick v]\nforever\n    wait (0.5) seconds\n    set [ghost v] effect to (100)\n    wait (0.5) seconds\n    set [ghost v] effect to (0)\n    wait (0.5) seconds\nend\n\n@coins\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [tick v]\nPosition ((Ingots: x) - (SCROLL X)) ((Ingots: y) - (SCROLL Y))\nif <touching (player v)?> then\n    start sound [Coin v]\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\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 [ingots: x v] to (x)\nset [ingots: y v] to (y)\nchange [collected max v] by (1)\ncreate clone of (_myself_ v)\n\nwhen I receive [setup v]\nhide\nset [collected v] to [0]\nset [collected max v] to [0]\nset [ingots: x v] to [0]\nset [ingots: y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (costume1 v)\n    Clone At x: [440] y: [150]\nelse\n    if <(LEVEL) = [2]> then\n        Clone At x: [540] y: [30]\n    else\n        switch costume to (costume9 v)\n    end\nend\nset [ingots: x v] to [-99999]\n\nwhen I receive [tick v]\nforever\n    next costume\nend\n\nchange [level v] by (1)\n\n@Danger\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((Platforms: x) - (SCROLL X)) ((Platforms: y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [platforms: x v] to [0]\nset [platforms: y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1-1 v)\n    Clone At x: [00] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\nend\nif <(LEVEL) = [2]> then\n    switch costume to (level 2-1 v)\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [450] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\n    Clone At x: [360] y: [0]\nend\nif <(LEVEL) = [3]> then\n    switch costume to (end! v)\nend\n\nClone At x: [360] y: [0]\nClone At x: [360] y: [0]\nClone At x: [360] y: [0]\nClone At x: [360] y: [0]\nClone At x: [360] y: [0]\nClone At x: [360] y: [0]\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 [platforms: x v] by (x)\nchange [platforms: y v] by (y)\nnext costume\n\nwhen flag clicked\nset [level v] to [1]\n\nswitch backdrop to (backdrop1 v)\n\n@Player\n\nwhen I start as a clone\nswitch costume to (trail v)\nrepeat (10)\n    change size by (-7)\n    change [ghost v] effect by (15)\nend\ndelete this clone\n\ndefine Change Player Y By (sy)\nchange [player: y v] by (sy)\nchange [in air v] by (1)\nPosition\nrepeat until <not <touching (platforms v)?>>\n    if <(sy) > [0]> then\n        change [player: y v] by (-1)\n    else\n        change [player: y v] by (1)\n        set [in air v] to [0]\n    end\n    Position\n    set [sy v] to [0]\nend\n\ndefine Change Player X By (sx)\nchange [player: x v] by (sx)\nPosition\nif <touching (platforms v)?> then\n    repeat (12)\n        change [player: y v] by (1)\n        Position\n        if <not <touching (platforms v)?>> then\n            stop [this script v]\n        end\n    end\n    change [player: y v] by (-12)\n    repeat until <not <touching (platforms v)?>>\n        if <(sx) > [0]> then\n            change [player: x v] by (-1)\n        else\n            change [player: x v] by (1)\n        end\n        Position\n    end\nend\n\ndefine Tick\nif <<key (left arrow v) pressed?> or <<key (a v) pressed?> or <<mouse down?> and <(x position) > (mouse x)>>>> then\n    Change Player X By [-8]\n    point in direction (-90)\nend\nif <<key (right arrow v) pressed?> or <<key (d v) pressed?> or <<mouse down?> and <(mouse x) > (x position)>>>> then\n    Change Player X By [8]\n    point in direction (90)\nend\nif <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > (y position)>>> then\n    if <(in air) < [4]> then\n        set [sy v] to [16]\n    end\nend\nchange [sy v] by (-2)\nChange Player Y By (sy)\nTest - Die\nset [add v] to (join (COLLECTED) (join [ ] (join [/] (join [ ] (COLLECTED MAX)))))\nchange [scroll x v] by (round (((Player: x) - (SCROLL X)) / (10)))\nif <(SCROLL X) < [0]> then\n    set [scroll x v] to [0]\nend\nchange [scroll y v] by (round (((Player: y) - (SCROLL Y)) / (10)))\nif <(SCROLL Y) < [0]> then\n    set [scroll y v] to [0]\nend\nPosition\nif <(Player: y) < [-180]> then\n    set [exit v] to [Die]\nend\n\ndefine Game On\nset [player: x v] to [0]\nset [player: y v] to [0]\nset [scroll x v] to [0]\nset [scroll y 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 (80) %\nset [ghost v] effect to (0)\nshow\n\ndefine Test - Die\nif <touching (danger v)?> then\n    set [exit v] to [Die]\nend\n\ndefine Game - Win\nrepeat (50)\n    create clone of (_myself_ v)\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\nchange [level v] by (1)\nwait (1) seconds\n\ndefine Game - Die\nbroadcast (die v)\nset [exit v] to []\nrepeat (5)\n    set [brightness v] effect to (100)\n    wait (0.1) seconds\n    set [brightness v] effect to (0)\n    wait (0.1) seconds\nend\nclear graphic effects\nhide\nwait (0.5) seconds\n\ndefine Position\ngo to x: ((Player: x) - (SCROLL X)) y: ((Player: y) - (SCROLL Y))\n\nwhen I receive [play game v]\nset [level v] to [1]\nforever\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)\n    end\n    if <(EXIT) = [Win]> then\n        Game - Win\n    else\n        Game - Die\n    end\nend\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\ngo [backward v] (1) layers\n\nwhen flag clicked\nbroadcast (Green Flag v) and wait\nbroadcast (Play Game v) and wait\n\nwhen I receive [tick v]\ncreate clone of (stamp v)\n\nwhen flag clicked\nforever\n    wait (pick random (3) to (5)) seconds\n    switch costume to (1 v)\n    repeat (16)\n        next costume\n    end\nend\n\nwhen flag clicked\nswitch costume to (1 v)\n\nwhen flag clicked\nclear graphic effects\n\nwhen flag clicked\nforever\n    create clone of (_myself_ v)\nend\n\nwhen flag clicked\nforever\n    if <(LEVEL) = [3]> then\nend\n\n