Mobile platformer: Tutorial


@Stage\n\nwhen I receive [begin early v]\nforever\n    play sound [Kevin MacLeod - Not As It Seems v] until done\nend\n\n@Blank\n\n@Blank2\n\n@Blank3\n\n@TN\n\nwhen flag clicked\nset [ghost v] effect to (100)\ngo to [front v] layer\n\n@Speeder\n\nwhen I receive [next level v]\nswitch costume to (Level)\n\nwhen I receive [setup v]\nswitch costume to (level 1 v)\n\n@ clouds\n\nwhen I start as a clone\nset size to (pick random (50) to (80)) %\nshow\ngo to [back v] layer\nset [ghost v] effect to (20)\nswitch costume to (pick random (1) to (5))\nif <(side) = [1]> then\n    go to x: (300) y: (pick random (150) to (100))\n    repeat until <(x position) < [-250]>\n        change x by (-1)\n    end\n    delete this clone\nend\nif <(side) = [2]> then\n    go to x: (-300) y: (pick random (150) to (100))\n    repeat until <(x position) > [250]>\n        change x by (1)\n    end\n    delete this clone\nend\n\nwhen I start as a clone\nforever\n    go [backward v] (1) layers\n    go to [back v] layer\nend\n\nwhen I receive [ready v]\nforever\n    set [side v] to (pick random (1) to (2))\n    create clone of (_myself_ v)\n    wait (pick random (3) to (4)) seconds\nend\n\nwhen I receive [setup v]\nhide\n\nwhen I receive [ready v]\nhide\n\n@Player\n\nwhen flag clicked\nbroadcast (Setup v) and wait\nbroadcast (Start Intro v)\n\nwhen I receive [ready v]\nforever\n    broadcast (Tick v)\nend\n\nwhen I receive [tick v]\nControls Up/Down\nControls Left/Right\nMove - In Steps (([abs v] of (speed x) ) + ([abs v] of (speed y) ))\nExtra Collisions\n\ndefine Controls Up/Down\nswitch costume to (idle v)\nchange [speed y v] by (GRAVITY)\nif <<<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<(mouse y) > ((y position) + (10))> and <mouse down?>>>> and <(falling) < [3]>> then\n    set [speed y v] to (JUMP HEIGHT)\nend\n\ndefine Controls Left/Right\nif <<key (left arrow v) pressed?> or <<key (a v) pressed?> or <<(mouse x) < (x position)> and <mouse down?>>>> then\n    switch costume to (left v)\n    change [speed x v] by ((0) - (SPEED))\n    if <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<(mouse y) > ((y position) + (10))> and <mouse down?>>>> then\n        switch costume to (upleft v)\n    end\nend\nif <<key (right arrow v) pressed?> or <<key (d v) pressed?> or <<(mouse x) > (x position)> and <mouse down?>>>> then\n    switch costume to (right v)\n    change [speed x v] by (SPEED)\n    if <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<(mouse y) > ((y position) + (10))> and <mouse down?>>>> then\n        switch costume to (upright v)\n    end\nend\nif <<key (down arrow v) pressed?> or <<key (s v) pressed?> or <<(mouse y) < (y position)> and <mouse down?>>>> then\n    switch costume to (crouched v)\n    set [speed v] to [0.7]\nelse\n    set [speed v] to [1.5]\n    Should Crouch?\nend\nset [speed x v] to ((speed x) * (0.8))\n\ndefine Move - In Steps (steps)\nchange [falling v] by (1)\nrepeat (steps)\n    set [last value v] to (x position)\n    change x by ((speed x) / (steps))\n    if <touching (levels v)?> then\n        set x to (last value)\n        if <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<(mouse y) > ((y position) + (10))> and <mouse down?>>>> then\n            set [speed y v] to (JUMP HEIGHT)\n            if <(speed x) > [0]> then\n                set [speed x v] to ((0) - (WALL JUMP KICK))\n            else\n                set [speed x v] to (WALL JUMP KICK)\n            end\n        else\n            set [speed x v] to [0]\n        end\n    end\n    set [last value v] to (y position)\n    change y by ((speed y) / (steps))\n    if <touching (levels v)?> then\n        set y to (last value)\n        if <(speed y) < [0]> then\n            set [falling v] to [0]\n        end\n        set [speed y v] to [0]\n    end\nend\n\nwhen I receive [setup v]\ngo to x: (-190) y: (0)\nset [gravity v] to [-1]\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [falling v] to [10]\nset [level v] to [1]\nset [speed v] to [1.5]\nset [jump height v] to [10]\nset [wall jump kick v] to [15]\n\ndefine Extra Collisions\nif <<touching (danger v)?> or <<touching (lava v)?> or <(y position) < [-178]>>> then\n    start sound [Crunch v]\n    broadcast (Reset v)\nend\nif <<(x position) > [239]> and <(Level) < [11]>> then\n    if <(COLLECTED) = (COLLECTED MAX)> then\n        change [level v] by (1)\n        broadcast (Reset v)\n        broadcast (Next Level v)\n    else\n        broadcast (No Treats v)\n    end\nend\nif <touching (water v)?> then\n    if <(IN WATER) = [0]> then\n        set [speed y v] to [0]\n        set [in water v] to [1]\n    end\n    set [gravity v] to [-0.2]\n    set [jump height v] to [6]\n    set [wall jump kick v] to [10]\n    if <<key (down arrow v) pressed?> or <<key (s v) pressed?> or <<(mouse y) < (y position)> and <mouse down?>>>> then\n        set [speed v] to [0.4]\n    else\n        set [speed v] to [1]\n    end\nelse\n    set [in water v] to [0]\n    set [gravity v] to [-1]\n    set [jump height v] to [10]\n    set [wall jump kick v] to [15]\n    if <<key (down arrow v) pressed?> or <<key (s v) pressed?> or <<(mouse y) < (y position)> and <mouse down?>>>> then\n        set [speed v] to [0.7]\n    else\n        set [speed v] to [1.5]\n    end\nend\nif <touching (speeder v)?> then\n    set [speed x v] to [20]\nend\n\nwhen I receive [reset v]\ngo to x: (-190) y: (0)\nset size to (100) %\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [falling v] to [10]\n\nwhen I receive [end intro v]\nbroadcast (Begin Early v)\nbroadcast (Ready v)\n\nwhen I receive [bounce v]\nset [speed y v] to [20]\n\ndefine Should Crouch?\nset [costume v] to (costume [number v])\nif <touching (levels v)?> then\n    switch costume to (crouched v)\n    if <not <touching (levels v)?>> then\n        set [speed v] to [0.7]\n        stop [this script v]\n    else\n        switch costume to (costume)\n    end\nend\n\nwhen I receive [extra jump v]\nset [speed y v] to (JUMP HEIGHT)\n\n@Intro\n\ndefine RESET\ndelete all of [duxxsync v]\nadd [100] to [duxxsync v]\nadd [0] to [duxxsync v]\nhide\nreset timer\nstart sound [Skylike - Higher v]\nclear graphic effects\ndelete this clone\n\ndefine Clone (id)\nset [clone id v] to (id)\ncreate clone of (_myself_ v)\nwait (0) seconds\n\nwhen I start as a clone\nif < (Clone ID) contains [Chev]?> then\n    show\n    clear graphic effects\n    set [fisheye v] effect to (80)\n    point in direction (90)\n    switch costume to (circle v)\n    set size to (10) %\n    if < (Clone ID) contains [Bottom]?> then\n        Go To [0] [-180]\n    else\n        Go To [0] [180]\n    end\n    if < (Clone ID) contains [Black]?> then\n        set [brightness v] effect to (-20)\n    else\n        if < (Clone ID) contains [White]?> then\n            set [brightness v] effect to (100)\n        else\n            set [brightness v] effect to (0)\n        end\n    end\n    repeat until \n        if <((size) + (20)) < [105]> then\n            switch costume to (hack 2 v)\n            change size by (((size) + (20)) / (15))\n            switch costume to (circle v)\n            if < (Clone ID) contains [Bottom]?> then\n                Go To [0] [-180]\n            else\n                Go To [0] [180]\n            end\n        else\n            switch costume to (hack 1 v)\n            change size by (((size) + (20)) / (15))\n            switch costume to (circle v)\n            if < (Clone ID) contains [Bottom]?> then\n                Go To [0] [-180]\n            else\n                Go To [0] [180]\n            end\n        end\n    end\n    wait (1) seconds\n    delete this clone\nend\n\ndefine Clone Chev Pair (1/2)\nif <(1/2) = [1]> then\n    Clone [ChevBottomBlack]\n    Clone [ChevTopBlack]\nelse\n    if <(1/2) = [2]> then\n        Clone [ChevBottomPlain]\n        Clone [ChevTopPlain]\n    else\n        if <(1/2) = [3]> then\n            Clone [ChevBottomWhite]\n            Clone [ChevTopWhite]\n        end\n    end\nend\n\ndefine Go To (x) (y)\ngo to x: (((x) * ((item (1) of [duxxsync v]) / (100))) * ((item (2) of [duxxsync v]) + (1))) y: ((y) * ((item (1) of [duxxsync v]) / (100)))\n\nwhen I start as a clone\nif < (Clone ID) contains [Name]?> then\n    show\n    clear graphic effects\n    point in direction (90)\n    switch costume to (name2 v)\n    go to [front v] layer\n    repeat until <(timer) > [8.3]>\n        set size to (((100) + (item (2) of [duxxsync v])) + (((100) - (item (1) of [duxxsync v])) * (4))) %\n        set [brightness v] effect to ((((100) - (item (1) of [duxxsync v])) * (1.2)) + ((item (2) of [duxxsync v]) * (.5)))\n        Go To [0] [0]\n        turn right ((100) - (item (1) of [duxxsync v])) degrees\n        if <([abs v] of ((90) - (direction)) ) < [2]> then\n            point in direction (90)\n        else\n            if <([abs v] of ((-90) - (direction)) ) < [2]> then\n                point in direction (-90)\n            end\n        end\n        go to x: (([sin v] of ((timer) * (300)) ) * (10)) y: (([cos v] of ((timer) * (300)) ) * (10))\n    end\nend\n\nwhen I start as a clone\nif < (Clone ID) contains [Particles]?> then\n    show\n    clear graphic effects\n    point in direction (90)\n    go to x: (pick random (-270) to (270)) y: (pick random (-170) to (170))\n    switch costume to (circle v)\n    go to [front v] layer\n    set size to (35) %\n    set [brightness v] effect to (100)\n    set [ghost v] effect to (60)\n    set [velocity v] to (pick random (2) to (6))\n    repeat until \n        change y by ((Velocity) + ((100) - (item (1) of [duxxsync v])))\n        change x by ((Velocity) + ((100) - (item (1) of [duxxsync v])))\n        set [ghost v] effect to ((60) - ((100) - (item (1) of [duxxsync v])))\n        set size to (((35) + (((100) - (item (1) of [duxxsync v])) / (2))) + (item (2) of [duxxsync v])) %\n        if <(y position) > [173]> then\n            set y to (-170)\n        end\n        if <(x position) > [240]> then\n            set x to (-250)\n        end\n    end\nend\n\ndefine Particles (#)\nrepeat (#)\n    Clone [Particles]\nend\n\nwhen I start as a clone\nif < (Clone ID) contains [Shutters]?> then\n    show\n    clear graphic effects\n    point in direction (90)\n    go to x: (0) y: (0)\n    switch costume to (hack 1 v)\n    set size to (110) %\n    switch costume to (shutters v)\n    repeat until \n        go to [front v] layer\n    end\nend\n\nwhen I start as a clone\nif < (Clone ID) contains [Slice]?> then\n    show\n    clear graphic effects\n    switch costume to (hack 1 v)\n    point in direction (90)\n    go to x: (0) y: (0)\n    set size to (100) %\n    switch costume to (slice v)\n    set [brightness v] effect to (join (letter ((length of (Clone ID)) - (3)) of (Clone ID)) (join (letter ((length of (Clone ID)) - (2)) of (Clone ID)) (join (letter ((length of (Clone ID)) - (1)) of (Clone ID)) (letter ((length of (Clone ID)) - (0)) of (Clone ID)))))\n    if <(join (letter ((length of (Clone ID)) - (3)) of (Clone ID)) (join (letter ((length of (Clone ID)) - (2)) of (Clone ID)) (join (letter ((length of (Clone ID)) - (1)) of (Clone ID)) (letter ((length of (Clone ID)) - (0)) of (Clone ID))))) = [-100]> then\n        start sound [Sword Sound Effect v]\n        set [wait? v] to [0]\n    else\n        set [wait? v] to [.2]\n    end\n    repeat until \n        if <(join (letter ((length of (Clone ID)) - (3)) of (Clone ID)) (join (letter ((length of (Clone ID)) - (2)) of (Clone ID)) (join (letter ((length of (Clone ID)) - (1)) of (Clone ID)) (letter ((length of (Clone ID)) - (0)) of (Clone ID))))) = [0100]> then\n            change x by (((650) - (x position)) / (5))\n        else\n            change x by (((650) - (x position)) / (5))\n        end\n        go to [front v] layer\n    end\n    wait ((1) + (Wait?)) seconds\n    add [Delete All] to [duxxsync v]\n    repeat (10)\n        go to [front v] layer\n        change [ghost v] effect by (10)\n    end\n    delete this clone\nend\n\nwhen I start as a clone\nif <not < (Clone ID) contains [Slice]?>> then\n    wait until <[duxxsync v] contains [Delete All]?>\n    delete this clone\nend\n\nwhen I start as a clone\nif < (Clone ID) contains [Shader]?> then\n    show\n    clear graphic effects\n    switch costume to (hack 1 v)\n    point in direction (90)\n    set size to (100) %\n    switch costume to (slice v)\n    go to x: (700) y: (0)\n    set [brightness v] effect to (-100)\n    go to [front v] layer\n    repeat (25)\n        go to [front v] layer\n        wait (.01) seconds\n    end\n    repeat (15)\n        change [ghost v] effect by (7)\n        go to [front v] layer\n    end\n    delete this clone\nend\n\nwhen I receive [debug v]\nrepeat until <(timer) > [8.3]>\n    wait (.5) seconds\n    replace item (2) of [duxxsync v] with [30]\nend\nwait (2) seconds\nbroadcast (End Intro v)\n\nwhen I receive [start intro v]\nRESET\nbroadcast (Debug v)\nwait until <(timer) > [2.31]>\nreplace item (1) of [duxxsync v] with [47]\nwait until <(timer) > [2.77]>\nreplace item (1) of [duxxsync v] with [47]\nwait until <(timer) > [6.06]>\nreplace item (1) of [duxxsync v] with [47]\nwait until <(timer) > [6.53]>\nreplace item (1) of [duxxsync v] with [47]\nwait until <(timer) > [7.6]>\nClone [Slice0100]\nwait (.1) seconds\nClone [Slice-100]\n\nwhen I receive [debug v]\nParticles [50]\nClone [Name]\nClone [Shutters]\nClone [Shader]\nrepeat until <(timer) > [8.3]>\n    Clone Chev Pair [3]\n    wait (0) seconds\n    Clone Chev Pair [1]\n    wait (.1) seconds\n    Clone Chev Pair [2]\n    wait (.07) seconds\nend\n\nwhen I receive [debug v]\nrepeat until <(timer) > [8.3]>\n    replace item (1) of [duxxsync v] with ((item (1) of [duxxsync v]) + (((100) - (item (1) of [duxxsync v])) / (5)))\n    replace item (2) of [duxxsync v] with ((item (2) of [duxxsync v]) + (((0) - (item (2) of [duxxsync v])) / (5)))\n    if <(item (1) of [duxxsync v]) < [100]> then\n        replace item (1) of [duxxsync v] with ([ceiling v] of (item (1) of [duxxsync v]) )\n    else\n        replace item (1) of [duxxsync v] with ([floor v] of (item (1) of [duxxsync v]) )\n    end\nend\n\n@Levels\n\nwhen I receive [setup v]\nswitch costume to (level 1 v)\n\nwhen I receive [next level v]\nswitch costume to (Level)\n\n@Texts\n\nwhen I receive [setup v]\nswitch costume to (level 1 v)\n\nwhen I receive [next level v]\nswitch costume to (Level)\n\n@Danger\n\nwhen I receive [setup v]\nswitch costume to (level 1 v)\n\nwhen I receive [next level v]\nswitch costume to (Level)\n\n@Lava\n\nwhen I receive [setup v]\nswitch costume to (level 1 v)\n\nwhen I receive [next level v]\nswitch costume to (Level)\nif <<(Level) = [2]> or <(Level) = [4]>> then\n    repeat until <<not <(Level) = [2]>> and <not <(Level) = [4]>>>\n        set y to ((4) * ([sin v] of ((timer) * (300)) ))\n    end\nend\n\n@Water\n\nwhen I receive [setup v]\nswitch costume to (level 1 v)\n\nwhen I receive [next level v]\nswitch costume to (Level)\nif <(Level) = [7]> then\n    repeat until <not <(Level) = [7]>>\n        set y to ((4) * ([sin v] of ((timer) * (300)) ))\n    end\nend\n\n@Trampoline\n\nwhen I receive [tick v]\nif <touching (player v)?> then\n    broadcast (Bounce v)\nend\n\nwhen I receive [bounce v]\nstart sound [Boing v]\nswitch costume to (bounced v)\nwait (0.5) seconds\nswitch costume to (un-bounced v)\n\nwhen I receive [next level v]\nif <(item (Level) of [positions v]) = [None]> then\n    hide\nelse\n    go to x: (item (Level) of [x v]) y: (item (Level) of [y v])\n    show\nend\n\nwhen I receive [setup v]\nhide\nswitch costume to (un-bounced v)\n\n@Treats\n\nwhen I receive [tick v]\nif <touching (player v)?> then\n    start sound [Collect v]\n    change [collected v] by (1)\n    delete this clone\nend\n\nwhen I receive [next level v]\nset [collected max v] to [0]\nset [collected v] to [0]\nLoad Level\n\nwhen I receive [setup v]\nhide\nswitch costume to (level v)\nset [collected v] to [0]\nset [collected max v] to [0]\n\ndefine Clone at (x) (y)\ngo to x: (x) y: (y)\nchange [collected max v] by (1)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nshow\n\ndefine Load Level\nif <(Level) = [2]> then\n    Clone at [-62] [-5]\nelse\n    if <(Level) = [3]> then\n        Clone at [10] [110]\n    else\n        if <(Level) = [4]> then\n            Clone at [45] [-20]\n        else\n            if <(Level) = [6]> then\n                Clone at [210] [0]\n            else\n                if <(Level) = [9]> then\n                    Clone at [200] [70]\n                else\n                    if <(Level) = [10]> then\n                        Clone at [30] [30]\n                    end\n                end\n            end\n        end\n    end\nend\n\n@Collect All\n\nwhen I receive [setup v]\nhide\nset [ghost v] effect to (0)\n\nwhen I receive [no treats v]\nshow\nwait (2) seconds\nrepeat (40)\n    change [ghost v] effect by (2.5)\nend\nhide\nset [ghost v] effect to (0)\n\n@Extra Jump\n\nwhen I receive [setup v]\nhide\nset [ghost v] effect to (0)\nset [ghost v] to [0]\nset size to (70) %\n\nwhen I receive [next level v]\nbroadcast (reset clones v) and wait\nset size to (70) %\nset [ghost v] effect to (0)\nset [ghost v] to [0]\nLoad Level\n\nwhen I receive [extra jump v]\nrepeat (20)\n    change size by (2)\n    change [ghost v] effect by (5)\n    change [ghost v] by (5)\nend\n\nwhen I receive [reset v]\nset size to (70) %\nset [ghost v] effect to (0)\nset [ghost v] to [0]\n\ndefine Load Level\nif <(Level) = [5]> then\n    Create Clone at [70] [0]\nelse\n    if <(Level) = [10]> then\n        Create Clone at [-40] [-30]\n    end\nend\n\ndefine Create Clone at (x) (y)\ngo to x: (x) y: (y)\ncreate clone of (_myself_ v)\n\nwhen I receive [reset clones v]\ndelete this clone\n\nwhen I start as a clone\nshow\n\nwhen I receive [tick v]\nif <<touching (player v)?> and <(ghost) = [0]>> then\n    broadcast (extra jump v)\nend\n\n