Reflections [Platformer]
@Stage\n\nwhen flag clicked\nbroadcast (setup v) and wait\nbroadcast (music v)\nbroadcast (intro v) and wait\nwait (0.5) seconds\nbroadcast (showTitle v) and wait\nbroadcast (startMenu v) and wait\n\nwhen I receive [music v]\nforever\n    play sound [Noisestorm - Leaving Now v] until done\nend\n\ndefine game\nif <(runGameLoop) = [1]> then\n    broadcast (gameTick v)\nend\ncalcFPS\n\nwhen I receive [rungameloop v]\nset [timemarker v] to ([floor v] of (timer) )\nforever\n    game\n    if <(runGameLoop) = [2]> then\n        stop [this script v]\n    end\nend\n\nwhen I receive [render v]\nbroadcast (render:switchMaps v) and wait\nbroadcast (render:clear entities v) and wait\nbroadcast (render:terrain v) and wait\nbroadcast (render:entities v) and wait\n\nwhen I receive [setup v]\nset [rungameloop v] to [1]\nset [maxlevel v] to [0]\nswitch backdrop to (background v)\n\nwhen I receive [startmenu v]\nswitch backdrop to (title-0 v)\nset [targettime v] to (pick random (3) to (5))\nreset timer\nrepeat until <not <(menu?) = [True]>>\n    if <not <(timer) < (targetTime)>> then\n        repeat (5)\n            next backdrop\n            wait (0) seconds\n        end\n        switch backdrop to (title-0 v)\n        set [targettime v] to (pick random (3) to (5))\n        reset timer\n    end\nend\nset [menuscreen v] to [game]\nbroadcast (initGame v)\n\nwhen I receive [initgame v]\nswitch backdrop to (sky v)\nbroadcast (render v) and wait\nbroadcast (runGameLoop v)\n\nwhen I receive [next v]\nif <not <(Level) < [10]>> then\n    broadcast (win v)\n    set [rungameloop v] to [2]\n    set [menuscreen v] to [title]\n    set [menu? v] to [True]\n    broadcast (render:clear entities v) and wait\n    erase all\n    set [rungameloop v] to [1]\n    broadcast (startMenu v)\nelse\n    set [rungameloop v] to [0]\n    change [level v] by (1)\n    if <(Level) > (maxLevel)> then\n        set [maxlevel v] to (Level)\n    end\n    replace item (maxLevel) of [locked v] with [0]\n    broadcast (render v) and wait\n    set [rungameloop v] to [1]\nend\n\ndefine calcFPS\nchange [frames v] by (1)\nif <([floor v] of (timer) ) > (timeMarker)> then\n    set [timemarker v] to ([floor v] of (timer) )\n    set [fps v] to (Frames)\n    set [frames v] to [0]\nend\n\n@Player\n\ndefine Touch Ground <>\nchange [falling? v] by (1)\nchange [jumpframe v] by (animSpd)\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        set [jumpframe v] to [0]\n    end\n    set [yv v] to [0]\nend\n\ndefine Reset\nif <(Level) = [10]> then\n    go to x: (-220) y: (20)\nelse\n    go to x: (-220) y: (80)\nend\npoint in direction (90)\nset [xv v] to [0]\nset [yv v] to [0]\nset [falling? v] to [6]\nset [speed v] to [2.5]\nset [jump height v] to [12.2]\nset [gravity v] to [1]\nset [animspd v] to [1]\nset [attacking v] to [0]\nset [hp v] to [10]\n\ndefine None\nchange x by (speed)\npoint in direction (direction)\nset [slope v] to [0]\nrepeat until <<not <touching (ground v)?>> or <(Slope) = [8]>>\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    set [xv v] to [0]\nend\nchange [runframe v] by (animSpd)\n\ndefine Set Costume\nset size to (20) %\nif <(Falling?) < [3]> then\n    if <(Attacking) > [0]> then\n        switch costume to (attack v)\n    else\n        if <([abs v] of (Xv) ) > [0]> then\n            switch costume to ([floor v] of (((runFrame) mod (9)) + (2)) )\n        else\n            switch costume to (run 1 v)\n        end\n    end\nelse\n    if <(Yv) > [0]> then\n        if <(jumpFrame) < [13]> then\n            switch costume to ([floor v] of ((jumpFrame) + (15)) )\n        else\n            switch costume to (jump 12 v)\n        end\n    else\n        switch costume to ([floor v] of ((jumpFrame) + (15)) )\n        if <(jumpFrame) > [18]> then\n            switch costume to (run 1 v)\n        end\n    end\nend\n\nwhen I receive [gametick v]\nshow\nPhysics\n\ndefine Physics\nswitch costume to (player hitbox v)\nset rotation style [left-right v]\nset size to (60) %\nchange [yv v] by ((0) - (Gravity))\nchange y by (Yv)\nTouch Ground <(Yv) > [0]>\nif <(Attacking) > [0]> then\n    change [attacking v] by (-1)\nelse\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        change [xv v] by ((0) - (Speed))\n    end\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        change [xv v] by (Speed)\n    end\nend\nset [xv v] to ((Xv) * (0.7))\nif <(Xv) > [0.5]> then\n    Walk (Xv) (90)\nelse\n    if <(Xv) < [-0.5]> then\n        Walk (Xv) (-90)\n    else\n        set [runframe v] to [0]\n    end\nend\nif <<key (space v) pressed?> or <<key (up arrow v) pressed?> or <key (w v) pressed?>>> then\n    if <<(Falling?) < [3]> and <(Jump Key?) = [0]>> then\n        set [jump key? v] to [1]\n        set [falling? v] to [6]\n        set [yv v] to (Jump Height)\n    else\n        set [jump key? v] to [0]\n    end\nend\nif <mouse down?> then\n    if <<(Falling?) < [3]> and <<(Attacking) = [0]> and <(Attack Key?) = [0]>>> then\n        set [attacking v] to [10]\n        set [attack key? v] to [1]\n    end\nelse\n    set [attack key? v] to [0]\nend\nif <<touching (obstacles v)?> or <<(y position) < [-195]> or <not <(HP) > [0]>>>> then\n    set [rungameloop v] to [0]\n    switch costume to (fall 1 v)\n    set size to (20) %\n    broadcast (dead v) and wait\n    set [rungameloop v] to [1]\nend\nif <(x position) > [235]> then\n    broadcast (next v)\nend\nSet Costume\n\nwhen I receive [dead v]\nanimateDeath\nReset\n\nwhen I receive [setup v]\nset [sprint v] to [1]\nhide\n\nwhen I receive [render:entities v]\nReset\n\ndefine animateDeath\nif <(y position) > [-180]> then\n    set [yv v] to [0]\n    set [deathframe v] to [0]\n    repeat until <not <(y position) > [-180]>>\n        change [deathframe v] by (0.5)\n        change [yv v] by ((0) - (Gravity))\n        set [xv v] to ((Xv) * (0.85))\n        change y by (Yv)\n        change x by (Xv)\n        switch costume to ([floor v] of (((deathFrame) mod (4)) + (11)) )\n    end\nend\n\nwhen I receive [startmenu v]\nhide\n\n@Player Reflection\n\nwhen I receive [setup v]\nhide\n\nwhen I receive [gametick v]\nshow\ngo to x: ([x position v] of [player v]) y: ((([y position v] of [player v]) * (-1)) - (8))\npoint in direction ([direction v] of [player v])\nswitch costume to ([costume # v] of [player v])\n\nwhen I receive [dead v]\nanimateDeath\nReset\n\ndefine Reset\ngo to x: (-220) y: (-88)\nset [xv v] to [0]\nset [yv v] to [0]\n\nwhen I receive [render:entities v]\nReset\n\nwhen I receive [startmenu v]\nhide\n\ndefine animateDeath\nif <(y position) < [180]> then\n    set [yv v] to [0]\n    set [xv v] to ([xv v] of [player v])\n    set [deathframe v] to [0]\n    repeat until <not <(y position) < [180]>>\n        change [deathframe v] by (0.5)\n        change [yv v] by (Gravity)\n        set [xv v] to ((Xv) * (0.85))\n        change y by (Yv)\n        change x by (Xv)\n        switch costume to ([floor v] of (((deathFrame) mod (4)) + (11)) )\n    end\nend\n\n@Ground\n\nwhen I receive [initgame v]\nset [ghost v] effect to (100)\nshow\n\nwhen I receive [setup v]\nswitch costume to (level 1 v)\ngo to x: (0) y: (-4)\nhide\n\nwhen I receive [render:switchmaps v]\nswitch costume to (Level)\n\nwhen I receive [startmenu v]\nhide\n\n@Obstacles\n\nwhen I receive [initgame v]\nset [ghost v] effect to (100)\nshow\n\nwhen I receive [setup v]\nswitch costume to (level 1 v)\ngo to x: (0) y: (-4)\nhide\n\nwhen I receive [startmenu v]\nhide\n\nwhen I receive [render:switchmaps v]\nswitch costume to (Level)\n\n@RenderMap\n\nwhen I receive [upload:hide v]\nset [ghost v] effect to (100)\n\nwhen I receive [upload:progress v]\nnext costume\n\nwhen I receive [upload:reset maps v]\nswitch costume to (level 1 v)\n\nwhen I receive [setup v]\nswitch costume to (level 1 v)\ngo to x: (0) y: (-4)\nhide\n\nwhen I receive [upload:show v]\nclear graphic effects\nshow\n\n@Render\n\ndefine render\nloadLevelData\nshow\ngo to x: (((tileWidth) / (2)) - ((screenWidth) / (2))) y: (((tileHeight) / (2)) - ((screenHeight) / (2)))\nset size to (100) %\nerase all\nset [loadmarker v] to [0]\nrepeat (length of [_level v])\n    change [loadmarker v] by (1)\n    if <not <(item (loadMarker) of [_level v]) = [0]>> then\n        if <(item (loadMarker) of [_level v]) = [5]> then\n            compileCoords (x position) (y position)\n            add (pos) to [enemypos v]\n        else\n            if <(y position) < [4]> then\n                switch costume to ((item (loadMarker) of [_level v]) + (2))\n            else\n                switch costume to ((item (loadMarker) of [_level v]) + (1))\n            end\n            stamp\n        end\n    end\n    change x by (tileWidth)\n    if <((loadMarker) mod (tilesRow)) = [0]> then\n        set x to (((tileWidth) / (2)) - ((screenWidth) / (2)))\n        change y by (tileHeight)\n    end\nend\nhide\n\ndefine loadLevelData\ndelete (all) of [_level v]\nset [loaddatamarker v] to (((Level) - (1)) * (totalTiles))\nrepeat until <(length of [_level v]) = (totalTiles)>\n    insert [0] at (last) of [_level v] \n    change [loaddatamarker v] by (1)\n    if <not <((item (loadDataMarker) of [_leveldata v]) mod (length of [_leveldata v])) = [0]>> then\n        replace item (last) of [_level v] with ((item (loadDataMarker) of [_leveldata v]) mod (length of [_leveldata v]))\n    end\nend\n\ndefine setup\nset [screenwidth v] to [480]\nset [screenheight v] to [360]\nset [tilewidth v] to [16]\nset [tileheight v] to [16]\nset [tilesrow v] to ([floor v] of ((screenWidth) / (tileWidth)) )\nset [tilescolumn v] to ([ceiling v] of ((screenHeight) / (tileHeight)) )\nset [totaltiles v] to ((tilesRow) * (tilesColumn))\n\ndefine uploadAll\nbroadcast (setup v) and wait\nswitch backdrop to (render v)\ndelete (all) of [_leveldata v]\nbroadcast (upload:reset maps v) and wait\nrepeat (length of [locked v])\n    upload\n    broadcast (upload:progress v) and wait\nend\n\nwhen I receive [render:terrain v]\nrender\n\nwhen I receive [setup v]\nerase all\nhide\nsetup\n\ndefine None\nset [pos v] to (join ((x) + (500)) ((y) + (500)))\n\ndefine upload\nshow\ngo to x: (((tileWidth) / (2)) - ((screenWidth) / (2))) y: (((tileHeight) / (2)) - ((screenHeight) / (2)))\nset size to (100) %\nbroadcast (upload:show v) and wait\nrepeat (23)\n    repeat (30)\n        switch costume to (render v)\n        if <touching color (#000000)?> then\n            switch costume to (ground v)\n        else\n            if <touching color (#ff0000)?> then\n                switch costume to (spike1 v)\n            else\n                if <touching color (#ff00bf)?> then\n                    switch costume to (enemy v)\n                else\n                end\n            end\n        end\n        add ((costume [number v]) - (1)) to [_leveldata v]\n        change x by (tileWidth)\n    end\n    set x to (((tileWidth) / (2)) - ((screenWidth) / (2)))\n    change y by (tileHeight)\nend\nbroadcast (upload:hide v)\nhide\n\n@Enemy\n\ndefine delClones\ndelete this clone\n\nwhen I receive [setup v]\ndelClones\ndelete (all) of [enemypos v]\ndelete (all) of [enemydata v]\ndelete (all) of [projectiledata v]\nset [#cloneid v] to [-1]\nset [canupdate v] to [0]\nhide\n\nwhen I receive [render:clear entities v]\ndelete (all) of [enemypos v]\ndelete (all) of [enemydata v]\ndelete (all) of [projectiledata v]\ndelete this clone\n\ndefine getStats\nset [pos v] to []\nset [health v] to []\nset [n v] to [0]\nrepeat until <(letter ((n) + (1)) of (item (#CloneID) of [enemydata v])) = [;]>\n    change [n v] by (1)\n    set [pos v] to (join (pos) (letter (n) of (item (#CloneID) of [enemydata v])))\nend\nchange [n v] by (1)\nrepeat until <(letter ((n) + (1)) of (item (#CloneID) of [enemydata v])) = [;]>\n    change [n v] by (1)\n    set [health v] to (join (health) (letter (n) of (item (#CloneID) of [enemydata v])))\nend\ngetCoords (pos)\n\ndefine None\nreplace item (#CloneID) of [enemydata v] with (join (join (pos) [;]) (join (health) [;]))\n\ndefine None\nset [x v] to ((join (letter (1) of (pos)) (join (letter (2) of (pos)) (letter (3) of (pos)))) - (500))\nset [y v] to ((join (letter (4) of (pos)) (join (letter (5) of (pos)) (letter (6) of (pos)))) - (500))\n\ndefine update\nif <(x position) > ([x position v] of [player v])> then\n    point in direction (-90)\nelse\n    point in direction (90)\nend\nif <<(Attacking) > [0]> and <(distance to [player v]) < [25]>> then\n    change [health v] by (-0.25)\nend\nif <not <(health) > [0]>> then\n    set [deletedid v] to (#CloneID)\n    delete (#CloneID) of [enemypos v]\n    delete (#CloneID) of [enemydata v]\n    delete (#CloneID) of [projectiledata v]\n    broadcast (shiftEnemyID v)\n    delete this clone\nend\ncompileStats (pos) (health)\n\nwhen I receive [render:entities v]\nset [n v] to [0]\nrepeat (length of [enemypos v])\n    change [n v] by (1)\n    genEnemy (item (n) of [enemypos v]) (10)\nend\n\nwhen I receive [gametick v]\nif <(#CloneID) > [0]> then\n    if <(canUpdate) = [1]> then\n        shootProjectileIf <(timer) > [30]>\n        update\n    end\nend\n\nwhen I receive [shiftenemyid v]\nif <(#CloneID) > (deletedID)> then\n    change [#cloneid v] by (-1)\nend\n\ndefine shootProjectileIf <>\nif <condition> then\n    set [timer v] to [0]\n    replace item (#CloneID) of [projectiledata v] with [1]\nelse\n    change [timer v] by (1)\nend\n\ndefine None\nadd (join (join (pos) [;]) (join (health) [;])) to [enemydata v]\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nset [#cloneid v] to (length of [enemydata v])\nadd [0] to [projectiledata v]\nset [mylevel v] to (Level)\ngetStats\ngo to x: (x) y: ((y) + (10))\nshow\nset [canupdate v] to [1]\n\n@Projectiles\n\nwhen I receive [setup v]\ndeleteClones\nset [#cloneid v] to [-1]\nhide\n\nwhen I receive [gametick v]\nif <(#CloneID) < [0]> then\n    if <[projectiledata v] contains [1]?> then\n        findIndex\n        set [#cloneid v] to (index)\n        create clone of (_myself_ v)\n        set [#cloneid v] to [-1]\n    end\nend\n\ndefine deleteClones\nset [#cloneid v] to [0]\ndelete this clone\n\ndefine getStats\nset [health v] to []\nset [pos v] to []\nset [n v] to [0]\nrepeat until <(letter ((n) + (1)) of (item (#CloneID) of [enemydata v])) = [;]>\n    change [n v] by (1)\n    set [pos v] to (join (pos) (letter (n) of (item (#CloneID) of [enemydata v])))\nend\nchange [n v] by (1)\nrepeat until <(letter ((n) + (1)) of (item (#CloneID) of [enemydata v])) = [;]>\n    change [n v] by (1)\n    set [health v] to (join (health) (letter (n) of (item (#CloneID) of [enemydata v])))\nend\ngetCoords (pos)\n\ndefine findIndex\nset [n v] to [0]\nrepeat until <(item (n) of [projectiledata v]) = [1]>\n    change [n v] by (1)\n    if <(n) > (length of [projectiledata v])> then\n        set [n v] to [0]\n        stop [this script v]\n    end\nend\nset [index v] to (n)\nreplace item (index) of [projectiledata v] with [0]\n\ndefine None\nset [x v] to ((join (letter (1) of (pos)) (join (letter (2) of (pos)) (letter (3) of (pos)))) - (500))\nset [y v] to ((join (letter (4) of (pos)) (join (letter (5) of (pos)) (letter (6) of (pos)))) - (500))\n\nwhen I receive [startmenu v]\ndeleteClones\nset [#cloneid v] to [-1]\nhide\n\nwhen I start as a clone\nclear graphic effects\nswitch costume to (projectile v)\nshow\nif <not <(length of [projectiledata v]) > [0]>> then\n    delete this clone\nend\ngetStats\ngo to x: (x) y: ((y) + (20))\npoint towards (player v)\nrepeat until <<<touching (player v)?> or <touching (_edge_ v)?>> or <touching (ground v)?>>\n    move (10) steps\nend\nif <touching (player v)?> then\n    hide\n    repeat (10)\n        change [hp v] by (-0.49)\n    end\nelse\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\nend\ndelete this clone\n\n@Health Bar\n\nwhen I receive [setup v]\ndelClones\nset [#cloneid v] to [0]\nhide\nclear graphic effects\n\ndefine delClones\ndelete this clone\n\nwhen I receive [initgame v]\nset [#cloneid v] to [1]\ncreate clone of (_myself_ v)\nset [#cloneid v] to [0]\n\nwhen I start as a clone\nif <(#CloneID) = [0]> then\n    set [#cloneid v] to (n)\n    getStats\n    go to x: (x) y: ((y) + (40))\nend\n\nwhen I receive [gametick v]\nshow\nif <(#CloneID) = [0]> then\n    go to x: ([x position v] of [player v]) y: (([y position v] of [player v]) + (30))\n    if <(y position) > [170]> then\n        set [ghost v] effect to (((y position) - (169)) * (10))\n    else\n        set [ghost v] effect to (0)\n    end\nelse\n    if <(#CloneID) = [1]> then\n        go to x: ([x position v] of [player reflection v]) y: (([y position v] of [player reflection v]) - (30))\n        if <(y position) < [-170]> then\n            set [ghost v] effect to ((([abs v] of (y position) ) - (169)) * (10))\n        else\n            set [ghost v] effect to (0)\n        end\n    end\nend\nif <(#CloneID) > [1]> then\n    if <(length of [enemydata v]) > [0]> then\n        getStats\n    else\n        delete this clone\n    end\n    if <not <(health) > [0]>> then\n        delete this clone\n    else\n        set [color v] effect to (((health) / (10)) * (75))\n    end\nelse\n    set [color v] effect to (((HP) / (10)) * (75))\nend\n\ndefine None\nset [x v] to ((join (letter (1) of (pos)) (join (letter (2) of (pos)) (letter (3) of (pos)))) - (500))\nset [y v] to ((join (letter (4) of (pos)) (join (letter (5) of (pos)) (letter (6) of (pos)))) - (500))\n\nwhen I receive [dead v]\nif <(#CloneID) < [2]> then\n    hide\nend\n\ndefine getStats\nset [pos v] to []\nset [health v] to []\nset [n v] to [0]\nrepeat until <(letter ((n) + (1)) of (item ((#CloneID) - (1)) of [enemydata v])) = [;]>\n    change [n v] by (1)\n    set [pos v] to (join (pos) (letter (n) of (item ((#CloneID) - (1)) of [enemydata v])))\nend\nchange [n v] by (1)\nrepeat until <(letter ((n) + (1)) of (item ((#CloneID) - (1)) of [enemydata v])) = [;]>\n    change [n v] by (1)\n    set [health v] to (join (health) (letter (n) of (item ((#CloneID) - (1)) of [enemydata v])))\nend\ngetCoords (pos)\n\nwhen I receive [render:entities v]\nif <(#CloneID) = [0]> then\n    set [n v] to [1]\n    repeat (length of [enemypos v])\n        change [n v] by (1)\n        create clone of (_myself_ v)\n    end\nend\n\nwhen I receive [render:clear entities v]\nif <(#CloneID) > [1]> then\n    delClones\nend\n\nwhen I receive [startmenu v]\ndelClones\nhide\n\n@Title\n\nwhen I receive [showtitle v]\nshow\nset [ghost v] effect to (100)\ngo to x: (0) y: (0)\nswitch costume to (title v)\nrepeat (25)\n    change [ghost v] effect by (-4)\nend\n\nwhen I receive [setup v]\nhide\n\nwhen I receive [startmenu v]\nhide\n\n@Menu\n\ndefine genStartButtons\nswitch costume to (play button v)\nset [#cloneid v] to [1]\ncreate clone of (_myself_ v)\nset [#cloneid v] to [-1]\n\nwhen I start as a clone\nif <(#CloneID) < [2]> then\n    go to x: (0) y: ((((#CloneID) - (1)) * (-50)) - (60))\n    set [ghost v] effect to (100)\n    show\n    repeat (10)\n        change [ghost v] effect by (-10)\n    end\n    repeat until <not <(menuScreen) = [title]>>\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (10)\n            if <mouse down?> then\n                go to x: (1) y: ((((#CloneID) - (1)) * (-50)) - (59))\n            else\n                go to x: (0) y: ((((#CloneID) - (1)) * (-50)) - (60))\n            end\n        else\n            set [brightness v] effect to (0)\n            go to x: (0) y: ((((#CloneID) - (1)) * (-50)) - (60))\n        end\n    end\n    repeat (4)\n        change [ghost v] effect by (25)\n    end\n    delete this clone\nelse\n    if <(#CloneID) < [14]> then\n        if <(#CloneID) < [8]> then\n            go to x: ((((#CloneID) - (3)) * (35)) - (82.5)) y: (-60)\n        else\n            go to x: ((((#CloneID) - (8)) * (35)) - (82.5)) y: (-95)\n        end\n        if <not <((#CloneID) - (2)) > ((maxLevel) + (1))>> then\n            replace item ((#CloneID) - (2)) of [locked v] with [0]\n        end\n        set [ghost v] effect to (100)\n        show\n        repeat (8)\n            change [ghost v] effect by (-12.5)\n        end\n        repeat until <not <(menuScreen) = [level select]>>\n            if <(item ((#CloneID) - (2)) of [locked v]) = [0]> then\n                if <touching (mouse-pointer v)?> then\n                    set [brightness v] effect to (10)\n                    if <mouse down?> then\n                        if <(#CloneID) < [8]> then\n                            go to x: ((((#CloneID) - (3)) * (35)) - (81.5)) y: (-59)\n                        else\n                            go to x: ((((#CloneID) - (8)) * (35)) - (81.5)) y: (-94)\n                        end\n                    else\n                        if <(#CloneID) < [8]> then\n                            go to x: ((((#CloneID) - (3)) * (35)) - (82.5)) y: (-60)\n                        else\n                            go to x: ((((#CloneID) - (8)) * (35)) - (82.5)) y: (-95)\n                        end\n                    end\n                else\n                    set [brightness v] effect to (0)\n                    if <(#CloneID) < [8]> then\n                        go to x: ((((#CloneID) - (3)) * (35)) - (82.5)) y: (-60)\n                    else\n                        go to x: ((((#CloneID) - (8)) * (35)) - (82.5)) y: (-95)\n                    end\n                end\n            else\n                set [brightness v] effect to (-25)\n            end\n        end\n        repeat (4)\n            change [ghost v] effect by (25)\n        end\n        delete this clone\n    else\n    end\nend\n\ndefine delClones\nhide\ndelete this clone\n\nwhen I receive [setup v]\ndelClones\nset [menuscreen v] to [title]\nset [menu? v] to [True]\n\ndefine genLevelButtons\ndelete (all) of [locked v]\nswitch costume to (level1 v)\nset [#cloneid v] to [2]\nrepeat (10)\n    change [#cloneid v] by (1)\n    add [1] to [locked v]\n    create clone of (_myself_ v)\n    next costume\nend\nset [#cloneid v] to [-1]\n\nwhen I receive [startmenu v]\ndelClones\ngenStartButtons\n\nwhen I receive [levelselect v]\ndelClones\ngenLevelButtons\n\nwhen this sprite clicked\nif <(#CloneID) = [1]> then\n    broadcast (levelSelect v)\n    set [menuscreen v] to [level select]\nelse\n    if <<(#CloneID) > [1]> and <(#CloneID) < [13]>> then\n        set [level v] to ((#CloneID) - (2))\n        set [menu? v] to [False]\n    else\n    end\nend\n\n@Thumbnail\n\nwhen I receive [setup v]\ndeleteClones\nset [intro:wait v] to [1]\ngo to [front v] layer\ngo to x: (0) y: (0)\nhide\n\ndefine deleteClones\ndelete this clone\n\nwhen I receive [intro v]\nswitch costume to (thumbnail v)\nshow\nwait (1) seconds\ncreate clone of (_myself_ v)\nwait until <(intro:wait) = [0]>\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\nwhen I start as a clone\ngo to x: (0) y: (-50)\ngo to [front v] layer\nswitch costume to (sigton v)\nset [ghost v] effect to (100)\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nwait (1.5) seconds\nset [intro:wait v] to [0]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nwhen I receive [initgame v]\nswitch costume to (thumbnail v)\nshow\n\nwhen I receive [win v]\ngo to x: (0) y: (0)\ngo to [front v] layer\nswitch costume to (win scene v)\nset [ghost v] effect to (100)\nrepeat (10)\n    change [ghost v] effect by (-10)\n    go to [front v] layer\nend\nwait (2) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\n    go to [front v] layer\nend\nhide\n\n
Controls:\nLeft/Right arrows, A/D - Walk left/right\nUp arrow, W, Space - Jump\nClick - Attack\n--------------------------\nIf you have problems, restart the project and they *should* go away. I recommend double-clicking the green flag :)\nIf it is really laggy, restart the project and it shouldn't be as bad :)\nWaiting a minute also works too. I don't even know how this started :P