Notebook __ A Platformer

Instructions: WAD or arrows key or tap to move.

@Stage\n\nwhen I receive [next level v]\nnext backdrop\n\nwhen I receive [sg v]\nswitch backdrop to (notebook v)\nrepeat until <(level) = [10]>\n    play sound (join [1] []) until done\nend\n\n@Player\n\nwhen flag clicked\nbroadcast (intro v) and wait\nbroadcast (sg v)\nset [level v] to [0]\nrepeat until <(level) = [10]>\n    show\n    go to x: (-215) y: (-104)\n    point in direction (90)\n    set [x velocity v] to [0]\n    set [y velocity v] to [0]\n    repeat until <<touching (flag v)?> or <touching (danger v)?>>\n        Move <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<(mouse x) < (x position)> and <mouse down?>>> <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<(mouse x) > (x position)> and <mouse down?>>> <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<(mouse y) > (y position)> and <mouse down?>>> Jump Height [4] Friction [0.85] Walk Speed [1.5] Fall Speed [1.5] Slope Height [12]\n    end\n    if <touching (flag v)?> then\n        broadcast (Next Level v)\n        change [level v] by (1)\n    end\nend\nhide\nbroadcast (w v)\nset [_outro? v] to [1]\n\ndefine Move <left> <right> <up> Jump Height (jump height) Friction (friction) Walk Speed (walk speed) Fall Speed (fall speed) Slope Height (slope height)\nif <left> then\n    change [x velocity v] by ((walk speed) * (-1))\nend\nif <right> then\n    change [x velocity v] by (walk speed)\nend\nif <up> then\n    if <(Jump) < (jump height)> then\n        set [y velocity v] to ((walk speed) * (8))\n        change [jump v] by (1)\n    end\nend\nif <touching (trampoline v)?> then\n    set [y velocity v] to ((walk speed) * (15))\n    set [jump v] to [4]\n    start sound [Big Boing v]\nend\nset [x velocity v] to ((X Velocity) * (friction))\nchange [y velocity v] by ((fall speed) * (-1))\nchange y by (round (Y Velocity))\nif <touching (platform v)?> then\n    repeat until <not <touching (platform v)?>>\n        if <(Y Velocity) > [0]> then\n            change y by (-1)\n        else\n            if <(Y Velocity) < [0]> then\n                change y by (1)\n            end\n        end\n    end\n    if <(Y Velocity) < [0]> then\n        set [jump v] to [0]\n    end\n    set [y velocity v] to [0]\nend\nchange x by (round (X Velocity))\nif <touching (platform v)?> then\n    set [slope v] to [0]\n    repeat (slope height)\n        if <(Slope) = [0]> then\n            change y by (1)\n            if <not <touching (platform v)?>> then\n                set [slope v] to [1]\n            end\n        end\n    end\n    if <(Slope) = [0]> then\n        change y by ((slope height) * (-1))\n        repeat until <not <touching (platform v)?>>\n            if <(X Velocity) > [0]> then\n                change x by (-1)\n            else\n                if <(X Velocity) < [0]> then\n                    change x by (1)\n                end\n            end\n        end\n        if <up> then\n            if <(X Velocity) > [0]> then\n                set [x velocity v] to ((walk speed) * (-8))\n            else\n                if <(X Velocity) < [0]> then\n                    set [x velocity v] to ((walk speed) * (8))\n                end\n            end\n            set [jump v] to [0]\n        else\n            set [x velocity v] to [0]\n        end\n    end\nend\nif <(x position) < [-215]> then\n    set x to (-215)\nend\nif <[215] < (x position)> then\n    set x to (215)\nend\n\n@Platform\n\nwhen I receive [next level v]\nnext costume\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nwhen flag clicked\nshow\nforever\n    if <(_OUTRO?) = [1]> then\n        hide\n    end\nend\n\nwhen [timer v] > (t)\nhide\n\n@Danger\n\nwhen I receive [next level v]\nnext costume\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nwhen flag clicked\nforever\n    go to x: (0) y: (-35)\n    if <<(costume [number v]) = [3]> or <(costume [number v]) = [5]>> then\n        point in direction (90)\n        go to x: (0) y: ((-30) + (([sin v] of ((timer) * (250)) ) * (5)))\n    end\n    if <(costume [number v]) = [8]> then\n        go to x: (0) y: ((10) + (([sin v] of ((timer) * (250)) ) * (70)))\n        point in direction ((timer) * (250))\n    end\n    if <(costume [number v]) = [9]> then\n        go to x: (0) y: ((-30) + (([sin v] of ((timer) * (250)) ) * (70)))\n        point in direction ((timer) * (250))\n    end\nend\n\n@Text\n\nwhen I receive [next level v]\nnext costume\n\nwhen flag clicked\nshow\nswitch costume to (costume1 v)\n\nwhen I receive [w v]\nhide\n\n@Flag\n\nwhen I receive [next level v]\nnext costume\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nwhen flag clicked\nshow\nforever\n    if <(_OUTRO?) = [1]> then\n        hide\n    end\nend\n\nwhen [timer v] > (t)\nhide\n\n@Trampoline\n\nwhen flag clicked\nshow\nswitch costume to (costume1 v)\n\nwhen I receive [next level v]\nnext costume\n\nwhen [timer v] > (t)\nhide\n\n@intro\n\nwhen I receive [intro v]\nshow\nreset timer\nclear graphic effects\ngo to x: (0) y: (0)\nstart sound (pick random (1) to (1))\nswitch costume to (bg v)\ncreate clone of (_myself_ v)\nswitch costume to (blank v)\nset size to (300) %\nswitch costume to (lines v)\ngo to x: (0) y: (-300)\nset [id var v] to [0]\nrepeat (4)\n    change [id var v] by (1)\n    create clone of (_myself_ v)\n    set [ghost v] effect to (100)\n    set [size v] to [50]\nend\nwait until <(timer) > [1.5]>\nswitch costume to (tyr v)\ncreate clone of (_myself_ v)\nwait until <(timer) > [3]>\nswitch costume to (yourentan v)\ncreate clone of (_myself_ v)\nwait until <(timer) > [5.5]>\nrepeat (4)\n    switch costume to (blank v)\n    set size to (1000) %\n    switch costume to (rectangles v)\n    go to x: (-480) y: (360)\n    create clone of (_myself_ v)\n    change [brightness v] effect by (-2)\n    wait (0.05) seconds\nend\nset size to (100) %\nhide\n\nwhen I start as a clone\nif <(costume [number v]) = [1]> then\n    wait until <(timer) > [7]>\n    delete this clone\nend\nif <(costume [number v]) = [2]> then\n    repeat until <([abs v] of (((-240) + ((id var) * (120))) - (y position)) ) < [1]>\n        switch costume to (blank v)\n        set size to (300) %\n        switch costume to (lines v)\n        change y by ((((-240) + ((id var) * (120))) - (y position)) / (10))\n        change [ghost v] effect by (-4)\n        change [size v] by (3)\n        set size to (size) %\n    end\n    wait until <(timer) > [2.7]>\n    glide (0.2) secs to x: (900) y: (y position)\n    hide\nend\nif <(costume [number v]) = [4]> then\n    set size to (50) %\n    go to x: (x position) y: ((y position) * (-0.4))\n    repeat until <([abs v] of ((0) - (y position)) ) < [1]>\n        change y by (((0) - (y position)) / (10))\n        change [ghost v] effect by (-5)\n        change size by (((150) - (size)) / (10))\n    end\n    wait until <(timer) > [2.7]>\n    glide (0.2) secs to x: (500) y: (y position)\n    hide\nend\nif <(costume [number v]) = [5]> then\n    set size to (100) %\n    clear graphic effects\n    go to x: (x position) y: ((y position) * (-1))\n    repeat until <([abs v] of ((0) - (y position)) ) < [1]>\n        change y by (((0) - (y position)) / (10))\n        point in direction ((90) + ([tan v] of (((timer) + (1)) * (50)) ))\n    end\n    repeat (10)\n        point in direction ((90) + ([tan v] of (((timer) + (1)) * (50)) ))\n    end\n    repeat (8)\n        change x by (30)\n        change size by (-2)\n        change [ghost v] effect by (5)\n    end\n    hide\nend\nif <(costume [number v]) = [6]> then\n    repeat until <([abs v] of ((0) - (y position)) ) < [1]>\n        switch costume to (blank v)\n        set size to (1000) %\n        switch costume to (rectangles v)\n        change y by (((0) - (y position)) / (5))\n        change x by (((0) - (x position)) / (5))\n        set size to (100) %\n        change [ghost v] effect by (((0) - ((x position) / (-4.8))) / (5))\n        change [iv v] by (-2)\n    end\n    go to x: (0) y: (0)\n    wait until <(timer) > [7]>\n    repeat (20)\n        change [ghost v] effect by (5)\n        change [brightness v] effect by (5)\n    end\n    delete this clone\nend\n\nwhen flag clicked\nset [iv v] to [100]\nforever\n    set volume to (IV) %\nend\n\nwhen [timer v] > (t)\nhide\n\n@Outro\n\nwhen flag clicked\nhide\nset size to (100) %\nset [_outro? v] to [0]\nwait until <(_OUTRO?) = [1]>\nstop all sounds\nClone Costume [1] x [0] y [70]\nClone Costume [2] x [0] y [0]\nClone Costume [3] x [0] y [0]\nClone Costume [4] x [0] y [-50]\nClone Costume [5] x [0] y [0]\n\ndefine Clone Costume (costume) x (x) y (y)\ngo to x: (x) y: (y)\nswitch costume to (costume)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nwait until <(_OUTRO?) = [2]>\nif <(costume [number v]) = [1]> then\n    show\n    set size to (5) %\n    set [ghost v] effect to (100)\n    repeat until <(size) = [60]>\n        change [ghost v] effect by ((((100) - (size)) / (10)) * (-1))\n        change size by (((60) - (size)) / (10))\n        set y to ((115) + (([sin v] of ((timer) * (300)) ) * (10)))\n        point in direction ((90) + (([cos v] of ((timer) * (150)) ) * (3)))\n    end\n    \n        set y to ((115) + (([sin v] of ((timer) * (300)) ) * (10)))\n        point in direction ((90) + (([cos v] of ((timer) * (150)) ) * (3)))\n    end\nend\nif <(costume [number v]) = [2]> then\n    point in direction (90)\n    show\n    go to [back v] layer\nend\nif <(costume [number v]) = [3]> then\n    show\n    set x to (-240)\n    repeat until <(x position) = [0]>\n        change [ghost v] effect by ((((0) - (x position)) / (10)) * (-1))\n        change x by (((x position) * (-1)) / (10))\n        set y to ((-50) + (([sin v] of ((timer) * (300)) ) * (10)))\n        point in direction ((90) + (([tan v] of ((timer) * (80)) ) * (2)))\n    end\n    \n        set y to ((-50) + (([sin v] of ((timer) * (300)) ) * (10)))\n        point in direction ((90) + (([tan v] of ((timer) * (80)) ) * (2)))\n    end\nend\nif <(costume [number v]) = [4]> then\n    show\n    set size to (5) %\n    set [ghost v] effect to (100)\n    repeat until <(size) = [70]>\n        change [ghost v] effect by ((((100) - (size)) / (10)) * (-1))\n        change size by (((70) - (size)) / (10))\n        set x to (140)\n        set y to ((-50) + (([sin v] of ((timer) * (300)) ) * (10)))\n        point in direction ((90) + (([cos v] of ((timer) * (200)) ) * (2)))\n    end\n    set size to (70) %\n    \n        set x to (140)\n        set y to ((-50) + (([sin v] of ((timer) * (300)) ) * (10)))\n        set size to (70) %\n        go to [front v] layer\n        go [backward v] (1) layers\n        point in direction ((90) + (([cos v] of ((timer) * (200)) ) * (2)))\n    end\nend\n\nwhen I start as a clone\nif <(costume [number v]) = [5]> then\n    show\n    set [ghost v] effect to (100)\n    repeat (10)\n        change [ghost v] effect by (-10)\n    end\n    wait (0.5) seconds\n    set [_outro? v] to [2]\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\nend\n\nwhen flag clicked\nwait until <(_OUTRO?) = [2]>\nforever\n    play sound [676545 v] until done\nend\n\n@TN\n\nwhen flag clicked\nshow\ngo to x: (0) y: (0)\nset size to (100) %\nset [ghost v] effect to (100)\nswitch costume to (costume2 v)\ncreate clone of (_myself_ v)\nswitch costume to (costume1 v)\nforever\n    set [t v] to (timer)\nend\n\nwhen [timer v] > (t)\nclear graphic effects\nrepeat (10)\n    change size by (0.5)\nend\n\n