Light - A Platformer

Instructions: Use the WASD keys to move. You need to use your torch to see what's ahead. If you get stuck press R to reset. If your game is lagging click See Inside and go to the dust sprite and read the comments to know how to reduce the lag. And don't worry, the first and the last levels lag due to block increase.\n\nPress R if you are stuck.\n

@Stage\n\nwhen flag clicked\nswitch backdrop to (backdrop1 v)\nset [deaths v] to [0]\nhide variable [deaths v]\nwait (1) seconds\nwait until <(Level) = [7]>\nswitch backdrop to (backdrop2 v)\nshow variable [deaths v]\nstop [all v]\n\nwhen flag clicked\nforever\n    play sound [Assassin's Creed Rogue OST - Animus Black \(Track 02\).mp3 v] until done\nend\n\n@Player\n\nwhen flag clicked\n\nwhen flag clicked\nset rotation style [left-right v]\nforever\n    if <(Attack) = [0]> then\n        if <key (left arrow v) pressed?> then\n            point in direction (-90)\n            next costume\n            wait (0.06) seconds\n        end\n        if <key (right arrow v) pressed?> then\n            point in direction (90)\n            next costume\n            wait (0.06) seconds\n        end\n    end\n    if <not <key (left arrow v) pressed?>> then\n        switch costume to (costume1 v)\n    end\n    if <not <key (right arrow v) pressed?>> then\n        switch costume to (costume1 v)\n    end\nend\n\nwhen flag clicked\nInit\nshow\nforever\n    if <(Pause?) = [0]> then\n        set [speed x v] to ((0.7) * (speed x))\n        if <<<key (w v) pressed?> or <key (up arrow v) pressed?>> or <(change y) < [4]>> then\n            change [change y v] by (-1)\n        else\n            change [change y v] by (-2)\n        end\n        if <(Wall jump) > [0]> then\n            change [wall jump v] by (-1)\n        else\n            if <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n                change [speed x v] by (-2)\n            end\n            if <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n                change [speed x v] by (2)\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 (up arrow v) pressed?>> then\n            if <<(jump key) = [0]> and <(falling?) < [3]>> then\n                set [change y v] to [16]\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        change [change y v] by (-1)\n        change y by (change y)\n        Touch Ground <(change y) > [0]>\n        Set Costume\n        if <[230] < (x position)> then\n            change [level v] by (1)\n            go to x: (-148) y: (-80)\n        end\n    end\nend\n\ndefine Touch Ground <>\nchange [falling? v] by (1)\nrepeat until <not <touching (entities v)?>>\n    set [change y v] to [0]\n    if <up?> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling? v] to [0]\n    end\nend\n\ndefine None\npoint in direction (direction)\nchange x by (speed)\nset [slope v] to [0]\nchange [frame v] by (0.5)\nrepeat until <<(slope) = [8]> or <not <touching (entities 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 <(Wall jump) = [0]> then\n        set [speed x v] to ((-4) * (speed))\n        set [change y v] to [11]\n        set [falling? v] to [6]\n        set [wall jump v] to [15]\n    else\n        set [speed x v] to [0]\n    end\nend\n\ndefine Set Costume\nif <(falling?) < [3]> then\n    if <(Frame) = [0]> then\n        switch costume to (costume2 v)\n    else\n        switch costume to ([floor v] of ((4) + ((Frame) mod (9))) )\n    end\nelse\n    if <(change y) > [0]> then\n        switch costume to (costume2 v)\n    else\n        switch costume to (costume11 v)\n    end\nend\n\ndefine Init\nset [level v] to [1]\nset [wall jump v] to [0]\nset [slope v] to [0]\nset [jump key v] to [0]\nset rotation style [left-right v]\nhide\nset [falling? v] to [0]\nset [change y v] to [0]\ngo to x: (-230) y: (-143)\nset [pause? v] to [0]\ngo to [front v] layer\nhide\nset [xv v] to [0]\nset [intro started? v] to [0]\nset [new game? v] to [0]\nset [yv v] to [0]\n\nchange [level v] by (1)\n\nchange y by (-10)\n\nchange y by (10)\n\nwhen I receive [reset v]\nchange [deaths v] by (1)\ngo to x: (-212) y: (-120)\n\nchange x by (10)\n\nchange y by (10000000)\n\nset y to (0)\nchange y by (100)\n\nforever\n    if <(Pause?) = [0]> then\n        if <(Attack) = [0]> then\n            if <<(y position) < [-175]> or <touching color (#ff0000)?>> then\n                go to x: (198) y: (-143)\n                set [xv v] to [0]\n                set [yv v] to [0]\n            end\n            if <key (left arrow v) pressed?> then\n                change [xv v] by (-1)\n            end\n            if <key (right arrow v) pressed?> then\n                change [xv v] by (1)\n            end\n            set [xv v] to ((xv) * (0.85))\n            change x by (xv)\n            if <touching color (#000008)?> then\n                change y by (-2)\n                if <touching color (#000008)?> then\n                    change y by (1)\n                    if <touching color (#000008)?> then\n                        change y by (1)\n                        if <touching color (#000008)?> then\n                            change y by (1)\n                            if <touching color (#000008)?> then\n                                change y by (1)\n                                if <touching color (#000008)?> then\n                                    change y by (1)\n                                    if <touching color (#000008)?> then\n                                        change y by (-5)\n                                        change x by ((-1) * (xv))\n                                        if <<key (up arrow v) pressed?> and <not <(xv) = [0]>>> then\n                                            set [mode v] to [walljump]\n                                            set [yv v] to [8]\n                                            set [xv v] to (((xv) / ([abs v] of (xv) )) * (-10))\n                                        else\n                                            set [mode v] to [wallslide]\n                                            set [xv v] to [0]\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n                change y by (2)\n            end\n            change y by (-3)\n            if <touching color (#000008)?> then\n                if <(yv) = [-3]> then\n                    if <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>> then\n                        set [mode v] to [run]\n                    else\n                        if <([abs v] of (xv) ) > [.1]> then\n                            set [mode v] to [skid]\n                        else\n                            set [mode v] to [stand]\n                        end\n                    end\n                end\n                if <key (up arrow v) pressed?> then\n                    set [mode v] to [jump]\n                    set [yv v] to [9]\n                end\n            end\n            if <<<<(mode) = [jump]> or <(mode) = [walljump]>> and <(yv) < [0]>> or <<<(mode) = [run]> or <(mode) = [skid]>> and <(yv) < [-3]>>> then\n                set [mode v] to [fall]\n            end\n            change y by (3)\n            if <(yv) > [-15]> then\n                change [yv v] by (-0.5)\n            end\n            change y by (-2)\n            if <not <touching color (#000008)?>> then\n                change y by (-1)\n                if <not <touching color (#000008)?>> then\n                    change y by (-1)\n                    if <not <touching color (#000008)?>> then\n                        change y by (-1)\n                        if <not <touching color (#000008)?>> then\n                            change y by (-1)\n                            if <not <touching color (#000008)?>> then\n                                change y by (-1)\n                                if <not <touching color (#000008)?>> then\n                                    change y by (5)\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n            change y by (2)\n            change y by (yv)\n            if <touching color (#000008)?> then\n                change y by (-2)\n                if <touching color (#000008)?> then\n                    change y by ((-1) * (yv))\n                    set [yv v] to [-3]\n                end\n                change y by (2)\n            end\n        end\n    end\nend\n\nwhen [i v] key pressed\nchange [level v] by (1)\n\nset [change y v] to [200]\n\nset [pause? v] to [0]\n\nset [pause? v] to [1]\n\nwhen flag clicked\nforever\n    if <touching color (#cc0000)?> then\n        broadcast (rESET v)\n    end\n    if <(y position) < [-178]> then\n        broadcast (rESET v)\n    end\nend\n\nwhen [r v] key pressed\nbroadcast (rESET v)\n\nwhen flag clicked\nwait (1) seconds\nwait until <(Level) = [7]>\nhide\n\n@Dust\n\nwhen I start as a clone\nshow\ngo to x: (pick random (-240) to (240)) y: (pick random (-180) to (180))\nforever\n    point in direction (pick random (-180) to (180))\n    wait (pick random (0.8) to (5)) seconds\nend\n\nwhen I start as a clone\nshow\ngo to x: (pick random (-240) to (240)) y: (pick random (-180) to (180))\nforever\n    move (0.3) steps\n    if <(distance to [torch v]) > [20]> then\n        set [brightness v] effect to (80)\n        show\n    end\n    if <(distance to [torch v]) > [40]> then\n        set [brightness v] effect to (60)\n        show\n    end\n    if <(distance to [torch v]) > [50]> then\n        show\n        set [brightness v] effect to (30)\n    end\n    if <(distance to [torch v]) > [75]> then\n        show\n        set [brightness v] effect to (20)\n    end\n    if <(distance to [torch v]) > [80]> then\n        show\n        set [brightness v] effect to (5)\n    end\n    if <(distance to [torch v]) > [95]> then\n        set [brightness v] effect to (5)\n        show\n    end\n    if <(distance to [torch v]) > [100]> then\n        set [brightness v] effect to (0)\n        hide\n    end\nend\n\nset [lag saver v] to [1]\n\nif <(Lag saver) = [0]> then\nend\n\nset [lag reducer v] to [25]\n\ndefine Create Clones Of Myself\nrepeat (Lag reducer)\n    create clone of (_myself_ v)\nend\n\nset [lag reducer v] to [0]\n\nif <(distance to [player v]) > [20]> then\n    set [brightness v] effect to (80)\n    show\nend\nif <(distance to [player v]) > [50]> then\n    show\n    set [brightness v] effect to (30)\nend\nif <(distance to [player v]) > [75]> then\n    set [brightness v] effect to (5)\n    show\nend\nif <(distance to [player v]) > [100]> then\n    set [brightness v] effect to (0)\n    hide\nend\n\nset [lag saver v] to [0]\n\nrepeat until <(CloneID) = [5]>\n    change [cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nif <not <(CloneID) = [5]>> then\n    hide\n    delete this clone\nend\n\nwhen flag clicked\nhide\nset [cloneid v] to [0]\nCreate Clones Of Myself\n\n@Torch\n\nwhen flag clicked\npoint in direction (90)\nset rotation style [left-right v]\nset [xy v] to (direction)\nset [leftright? v] to [90]\nforever\n    if <([direction v] of [player v]) = [90]> then\n        go to x: (([x position v] of [player v]) + (5)) y: ([y position v] of [player v])\n        point in direction (90)\n    end\n    if <([direction v] of [player v]) = [-90]> then\n        go to x: (([x position v] of [player v]) - (9)) y: ([y position v] of [player v])\n        point in direction (-90)\n    end\nend\n\nif  then\n    point in direction (90)\nelse\nend\n\nwhen flag clicked\nforever\nend\n\nif  then\nend\n\nif <<([abs v] of (round (XY)) ) = [91]> or <<([abs v] of (round (XY)) ) = [90]> or <([abs v] of (round (XY)) ) = [89]>>> then\n    set [leftright? v] to [1]\nend\n\nif <(Leftright?) = [0]> then\n    point in direction (XY)\nend\nif <key (k v) pressed?> then\n    change [xy v] by (3)\n    set [leftright? v] to [0]\nend\nif <key (l v) pressed?> then\n    change [xy v] by (-3)\n    set [leftright? v] to [0]\nend\nif <(Leftright?) = [1]> then\n    set rotation style [left-right v]\nelse\n    set rotation style [all around v]\nend\n\nwhen I receive [reset v]\n\n@Entities\n\ndefine Glow Effect\nif <(distance to [torch v]) > [30]> then\n    set [ghost v] effect to (0)\nend\nif <(distance to [torch v]) > [45]> then\n    set [ghost v] effect to (15)\nend\nif <(distance to [torch v]) > [50]> then\n    set [ghost v] effect to (25)\nend\nif <(distance to [torch v]) > [60]> then\n    set [ghost v] effect to (40)\nend\nif <(distance to [torch v]) > [70]> then\n    set [ghost v] effect to (50)\nend\nif <(distance to [torch v]) > [80]> then\n    set [ghost v] effect to (65)\nend\nif <(distance to [torch v]) > [90]> then\n    set [ghost v] effect to (85)\nend\nif <(distance to [torch v]) > [100]> then\n    set [ghost v] effect to (100)\nend\n\nwhen I start as a clone\nshow\nwait until <(Level) = [1]>\nrepeat until <(Level) = [2]>\n    Glow Effect\nend\ndelete this clone\n\nif <(distance to [sprite1 v]) > [30]> then\n    set [brightness v] effect to (80)\nend\nif <(distance to [sprite1 v]) > [60]> then\n    set [brightness v] effect to (60)\nend\nif <(distance to [sprite1 v]) > [80]> then\n    set [brightness v] effect to (40)\nend\nif <(distance to [sprite1 v]) > [90]> then\n    set [brightness v] effect to (20)\nend\nif <(distance to [sprite1 v]) > [100]> then\n    set [brightness v] effect to (0)\nend\n\nwhen flag clicked\ngo to x: (-240) y: (-170)\nwait until <(Level) = [2]>\nCreate Vertical Line (4)\nCreate Horizontal Line (4)\nchange x by (90)\nCreate Horizontal Line (4)\ngo to x: (97) y: (-166)\nCreate Vertical Line (5)\nstop [this script v]\n\ndefine None\nrepeat (length)\n    create clone of (_myself_ v)\n    change [cloneid v] by (1)\n    change y by (10)\nend\n\nwhen I start as a clone\nwait (0.1) seconds\n\nwhen flag clicked\ngo to x: (-240) y: (-170)\nwait (1) seconds\nwait until <(Level) = [4]>\nwait (-1) seconds\ngo to x: (-240) y: (-170)\nCreate Vertical Line (4)\nchange x by (80)\nCreate Horizontal Line (2)\nchange y by (-30)\nCreate Vertical Line (1)\nchange x by (90)\nCreate Vertical Line (1)\n\nwhen I start as a clone\nwait until <(Level) = [4]>\nwait until <(Level) = [5]>\ndelete this clone\n\nwhen I start as a clone\nforever\n    Glow Effect\nend\n\nwhen flag clicked\ngo to x: (-240) y: (-170)\nwait (1) seconds\nwait until <(Level) = [5]>\nwait (-1) seconds\ngo to x: (-210) y: (-170)\nCreate Vertical Line (2)\nchange x by (90)\nCreate Horizontal Line (1)\nchange x by (90)\nCreate Horizontal Line (7)\nchange x by (90)\nCreate Horizontal Line (3)\n\nwhen I start as a clone\nwait until <(Level) = [2]>\nrepeat until <(Level) = [3]>\n    Glow Effect\nend\ndelete this clone\n\nwhen flag clicked\n\nwhen I start as a clone\nwait until <(Level) = [4]>\nwait until <(Level) = [5]>\ndelete this clone\n\nwait until <(Level) = [5]>\nset x to (0)\nset y to (-180)\nCreate Horizontal Line (15)\nset x to (-200)\nset y to (-59)\nCreate Horizontal Line (1)\n\nchange x by (90)\nCreate Horizontal Line (7)\nchange x by (90)\n\nwhen [space v] key pressed\n\nwhen flag clicked\nset x to (-240)\nset y to (-175)\nhide\nset [cloneid v] to [0]\nCreate Vertical Line (20)\nset y to (0)\nset x to (-240)\nCreate Vertical Line (20)\n\ndefine None\nrepeat (lenght)\n    create clone of (_myself_ v)\n    change [cloneid v] by (1)\n    change x by (30)\nend\n\nwhen I start as a clone\nwait until <(Level) = [5]>\nwait until <(Level) = [6]>\ndelete this clone\n\nwhen I start as a clone\nwait until <(Level) = [3]>\nwait until <(Level) = [4]>\ndelete this clone\n\nwhen flag clicked\ngo to x: (-240) y: (-170)\nwait (1) seconds\nwait until <(Level) = [3]>\nwait (-1) seconds\ngo to x: (-220) y: (-170)\nCreate Vertical Line (4)\nchange x by (90)\nCreate Horizontal Line (3)\nchange x by (80)\nCreate Horizontal Line (3)\nchange x by (90)\nCreate Horizontal Line (1)\n\nchange [level v] by (1)\n\nwhen flag clicked\ngo to x: (-240) y: (-170)\nwait (1) seconds\nwait until <(Level) = [6]>\nwait (-1) seconds\ngo to x: (-210) y: (-170)\nCreate Vertical Line (18)\nchange x by (90)\nCreate Horizontal Line (20)\ngo to x: (50) y: (-80)\nCreate Vertical Line (4)\ngo to x: (58) y: (20)\nCreate Vertical Line (3)\ngo to x: (62) y: (100)\nCreate Vertical Line (2)\n\n@Sprite1\n\nwhen flag clicked\nset [fpsstack v] to [0]\nforever\n    wait (1) seconds\n    set [fps v] to (fpsstack)\n    set [fpsstack v] to [0]\nend\n\nwhen flag clicked\nforever\n    change [fpsstack v] by (1)\nend\n\n