Darkness - A Platformer
@Stage\n\nwhen flag clicked\nforever\n    play sound [5555734759079936 v] until done\nend\n\nwhen I receive [starttimer v]\nforever\n    wait (1) seconds\n    change [timer v] by (1)\nend\n\n@player\n\nwhen flag clicked\nswitch costume to (player_right v)\nset [x v] to [0]\nset [y v] to [0]\nset [falling? v] to [1000]\ngo to x: (-190) y: (-50)\nforever\n    hide variable [energy v]\n    if <(walljump) < [1]> then\n        if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n            switch costume to (player_right v)\n            change [x v] by (0.5)\n        end\n        if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n            switch costume to (player_left v)\n            change [x v] by (-0.5)\n        end\n    else\n        change [walljump v] by (-1)\n    end\n    set [x v] to ((x) * (0.9))\n    touchGround <(y) > [0]>\n    change [y v] by (-1)\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> and <(falling?) < [3]>> then\n        set [y v] to [7]\n        broadcast (jump v)\n    end\n    move (x)\n    change y by (y)\n    if <<(y position) < [-175]> or <<touching (pain v)?> or <touching (lava v)?>>> then\n        repeat (20)\n            change x by (((-190) - (x position)) / (4))\n            change y by (((-50) - (y position)) / (4))\n        end\n        broadcast (hit v)\n        set [x v] to [0]\n        set [y v] to [0]\n        set [falling? v] to [1000]\n    end\n    if <touching (portal v)?> then\n        repeat (20)\n            change x by (((-190) - (x position)) / (4))\n            change y by (((-50) - (y position)) / (4))\n        end\n        broadcast (lvlup v)\n        change [level v] by (1)\n        set [x v] to [0]\n        set [y v] to [0]\n        set [falling? v] to [1000]\n    end\nend\n\ndefine move (speed)\nchange x by (speed)\nif <touching (map v)?> then\n    change y by (1)\n    if <touching (map v)?> then\n        change y by (1)\n        if <touching (map v)?> then\n            change y by (1)\n            if <touching (map v)?> then\n                change y by (1)\n                if <touching (map v)?> then\n                    change y by (1)\n                    if <touching (map v)?> then\n                        change x by ((0) - (speed))\n                        if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                            set [y v] to [7]\n                            set [walljump v] to [7]\n                            if <(x) < [1]> then\n                                set [x v] to [10]\n                                switch costume to (player_right v)\n                            else\n                                set [x v] to [-10]\n                                switch costume to (player_left v)\n                            end\n                            broadcast (jump v)\n                        end\n                        change y by (-5)\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine touchGround <up?>\nchange [falling? v] by (1)\nrepeat until <not <touching (map v)?>>\n    if <up?> then\n        change y by (-1)\n    else\n        set [falling? v] to [0]\n        change y by (1)\n    end\n    set [y v] to [0]\nend\n\nwhen flag clicked\nwait until <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<key (left arrow v) pressed?> or <key (a v) pressed?>>>>\nbroadcast (startTimer v)\n\n@light\n\nwhen flag clicked\nset [energy v] to [50]\nswitch costume to (costume1 v)\nset size to (100) %\nforever\n    go to (player v)\n    go to [back v] layer\n    point towards (mouse-pointer v)\n    if <<key (s v) pressed?> and <(energy) > [0]>> then\n        switch costume to (costume2 v)\n        change [energy v] by (-1)\n    else\n        switch costume to (costume1 v)\n    end\n    if <(energy) > [50]> then\n        set [energy v] to [50]\n    end\nend\n\n@map\n\nwhen flag clicked\nset [level v] to [1]\nforever\n    go to x: (0) y: (0)\n    switch costume to (level)\nend\n\nwhen I receive [lvlup v]\nchange [energy v] by (20)\n\n@pain\n\nwhen flag clicked\nforever\n    go to x: (0) y: (0)\n    go to [back v] layer\n    switch costume to (level)\nend\n\n@grass\n\ndefine Grass from (xpos1) to (xpos2) (xpos2 > xpos1)\ngo to x: (xpos1) y: (0)\npoint in direction (90)\nrepeat until <(x position) > (xpos2)>\n    set size to (pick random (50) to (100)) %\n    change x by (1)\n    if <(pick random (1) to (3)) = [1]> then\n        create clone of (_myself_ v)\n    end\nend\n\nwhen I start as a clone\nshow\nGrass\nforever\n    go to [front v] layer\n    if <touching (player v)?> then\n        Sway\n    end\nend\n\ndefine Grass\nswitch costume to (hit v)\nset [ghost v] effect to (50)\nif <touching (map v)?> then\n    repeat until <<not <touching (map v)?>> or <<touching (_edge_ v)?> or <touching (portal v)?>>>\n        change y by (1)\n    end\n    change y by (-1)\n    if <<touching (_edge_ v)?> or <touching (portal v)?>> then\n        delete this clone\n    end\nelse\n    repeat until <<touching (map v)?> or <<touching (_edge_ v)?> or <touching (portal v)?>>>\n        change y by (-2)\n    end\n    repeat until <<not <touching (map v)?>> or <touching (_edge_ v)?>>\n        change y by (1)\n    end\n    change y by (-1)\n    if <<touching (_edge_ v)?> or <touching (portal v)?>> then\n        delete this clone\n    end\nend\nswitch costume to (pick random (1) to (10))\nchange y by (-2)\n\ndefine Sway\nset [magnitude v] to (((x) + (pick random (-2.0) to (2.0))) * (2))\nset [sway v] to [0]\nrepeat until <<[0] = (round ((Magnitude) * (2)))> or <<touching (player v)?> and <([abs v] of (Magnitude) ) < ([abs v] of ((x) * (2)) )>>>\n    point in direction ((90) - (([sin v] of (sway) ) * (Magnitude)))\n    change [sway v] by (-10)\n    set [magnitude v] to ((0.95) * (Magnitude))\nend\n\nwhen flag clicked\nhide\nGrass from [-240] to [235] (xpos2 > xpos1)\n\nwhen I receive [lvlup v]\ndelete this clone\n\nwhen I receive [lvlup v]\nwait (0.05) seconds\nGrass from [-240] to [235] (xpos2 > xpos1)\n\n@portal\n\nwhen flag clicked\nforever\n    go to x: (0) y: (0)\n    go to [back v] layer\n    switch costume to (level)\n    change [ghost v] effect by ([sin v] of ((150) * (timer)) )\nend\n\n@lava\n\nwhen flag clicked\nclear graphic effects\ngo to x: (0) y: (0)\nset [me v] to [1]\nrepeat (3)\n    create clone of (_myself_ v)\n    change y by (-5)\n    change [brightness v] effect by (-10)\n    change [me v] by (1)\nend\n\nwhen I start as a clone\nshow\nforever\n    switch costume to (level)\n    set y to ((([sin v] of (((timer) + (me)) * (300)) ) * (8)) - ((me) * (5)))\n    set [ghost v] effect to (25)\nend\n\nwhen flag clicked\ngo to [back v] layer\nforever\n    hide\nend\n\n@nail\n\nwhen flag clicked\nforever\n    set [checktime v] to (timer)\nend\n\nwhen [timer v] > (checkTime)\nshow\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nforever\n    go to [front v] layer\nend\n\n@trail\n\nwhen flag clicked\nhide\nforever\n    go to [back v] layer\n    go to (player v)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nswitch costume to (join [costume] (pick random (1) to (4)))\nset size to (10) %\nshow\npoint in direction (pick random (1) to (360))\nrepeat (10)\n    change [ghost v] effect by (10)\n    change size by (-1)\n    move (1) steps\nend\ndelete this clone\n\n@easter eggs\n\nwhen flag clicked\nset [coin v] to [0]\nshow\ngo to x: (0) y: (0)\ngo to [back v] layer\nset [ghost v] effect to (50)\nswitch costume to (level)\nwait until <touching (player v)?>\nrepeat (10)\n    change [ghost v] effect by (5)\nend\nchange [coin v] by (1)\nhide\n\nwhen I receive [lvlup v]\nstop [other scripts in sprite v]\nshow\ngo to x: (0) y: (0)\ngo to [back v] layer\nset [ghost v] effect to (50)\nswitch costume to (level)\nwait until <touching (player v)?>\nrepeat (10)\n    change [ghost v] effect by (5)\nend\nchange [coin v] by (1)\nhide\n\n@egg\n\nwhen flag clicked\ngo to x: (0) y: (150)\ngo to [front v] layer\nset volume to (100) %\nset [digits v] to [0]\nforever\n    hide\n    if <(length of (Coin)) > (Digits)> then\n        create clone of (_myself_ v)\n        change [digits v] by (1)\n    end\nend\n\nwhen I start as a clone\nset size to (300) %\ngo to [front v] layer\nset [digit # v] to (Digits)\nshow\nforever\n    set [ghost v] effect to (50)\n    go to x: (((30) * ((Digit #) - ((Digits) / (2)))) - (230)) y: (160)\n    switch costume to (letter (Digit #) of (Coin))\n    if <(length of (Coin)) < (Digit #)> then\n        change [digits v] by (-1)\n        delete this clone\n    end\nend\n\nwhen I receive [sound v]\nif <(volume) = [100]> then\n    set volume to (0) %\nelse\n    set volume to (100) %\nend\n\n@skip\n\nwhen flag clicked\nshow\ngo to [front v] layer\nforever\n    set size to (30) %\n    set [brightness v] effect to (0)\n    repeat until <not <touching (mouse-pointer v)?>>\n        change size by (((40) - (size)) / (1.5))\n        set [brightness v] effect to (30)\n    end\nend\n\nwhen flag clicked\nforever\n    go to x: (-210) y: (-163)\n    point in direction ((90) + (([sin v] of ((350) * (timer)) ) * (10)))\nend\n\nwhen flag clicked\nforever\n    wait until <<touching (mouse-pointer v)?> and <mouse down?>>\n    broadcast (lvlup v)\n    change [level v] by (1)\n    wait until <not <<touching (mouse-pointer v)?> and <mouse down?>>>\nend\n\n@jump\n\nwhen I start as a clone\nset [clone? v] to [1]\nswitch costume to (join [costume] (pick random (1) to (4)))\nset size to (10) %\nshow\npoint in direction (pick random (1) to (360))\ngo to (player v)\nrepeat (10)\n    change [ghost v] effect by (10)\n    change size by (-1)\n    move (5) steps\nend\ndelete this clone\n\nwhen flag clicked\nset [clone? v] to [0]\nhide\nforever\n    go to [back v] layer\nend\n\nwhen I receive [jump v]\nif <(clone?) = [0]> then\n    repeat (20)\n        create clone of (_myself_ v)\n    end\nend\n\n@sword\n\nwhen flag clicked\nset [tier v] to [1]\nset [hit? v] to [0]\nset [gotsword v] to [0]\nset rotation style [left-right v]\nhide\nswitch costume to (get v)\nclear graphic effects\nrepeat until <touching (player v)?>\n    go to x: (10) y: (-70)\n    go to [back v] layer\n    if <(level) = [6]> then\n        show\n        change y by (([sin v] of ((150) * (timer)) ) * (5))\n    else\n        hide\n    end\nend\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nshow\nclear graphic effects\nset [gotsword v] to [1]\nforever\n    broadcast (go to player v)\nend\n\nwhen I receive [go to player v]\nset [ghost v] effect to (0)\ngo to (player v)\nif <([costume # v] of [player v]) = [1]> then\n    point in direction (90)\nelse\n    point in direction (-90)\nend\nmove (20) steps\nchange y by (10)\nswitch costume to (tier)\nset [hit? v] to [0]\nif <key (space v) pressed?> then\n    switch costume to (join (tier) [slash])\n    set [hit? v] to [1]\n    if <([costume # v] of [player v]) = [1]> then\n        set [x v] to ((13) + ((2) * (tier)))\n    else\n        set [x v] to ((-1) * ((13) + ((2) * (tier))))\n    end\nend\n\n@sword effect\n\nwhen flag clicked\nhide\nforever\n    if <(hit?) = [1]> then\n        create clone of (_myself_ v)\n    end\nend\n\nwhen I start as a clone\nswitch costume to (costume1 v)\ngo to [back v] layer\ngo to (player v)\npoint in direction ([direction v] of [sword v])\npoint in direction (pick random (1) to (360))\nset size to (10) %\nset [ghost v] effect to (50)\nshow\nrepeat (10)\n    change [ghost v] effect by (5)\n    change size by (-1)\n    move (2) steps\nend\ndelete this clone\n\n@shot\n\nwhen flag clicked\nset [me v] to [0]\nset [ghost v] effect to (50)\nhide\nforever\n    wait until <(hit?) = [1]>\n    set [me v] to [1]\n    go to (player v)\n    create clone of (_myself_ v)\n    wait (0.5) seconds\nend\n\nwhen I start as a clone\ngo to [back v] layer\nset [ghost v] effect to (50)\nset [size v] to ((7.5) + ((2.5) * (tier)))\nif <(me) = [1]> then\n    set [dir v] to ([direction v] of [sword v])\n    point in direction (dir)\n    move (84) steps\n    show\n    forever\n        set size to (3) %\n        if <<touching (map v)?> or <touching (_edge_ v)?>> then\n            set size to (size) %\n            repeat (10)\n                change [ghost v] effect by (5)\n                set [me v] to [2]\n                create clone of (_myself_ v)\n            end\n            delete this clone\n        end\n        set size to (size) %\n        point in direction (dir)\n        set [dir v] to (direction)\n        move (10) steps\n        point in direction (pick random (0) to (360))\n        set [me v] to [2]\n        create clone of (_myself_ v)\n    end\nelse\n    point in direction (pick random (0) to (360))\n    move (4) steps\n    repeat (20)\n        change [ghost v] effect by (5)\n        change size by (-0.5)\n    end\nend\ndelete this clone\n\nwhen I start as a clone\nset [time v] to [0]\nforever\n    wait (1) seconds\n    change [time v] by (1)\nend\n\n@timer\n\nwhen flag clicked\nsetup\n\nwhen I start as a clone\npoint in direction (90)\nshow\ngo to [front v] layer\nset [ghost v] effect to (50)\nforever\n    chang costume to (letter (index) of (timer))\n    set x to ((((index) - (0.5)) * (20)) - (225))\n    change size by ((0.2) * ((300) - (size)))\nend\n\ndefine setup\nset [timer v] to [0]\nswitch costume to (costume1 v)\nhide\nset size to (100) %\nset [index v] to [1]\ngo to x: (9) y: (132)\nrepeat (10)\n    create clone of (_myself_ v)\n    change x by ((size) / (2))\n    change [index v] by (1)\nend\n\ndefine chang costume to (costume)\nif <not <(costume) = (costume [name v])>> then\n    switch costume to (costume)\n    set size to (120) %\nend\n\n
WASD or Arrow keys. Press space to attack (if you have sword) \nPress s to use flashlight, but be careful with your energy!\nIt's hard.\nHint: Attacking = Dashing... so use it well