bricks platformer game

Instructions: Use arrow keys or wasd. 16 levels

@Stage\n\n@tile based game engine\n\ndefine rejoin (data)\ndelete (all) of [rejoin data v]\nset [rejoin.i v] to [0]\nrepeat ((length of (data)) - (1))\n    change [rejoin.i v] by (1)\n    if <(letter (rejoin.i) of (data)) = [ ]> then\n        add [~] to [rejoin data v]\n    else\n        add (letter (rejoin.i) of (data)) to [rejoin data v]\n    end\nend\nadd [~] to [rejoin data v]\nset [rejoined v] to (rejoin data)\n\nadd [99] to [level v]\nrejoin (level)\nreplace item (level) of [levels v] with (rejoined)\nset [tile size v] to [24]\n\ndefine do switches\nset [i v] to [0]\nif <((tic) mod (switch speed)) = [0]> then\n    repeat (length of [switch v])\n        change [i v] by (1)\n        if <(item (item (((i) * (3)) - (2)) of [switch v]) of [solid tiles v]) = [a]> then\n            replace item (item (((i) * (3)) - (2)) of [switch v]) of [solid tiles v] with (item (((i) * (3)) - (1)) of [switch v])\n            replace item (item ((i) * (3)) of [switch v]) of [jumpable? v] with (item (((i) * (3)) - (1)) of [switch v])\n        else\n            replace item (item (((i) * (3)) - (2)) of [switch v]) of [solid tiles v] with [a]\n            replace item (item ((i) * (3)) of [switch v]) of [jumpable? v] with [a]\n        end\n    end\nend\n\nset [switch speed v] to [10000]\n\ndefine load level\ndelete (all) of [level v]\nset [separate.i v] to [1]\nrepeat until <(separate.i) > (length of (item (level) of [levels v]))>\n    set [separate.join v] to []\n    if <(letter (separate.i) of (item (level) of [levels v])) = [~]> then\n        change [separate.i v] by (1)\n    end\n    repeat until <<(letter (separate.i) of (item (level) of [levels v])) = [~]> or <(separate.i) > (length of (item (level) of [levels v]))>>\n        if <not <(letter (separate.i) of (item (level) of [levels v])) = [~]>> then\n            set [separate.join v] to (join (separate.join) (letter (separate.i) of (item (level) of [levels v])))\n        end\n        change [separate.i v] by (1)\n    end\n    if <not <(separate.join) = []>> then\n        add (separate.join) to [level v]\n    end\nend\n\nrejoin (level)\nadd (rejoined) to [levels v]\n\nwhen I receive [load level v]\nchange [level v] by (1)\ndelete all of [win v]\ndelete all of [solid tiles v]\ndelete all of [solid type 2 v]\ndelete all of [solid type 3 v]\ndelete all of [solid type 4 v]\ndelete all of [solid type 5 v]\ndelete all of [tile set v]\ndelete all of [jumpable? v]\ndelete all of [x push v]\ndelete all of [y push v]\ndelete all of [damage v]\ndelete all of [switch v]\ndelete all of [air v]\nload level\nset [switch speed v] to [100]\nset [spawn x v] to [-180]\nset [spawn y v] to [-100]\nset [player x v] to [-180]\nset [player y v] to [-100]\nset [player x vel v] to [0]\nset [player y vel v] to [0]\nset [player costume v] to [14]\nset [level height v] to ([ceiling v] of ((360) / (tile size)) )\nset [level width v] to ([ceiling v] of ((480) / (tile size)) )\nset [tile size v] to [24]\nset [tic v] to [0]\ncreate tile type frame label [0] [1] [0] [1] [0] [0] [1] [0] [0] [1]\ncreate tile type frame label [0] [2] [0] [1] [0] [0] [1] [0] [0] [2]\ncreate tile type frame label [0] [3] [0] [1] [0] [0] [1] [0] [0] [3]\ncreate tile type frame label [0] [4] [0] [1] [0] [0] [1] [0] [0] [4]\ncreate tile type frame label [0] [5] [0] [1] [0] [0] [1] [0] [0] [5]\ncreate tile type frame label [4] [0] [0] [1] [0] [0] [.8] [0] [0] [6~7~8~9~]\ncreate tile type frame label [4] [0] [1] [0] [0] [1] [1] [0] [0] [10~11~12~13~]\ncreate tile type frame label [3] [1] [0] [0] [0] [0] [1] [1] [0] [15~16~17~18~19~20~21~22~23~24~25~26~27~28~29~30~31~32~33~34~35~36~37~38~]\ncreate tile type frame label [1] [0] [0] [0] [0] [1] [1] [0] [0] [39~40~41~42~43~44~45~46~]\ncreate tile type frame label [0] [6] [0] [1] [0] [0] [1] [0] [0] [47]\ncreate tile type frame label [0] [0] [0] [1] [0] [0] [1] [1] [0] [48]\nset [player health v] to (max health)\n\nreset level\n\ndefine seperate (data)\ndelete (all) of [data v]\nset [separate.i v] to [1]\nrepeat until <(separate.i) > (length of (data))>\n    set [separate.join v] to []\n    if <(letter (separate.i) of (data)) = [~]> then\n        change [separate.i v] by (1)\n    end\n    repeat until <<(letter (separate.i) of (data)) = [~]> or <(separate.i) > (length of (data))>>\n        if <not <(letter (separate.i) of (data)) = [~]>> then\n            set [separate.join v] to (join (separate.join) (letter (separate.i) of (data)))\n        end\n        change [separate.i v] by (1)\n    end\n    if <not <(separate.join) = []>> then\n        add (separate.join) to [data v]\n    end\nend\n\ndefine tile (tile)\npoint in direction (90)\nseperate (item (tile) of [tile set v])\nswitch costume to (item ((([floor v] of ((tic) / (item (1) of [data v])) ) mod ((length of [data v]) - (6))) + (7)) of [data v])\nstamp\n\ndefine render\nerase all\nset [i v] to [0]\ngo to x: ((-240) + ((tile size) / (2))) y: ((-180) + ((tile size) / (2)))\nrepeat (level width)\n    set y to ((-180) + ((tile size) / (2)))\n    repeat (level height)\n        change [i v] by (1)\n        if <not <(item (i) of [level v]) = [0]>> then\n            tile (item (i) of [level v])\n        else\n            switch costume to (49 v)\n            stamp\n        end\n        change y by (tile size)\n    end\n    change x by (tile size)\nend\nswitch costume to (player costume)\ngo to x: (player x) y: (player y)\nstamp\n\ndefine reset level\ndelete all of [level v]\nrepeat ((level height) * (level width))\n    add [0] to [level v]\nend\n\ngo to x: (0) y: (0)\ntile [1]\n\ndefine collision detection\nset [player tile v] to (((([ceiling v] of (((player x) + (240)) / (tile size)) ) - (1)) * (level height)) + ([ceiling v] of (((player y) + (180)) / (tile size)) ))\nif <[spawn set v] contains (item (player tile) of [level v])?> then\n    set [spawn x v] to (player x)\n    set [spawn y v] to (player y)\nend\nif <[win v] contains (item (player tile) of [level v])?> then\n    broadcast (load level v) and wait\nend\nchange [player health v] by (() - (item (item (player tile) of [level v]) of [damage v]))\nchange [player x vel v] by (item (item (player tile) of [level v]) of [x push v])\nchange [player y vel v] by (item (item (player tile) of [level v]) of [y push v])\nif <not <(item (player tile) of [level v]) = [0]>> then\n    set [player x vel v] to ((player x vel) * (item (item (player tile) of [level v]) of [air v]))\n    set [player y vel v] to ((player y vel) * (item (item (player tile) of [level v]) of [air v]))\nend\nchange [player y v] by (player y vel)\nset [player y vel v] to (((player y vel) * (air)) - (gravity))\nif <[jumpable? v] contains (item (player tile) of [level v])?> then\n    if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n        if <(player y vel) < [0]> then\n            set [player y vel v] to [13]\n            change [player y v] by (1)\n            ceiling\n        end\n    end\nend\nset [x vel done? v] to [0]\nif <[1] > (player y vel)> then\n    left down\n    right down\nend\nchange [player x v] by (player x vel)\nset [player x vel v] to ((player x vel) * (air))\nphys 2\nphys 3\nif <(over head?) = [0]> then\n    if <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n        change [player x vel v] by (-.8)\n    end\n    if <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n        change [player x vel v] by (.8)\n    end\nend\nif <(player y vel) > [0]> then\n    set [player tile v] to (((([ceiling v] of (((((player x) + (1)) - ((tile size) / (2))) + (240)) / (tile size)) ) - (1)) * (level height)) + ([ceiling v] of ((((player y) - ((tile size) / (2))) + (180)) / (tile size)) ))\n    if <[solid tiles v] contains (item ((player tile) + (1)) of [level v])?> then\n        set [player y v] to (((([ceiling v] of (((player y) + (180)) / (tile size)) ) * (tile size)) - (180)) - ((tile size) / (2)))\n        set [player y vel v] to [0]\n    end\n    if <[solid type 5 v] contains (item ((player tile) + (1)) of [level v])?> then\n        set [player y v] to (((((round (((player y) + (180)) / (tile size))) * (tile size)) - (180)) + (((((player x) + (241)) + ((tile size) / (2))) mod (tile size)) - (1))) - ((tile size) / (2)))\n        change [player x vel v] by (.5)\n        set [player x vel v] to (hills)\n        set [player y vel v] to [0]\n    end\n    set [player tile v] to (((([ceiling v] of (((((player x) - (1)) - ((tile size) / (2))) + (240)) / (tile size)) ) - (1)) * (level height)) + ([ceiling v] of ((((player y) - ((tile size) / (2))) + (180)) / (tile size)) ))\n    if <[solid tiles v] contains (item (((player tile) + (1)) + (level height)) of [level v])?> then\n        set [player y v] to (((([ceiling v] of (((player y) + (180)) / (tile size)) ) * (tile size)) - (180)) - ((tile size) / (2)))\n        set [player y vel v] to [0]\n    end\n    if <[solid type 4 v] contains (item (((player tile) + (1)) + (level height)) of [level v])?> then\n        set [player y v] to (((((round (((player y) + (180)) / (tile size))) * (tile size)) - (180)) + ((tile size) - (((((player x) + (241)) + ((tile size) / (2))) mod (tile size)) - (1)))) - ((tile size) / (2)))\n        change [player x vel v] by (-.5)\n        set [player x vel v] to (() - (hills))\n        set [player y vel v] to [0]\n        if <(((((player x) + (241)) + ((tile size) / (2))) mod (tile size)) - (1)) < [1]> then\n            set [player y v] to (((([ceiling v] of (((player y) + (180)) / (tile size)) ) * (tile size)) - (180)) + (() - ((tile size) * (1.5))))\n        end\n    end\nend\nif <(player x vel) < [0]> then\n    set [player tile v] to (((([ceiling v] of ((((player x) - ((tile size) / (2))) + (240)) / (tile size)) ) - (1)) * (level height)) + ([ceiling v] of (((((player y) + (1)) - ((tile size) / (2))) + (180)) / (tile size)) ))\n    if <[solid tiles v] contains (item (player tile) of [level v])?> then\n        set [player x v] to (((([ceiling v] of (((player x) + (240)) / (tile size)) ) * (tile size)) - (240)) - ((tile size) / (2)))\n        set [player x vel v] to [0]\n    end\n    set [player tile v] to (((([ceiling v] of ((((player x) - ((tile size) / (2))) + (240)) / (tile size)) ) - (1)) * (level height)) + ([ceiling v] of (((((player y) - (1)) - ((tile size) / (2))) + (180)) / (tile size)) ))\n    if <[solid tiles v] contains (item ((player tile) + (1)) of [level v])?> then\n        set [player x v] to (((([ceiling v] of (((player x) + (240)) / (tile size)) ) * (tile size)) - (240)) - ((tile size) / (2)))\n        set [player x vel v] to [0]\n    end\nend\nif <[0] < (player x vel)> then\n    set [player tile v] to (((([ceiling v] of ((((player x) - ((tile size) / (2))) + (240)) / (tile size)) ) - (1)) * (level height)) + ([ceiling v] of (((((player y) + (1)) - ((tile size) / (2))) + (180)) / (tile size)) ))\n    if <[solid tiles v] contains (item ((player tile) + (level height)) of [level v])?> then\n        set [player x v] to (((([ceiling v] of (((player x) + (240)) / (tile size)) ) * (tile size)) - (240)) - ((tile size) / (2)))\n        set [player x vel v] to [0]\n    end\n    set [player tile v] to (((([ceiling v] of ((((player x) - ((tile size) / (2))) + (240)) / (tile size)) ) - (1)) * (level height)) + ([ceiling v] of (((((player y) - (1)) - ((tile size) / (2))) + (180)) / (tile size)) ))\n    if <[solid tiles v] contains (item (((player tile) + (1)) + (level height)) of [level v])?> then\n        set [player x v] to (((([ceiling v] of (((player x) + (240)) / (tile size)) ) * (tile size)) - (240)) - ((tile size) / (2)))\n        set [player x vel v] to [0]\n    end\nend\n\nset [tile replace v] to [1]\n\ndefine ceiling\n\nwhen [space v] key pressed\nif <(edit?) = [1]> then\n    ask [] and wait\n    set [tile replace v] to (answer)\nend\n\nset [gravity v] to [.8]\n\nset [over head? v] to [0]\n\ndefine create tile type frame label (frame) (phisics type) (kills player?) (jump?) (x gravity) (y gravity) (air) (respawn?) (switch) (animation)\nadd (join (join (join (join (frame) [~]) (join (phisics type) [~])) (join (join (kills player?) [~]) (join (jump?) [~]))) (join (join (join (x gravity) [~]) (join (y gravity) [~])) (join (animation) [~]))) to [tile set v]\nadd (x gravity) to [x push v]\nadd (y gravity) to [y push v]\nadd (kills player?) to [damage v]\nadd (air) to [air v]\nif <(respawn?) = [1]> then\n    add (length of [tile set v]) to [spawn set v]\nend\nif <(jump?) = [1]> then\n    add (length of [tile set v]) to [jumpable? v]\nend\nif <(phisics type) = [1]> then\n    add (length of [tile set v]) to [solid tiles v]\nelse\n    if <(phisics type) = [2]> then\n        add (length of [tile set v]) to [solid type 2 v]\n    else\n        if <(phisics type) = [3]> then\n            add (length of [tile set v]) to [solid type 3 v]\n        else\n            if <(phisics type) = [4]> then\n                add (length of [tile set v]) to [solid type 4 v]\n            else\n                if <(phisics type) = [5]> then\n                    add (length of [tile set v]) to [solid type 5 v]\n                else\n                    if <(phisics type) = [6]> then\n                        add (length of [tile set v]) to [win v]\n                    end\n                end\n            end\n        end\n    end\nend\nif <(switch) = [1]> then\n    add (length of [solid tiles v]) to [switch v]\n    add (length of [tile set v]) to [switch v]\n    add (length of [jumpable? v]) to [switch v]\nend\n\ndefine phys 2\nset [player tile v] to (((([ceiling v] of (((((player x) + (1)) - ((tile size) / (2))) + (240)) / (tile size)) ) - (1)) * (level height)) + ([ceiling v] of ((((player y) - ((tile size) / (2))) + (181)) / (tile size)) ))\nif <[solid type 2 v] contains (item (player tile) of [level v])?> then\n    left down\n    set [player y v] to (((((round (((player y) + (180)) / (tile size))) * (tile size)) - (180)) + ((tile size) - (((((player x) + (241)) + ((tile size) / (2))) mod (tile size)) - (1)))) - ((tile size) / (2)))\n    change [player x vel v] by (hills)\n    set [player y vel v] to [0]\n    if <not <[solid tiles v] contains (item (((player tile) + (1)) + (level height)) of [level v])?>> then\n        if <[jumpable? v] contains (item (player tile) of [level v])?> then\n            if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n                set [player y vel v] to [13]\n                change [player y v] by (1)\n                ceiling\n            end\n        end\n    end\nend\n\ndefine left down\nset [player tile v] to (((([ceiling v] of (((((player x) + (1)) - ((tile size) / (2))) + (240)) / (tile size)) ) - (1)) * (level height)) + ([ceiling v] of ((((player y) - ((tile size) / (2))) + (180)) / (tile size)) ))\nif <[solid tiles v] contains (item (player tile) of [level v])?> then\n    set [player y v] to (((([ceiling v] of (((player y) + (180)) / (tile size)) ) * (tile size)) - (180)) - ((tile size) / (2)))\n    set [player y vel v] to [0]\n    if <not <[solid tiles v] contains (item (((player tile) + (1)) + (level height)) of [level v])?>> then\n        if <[jumpable? v] contains (item (player tile) of [level v])?> then\n            if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n                set [player y vel v] to [13]\n                change [player y v] by (1)\n                ceiling\n            end\n        end\n    end\n    set [x vel done? v] to [1]\nend\n\ndefine right down\nset [player tile v] to (((([ceiling v] of (((((player x) - (1)) - ((tile size) / (2))) + (240)) / (tile size)) ) - (1)) * (level height)) + ([ceiling v] of ((((player y) - ((tile size) / (2))) + (180)) / (tile size)) ))\nif <[solid tiles v] contains (item ((player tile) + (level height)) of [level v])?> then\n    set [player y v] to (((([ceiling v] of (((player y) + (180)) / (tile size)) ) * (tile size)) - (180)) - ((tile size) / (2)))\n    set [player y vel v] to [0]\n    if <not <[solid tiles v] contains (item (((player tile) + (1)) + (level height)) of [level v])?>> then\n        if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n            if <[jumpable? v] contains (item ((player tile) + (level height)) of [level v])?> then\n                set [player y vel v] to [13]\n                change [player y v] by (1)\n                ceiling\n            end\n        end\n    end\nend\n\ndefine phys 3\nset [player tile v] to (((([ceiling v] of (((((player x) - (1)) - ((tile size) / (2))) + (240)) / (tile size)) ) - (1)) * (level height)) + ([ceiling v] of ((((player y) - ((tile size) / (2))) + (181)) / (tile size)) ))\nif <[solid type 3 v] contains (item ((player tile) + (level height)) of [level v])?> then\n    right down\n    set [player y v] to (((((round (((player y) + (180)) / (tile size))) * (tile size)) - (180)) + (((((player x) + (241)) + ((tile size) / (2))) mod (tile size)) - (1))) - ((tile size) / (2)))\n    change [player x vel v] by (() - (hills))\n    if <(((((player x) + (241)) + ((tile size) / (2))) mod (tile size)) - (1)) < [1]> then\n        set [player y v] to (((([ceiling v] of (((player y) + (180)) / (tile size)) ) * (tile size)) - (180)) + ((tile size) / (2)))\n    end\n    set [player y vel v] to [0]\n    if <not <[solid tiles v] contains (item (((player tile) + (1)) + (level height)) of [level v])?>> then\n        if <[jumpable? v] contains (item ((player tile) + (level height)) of [level v])?> then\n            if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                set [player y vel v] to [13]\n                change [player y v] by (1)\n                ceiling\n            end\n        end\n    end\nend\n\nset [air v] to [.9]\nset [gravity v] to [.8]\nset [hills v] to [.5]\n\nset [hills v] to [.5]\n\nwhen I receive [start game v]\nset [level v] to [0]\nbroadcast (load level v) and wait\nforever\n    do switches\n    change [tic v] by (1)\n    if <(edit?) = [1]> then\n        set [mouse tile v] to (((([ceiling v] of (((mouse x) + (240)) / (tile size)) ) - (1)) * (level height)) + ([ceiling v] of (((mouse y) + (180)) / (tile size)) ))\n    end\n    collision detection\n    if <(player health) < [0]> then\n        set [player health v] to (max health)\n        set [player x v] to (spawn x)\n        set [player y v] to (spawn y)\n    end\n    render\nend\n\nif <(edit?) = [1]> then\n    set [mouse tile v] to (((([ceiling v] of (((mouse x) + (240)) / (tile size)) ) - (1)) * (level height)) + ([ceiling v] of (((mouse y) + (180)) / (tile size)) ))\nend\n\n@game platformer\n\ngo to x: (0) y: (0)\n\nwhen flag clicked\nset [ghost v] effect to (100)\n\n@intro\n\nwhen flag clicked\nswitch backdrop to (backdrop2 v)\nshow\nset volume to (100) %\ngo to x: (0) y: (0)\nstart sound [rolemu_-_neogauge v]\nswitch costume to (logo v)\nerase all\nset size to (800) %\nwait (1.4) seconds\nrepeat (28)\n    change x by (5)\n    change y by ((40) / (28))\n    set size to (((600) / ((x position) / (2))) + (140)) %\nend\nstamp\nset size to (200) %\nswitch costume to (name v)\ngo to x: (-300) y: (40)\nglide (.5) secs to x: (-20) y: (40)\nstamp\nhide\ngo to x: (10) y: (-200)\nwait (1.1) seconds\nswitch costume to (games v)\nshow\nglide (.5) secs to x: (-20) y: (-10)\nstamp\nwait (2) seconds\nswitch backdrop to (backdrop1 v)\nerase all\nhide\nbroadcast (start game v)\n\n