Scratch— A Mobile Platformer


@Stage\n\nwhen I receive [green flag clicked v]\nforever\n    wait (1) seconds\n    play sound [Music3 v] until done\n    play sound [\[8-BIT_One_Republic_-_Counting_Stars4 v] until done\nend\n\n@Player\n\nwhen I receive [green flag clicked v]\nset size to (40) %\nset rotation style [left-right v]\ngo to x: (-200) y: (100)\nshow\ngo to [front v] layer\nset [speed y v] to [0]\nset [falling? v] to [10]\nforever\n    set [color v] effect to (Color)\n    switch costume to (costume2 v)\n    if <<(speed y) < [4]> or <<key (w v) pressed?> or <<key (space v) pressed?> or <<key (up arrow v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>>>>> then\n        change [speed y v] by (-1)\n    else\n        change [speed y v] by (-2)\n    end\n    change y by (speed y)\n    Touch Ground <(speed y) > [0]>\n    if <(wall jump) > [0]> then\n        change [wall jump v] by (-1)\n    else\n        set [speed x v] to ((speed x) * (0.7))\n        if <<key (left arrow v) pressed?> or <<key (a v) pressed?> or <<mouse down?> and <(x position) > (mouse x)>>>> then\n            change [speed x v] by (-1.5)\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 [speed x v] by (1.5)\n        end\n    end\n    if <(speed x) < [-0.5]> then\n        Walk (-90) (speed x)\n    else\n        if <(speed x) > [0.5]> then\n            Walk (90) (speed x)\n        else\n            set [frame v] to [0]\n        end\n    end\n    if <<key (w v) pressed?> or <<key (space v) pressed?> or <<key (up arrow v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>>>> then\n        if <<(jump key) = [0]> and <(falling?) < [3]>> then\n            set [speed y v] to [14]\n            set [falling? v] to [6]\n            set [jump key v] to [1]\n        end\n    else\n        set [jump key v] to [0]\n    end\n    if <(y position) < [-180]> then\n        go to x: (-200) y: (100)\n        set [speed y v] to [0]\n    end\n    if <(x position) > [220]> then\n        go to x: (-200) y: (100)\n        broadcast (Next level v)\n    end\n    if <touching (spikes v)?> then\n        broadcast (Die v)\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n        set [ghost v] effect to (0)\n        go to x: (-200) y: (100)\n    end\n    Set Costume\nend\n\ndefine Walk (direction) (speed)\npoint in direction (direction)\nchange x by (speed)\nset [slope v] to [0]\nrepeat until <<(slope) = [8]> or <not <touching (ground v)?>>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <(slope) = [8]> then\n    change x by ((0) - (speed))\n    change y by ((0) - (slope))\n    if <<<key (w v) pressed?> or <<key (space v) pressed?> or <<key (up arrow v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>>>> and <([abs v] of (speed) ) > [3]>> then\n        if <(wall jump) = [0]> then\n            set [speed x v] to ((-1.2) * (speed))\n            set [speed y v] to [11]\n            set [falling? v] to [6]\n            set [wall jump v] to [15]\n        end\n    else\n        set [speed x v] to [0]\n    end\nend\nif <(speed) < [0]> then\n    change [frame v] by ((speed) / (-10))\nelse\n    change [frame v] by ((speed) / (10))\nend\n\ndefine Touch Ground <up?>\nchange [falling? v] by (1)\nrepeat until <not <touching (ground v)?>>\n    if <up?> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling? v] to [0]\n    end\n    set [speed y v] to [0]\nend\n\ndefine Set Costume\nswitch costume to (costume2 v)\n\nwhen I start as a clone\nswitch costume to (costume3 v)\nset [ghost v] effect to (10)\nrepeat (10)\n    change size by (-1)\n    set [color v] effect to (Color)\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nwhen I receive [green flag clicked v]\nforever\n    create clone of (_myself_ v)\nend\n\nwhen I receive [next level v]\nset size to (40) %\nset rotation style [left-right v]\ngo to x: (-200) y: (100)\nshow\nset [speed y v] to [0]\nset [falling? v] to [10]\n\nwhen I receive [restart v]\nset size to (40) %\nset rotation style [left-right v]\ngo to x: (-200) y: (100)\nshow\nset [speed y v] to [0]\nset [falling? v] to [10]\n\n@Light\n\nwhen flag clicked\nforever\n    go to (player v)\n    set [color v] effect to (Color)\nend\n\nwhen flag clicked\nhide\nforever\n    set [color v] effect to (Color)\n    set [ghost v] effect to (0)\nend\n\nwhen I receive [green flag clicked v]\nshow\n\n@Ground\n\nwhen I receive [next level v]\nif <not <(costume [number v]) = [13]>> then\n    next costume\n    next backdrop\nend\n\nwhen I receive [green flag clicked v]\nswitch backdrop to (backdrop1 v)\nswitch costume to (costume1 v)\n\n@Particles\n\nwhen I start as a clone\nshow\ngo to (player v)\npoint in direction (pick random (-180) to (180))\ngo to [back v] layer\nrepeat until <<(distance to [player v]) > [50]> or <touching (_edge_ v)?>>\n    set [color v] effect to (pick random (1) to (100))\n    move (-1) steps\n    set [ghost v] effect to (distance to [player v])\nend\ndelete this clone\n\nwhen flag clicked\nswitch costume to (costume1 v)\nhide\nforever\n    set [color v] effect to (Color)\nend\n\nwhen I receive [green flag clicked v]\nshow\nforever\n    hide\n    create clone of (_myself_ v)\n    change [color v] effect by (2)\n    wait (.00001) seconds\nend\n\n@Spikes\n\nwhen flag clicked\nswitch costume to (costume2 v)\n\nwhen I receive [next level v]\nif <not <(costume [number v]) = [13]>> then\n    next costume\nend\n\nwhen flag clicked\nforever\n    set [color v] effect to (Color)\nend\n\n@TN\n\nwhen flag clicked\nset [ghost v] effect to (0)\nwait (1) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\n    broadcast (Green Flag clicked v)\nend\nforever\n    show\n    go to [front v] layer\n    set [ghost v] effect to (100)\nend\n\n@Background stuff\n\nwhen I start as a clone\nshow\ngo to [back v] layer\npoint in direction (pick random (-70) to (-100))\ngo to x: (300) y: (pick random (-180) to (180))\nset size to (pick random (10) to (30)) %\nset [ghost v] effect to (pick random (5) to (95))\nif <(pick random (1) to (3)) = [3]> then\n    go to [back v] layer\nelse\n    go to [front v] layer\nend\nrepeat until <(x position) < [-220]>\n    move (8) steps\nend\ndelete this clone\n\nwhen flag clicked\nforever\n    hide\n    create clone of (_myself_ v)\n    wait (0.02) seconds\nend\n\n@Skip\n\nwhen flag clicked\nhide\n\nwhen I receive [green flag clicked v]\nwait (0.01) seconds\ngo to [front v] layer\nshow\nforever\n    point in direction ((([sin v] of ((timer) * (300)) ) * (10)) + (90))\nend\n\nwhen this sprite clicked\nbroadcast (Next level v)\n\n@Restart\n\nwhen flag clicked\nhide\n\nwhen I receive [green flag clicked v]\nwait (0.01) seconds\ngo to [front v] layer\nshow\nforever\n    point in direction ((([sin v] of ((timer) * (300)) ) * (10)) + (90))\nend\n\nwhen this sprite clicked\nbroadcast (Restart v)\n\n@Background stuff2\n\nwhen I start as a clone\nshow\ngo to [back v] layer\npoint in direction (pick random (-70) to (-100))\ngo to x: (300) y: (pick random (-180) to (180))\nset size to (pick random (10) to (50)) %\nset [ghost v] effect to (pick random (70) to (95))\ngo to [back v] layer\nrepeat until <(x position) < [-220]>\n    move (3) steps\nend\ndelete this clone\n\nwhen flag clicked\nforever\n    hide\n    create clone of (_myself_ v)\n    wait (0.5) seconds\nend\n\n