TechnoTopia (a Mario Brothers style scrolling platformer)

Instructions: INSTRUCTIONS: Arrow keys or wasd to move, down or S to drop through semi solid platforms, collect the SUPER battery to finish a level, dodge enemy's and lava, one last thing.... Save Techno-Topia.\n

@Stage\n\n@Mario\n\ndefine move camera\nset [camera x v] to (x)\nchange [camera y v] by (((y) - (CAMERA Y)) / (4))\nif <(EDITOR) > [0]> then\n    limit camera edge x: [240] edge y: [180]\nelse\n    limit camera edge x: [272] edge y: [180]\nend\n\ndefine reset player\ngo to [front v] layer\nset [-tiny v] to [-0.000001]\nif <(spawn index) > [0]> then\n    set [x v] to ([floor v] of (((spawn index) - (1)) / (GRID HEIGHT)) )\n    set [y v] to (((spawn index) - (1)) mod (GRID HEIGHT))\nelse\n    set [x v] to [3]\n    set [y v] to [3]\nend\nset [x v] to (((x) * (32)) + (16))\nset [y v] to (((y) * (32)) + (height))\nset [height v] to [24]\nset [width v] to [8]\nset [camera y v] to (x)\nset [camera x v] to (y)\nset [jumping v] to [99]\nset [falling v] to [99]\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [mario v] to [Mini]\nset [invulnerable v] to [0]\npoint in direction (90)\nmove camera\n\ndefine game loop\nforever\n    broadcast (check controls v)\n    broadcast (move player v)\n    broadcast (move enemy v)\n    broadcast (move player after enemy v)\n    broadcast (position tiles v)\nend\n\nwhen I receive [move player v]\nset [bump index v] to []\nif <(EDITOR) > [0]> then\n    Handle - god mode\nelse\n    if <<(falling) > [2]> and <(speed y) < [-1]>> then\n        set [bop y v] to (y)\n    else\n        set [bop y v] to []\n    end\n    handle keys - left right\n    handle keys - jump / crouch\n    move sprite x\n    move sprite y\n    check around player\nend\npaint sprite\n\ndefine get tile at x: (x) y: (y)\nset [tile grid x v] to ([floor v] of ((x) / (32)) )\nset [tile grid y v] to ([floor v] of ((y) / (32)) )\nset [tile index v] to (((1) + (tile grid y)) + ((tile grid x) * (GRID HEIGHT)))\nif <(tile grid y) < [0]> then\n    set [tile v] to []\nelse\n    set [tile v] to (item (tile index) of [tile grid v])\nend\nset [tile shape v] to (item (tile) of [tile shape v])\n\ndefine fix collision in direction dx: (dx) dy: (dy)\nset [fix dx v] to (dx)\nset [fix dy v] to (dy)\nset [solid v] to []\nrepeat (2)\n    fix collision at point x: ((x) - (width)) y: ((y) - (height)) Part: [feet]\n    fix collision at point x: (((x) + (width)) + (-TINY)) y: ((y) - (height)) Part: [feet]\n    fix collision at point x: ((x) - (width)) y: (y) Part: []\n    fix collision at point x: (((x) + (width)) + (-TINY)) y: (y) Part: []\n    if <not <(player action) = [crouch]>> then\n        fix collision at point x: ((x) - (width)) y: ((y) + (height)) Part: []\n        fix collision at point x: (((x) + (width)) + (-TINY)) y: ((y) + (height)) Part: []\n    end\n    if <(solid) < [1]> then\n        stop [this script v]\n    end\nend\n\ndefine fix collision at point x: (x) y: (y) Part: (part)\nget tile at x: (x) y: (y)\nif <(tile shape) = []> then\n    stop [this script v]\nend\nset [mod x v] to ((x) mod (32))\nset [mod y v] to ((y) mod (32))\nset [temp v] to (letter (1) of (tile shape))\nif <<(temp) = [/]> or <(temp) = [\]>> then\n    set [m v] to ((1) / (letter (2) of (tile shape)))\n    set [c v] to ((letter (3) of (tile shape)) * ((32) * (m)))\n    if <(temp) = [\]> then\n        set [m v] to (() - (m))\n        set [c v] to ((32) - (c))\n    end\n    set [offset y v] to ((mod y) - (((mod x) * (m)) + (c)))\n    if <not <(offset y) < [0]>> then\n        stop [this script v]\n    end\n    if <(fix dy) < [0]> then\n        change [y v] by ((0) - (offset y))\n        set [solid v] to [10]\n        stop [this script v]\n    end\n    if <<(fix dy) = [0]> and <<(fix dx) > [0]> = <(m) > [0]>>> then\n        change [x v] by ((offset y) / (m))\n        set [solid v] to [10]\n        stop [this script v]\n    end\nend\nif <(tile shape) = [=]> then\n    if <<not <(part) = [feet]>> or <((mod y) - (fix dy)) < [32]>> then\n        stop [this script v]\n    end\n    if <([down v] of [controls v]) > [0]> then\n        if <[2] > (falling)> then\n            stop [this script v]\n        end\n    end\nend\nset [solid v] to [10]\nif <(fix dy) < [0]> then\n    change [y v] by ((32) - (mod y))\nend\nif <(fix dx) < [0]> then\n    change [x v] by ((32) - (mod x))\nend\nif <(fix dy) > [0]> then\n    change [y v] by ((-TINY) - (mod y))\nend\nif <(fix dx) > [0]> then\n    change [x v] by ((-TINY) - (mod x))\nend\n\ndefine handle keys - left right\nif <(player action) = [crouch]> then\n    if <([abs v] of (speed x) ) > [0.4]> then\n        change [speed x v] by ((-0.4) * (([abs v] of (speed x) ) / (speed x)))\n        made skid smoke\n    else\n        set [speed x v] to [0]\n        set [player frame v] to [0]\n    end\nelse\n    set [player action v] to [walk]\n    set [key walk v] to ([x axis v] of [controls v])\n    if <(KEY WALK) = [0]> then\n        if <(falling) < [2]> then\n            if <(speed x) > [0.4]> then\n                change [speed x v] by (-0.4)\n            else\n                if <(speed x) < [-0.4]> then\n                    change [speed x v] by (0.4)\n                else\n                    set [speed x v] to [0]\n                    set [player frame v] to [0]\n                end\n            end\n        end\n    else\n        point in direction ((90) * (KEY WALK))\n        if <((KEY WALK) * (speed x)) < [10]> then\n            if <((KEY WALK) * (speed x)) < [0]> then\n                change [speed x v] by ((KEY WALK) * (0.8))\n                if <(falling) < [2]> then\n                    set [player action v] to [turn]\n                    made skid smoke\n                end\n            else\n                change [speed x v] by ((KEY WALK) * (0.4))\n            end\n        end\n    end\n    set [temp v] to (([abs v] of (speed x) ) / (19))\n    if <(temp) < [0.2]> then\n        set [temp v] to [0.2]\n    end\n    change [player frame v] by (temp)\nend\n\ndefine handle keys - jump / crouch\nchange [speed y v] by (-2)\nif <(speed y) < [-22]> then\n    set [speed y v] to [-22]\nend\nif <<([down v] of [controls v]) > [0]> and <not <(MARIO) = [Mini]>>> then\n    if <(falling) < [2]> then\n        set [player action v] to [crouch]\n    end\n    set [jumping v] to [0]\nelse\n    if <(player action) = [crouch]> then\n        handle - get up\n    else\n        if <([up v] of [controls v]) > [0]> then\n            if <<(falling) < [2]> or <(jumping) > [0]>> then\n                change [jumping v] by (1)\n                if <(jumping) < [11]> then\n                    set [speed y v] to [13]\n                    if <(jumping) = [1]> then\n                        start sound [Jump v]\n                    end\n                end\n            end\n        else\n            set [jumping v] to [0]\n        end\n    end\nend\n\ndefine move sprite y\nchange [y v] by (speed y)\nchange [falling v] by (1)\nfix collision in direction dx: [0] dy: (speed y)\nif <(solid) > [0]> then\n    if <(speed y) < [0]> then\n        set [falling v] to [0]\n    else\n        set [jumping v] to [99]\n        Bump head\n    end\n    set [speed y v] to [0]\nend\n\ndefine paint sprite\nswitch costume to (big v)\ngo to x: ((x) - (CAMERA X)) y: ((y) - (CAMERA Y))\nif <(player action) = [crouch]> then\n    switch costume to (join (MARIO) [Crouch])\n    stop [this script v]\nend\nif <(player action) = [lose life]> then\n    switch costume to (join (MARIO) [Death])\n    stop [this script v]\nend\nif <(falling) > [1]> then\n    if <(speed y) > [0]> then\n        switch costume to (join (MARIO) [Jump])\n    else\n        switch costume to (join (MARIO) [Walk3])\n    end\n    stop [this script v]\nend\nif <(player action) = [turn]> then\n    switch costume to (join (MARIO) [Turn])\n    stop [this script v]\nend\nswitch costume to (join (MARIO) [Walk1])\nswitch costume to ((costume [number v]) + (([floor v] of (player frame) ) mod (4)))\n\ndefine made skid smoke\nchange [player frame v] by (1)\nif <((player frame) mod (3)) < [1]> then\n    add [smoke] to [particles v]\n    add (x) to [particles v]\n    add ((y) - (20)) to [particles v]\n    start sound [Skid v]\nend\n\ndefine Handle - god mode\nchange [speed x v] by ((6) * ([x axis v] of [controls v]))\nchange [speed y v] by ((6) * ([y axis v] of [controls v]))\nset [speed x v] to ((0.7) * (speed x))\nset [speed y v] to ((0.7) * (speed y))\nchange [x v] by (speed x)\nchange [y v] by (speed y)\n\ndefine check around player\nbroadcast (check for lava v)\nif <(y) < [0]> then\n    broadcast (Mario - Lose life v)\nend\nCheck around player at x: (x) y: ((y) - (8))\nCheck around player at x: (x) y: ((y) + (8))\n\ndefine limit camera edge x: (edge x) edge y: (edge y)\nif <(CAMERA X) < (edge x)> then\n    set [camera x v] to (edge x)\nend\nif <(CAMERA Y) < (edge y)> then\n    set [camera y v] to (edge y)\nend\nif <(CAMERA X) > (((32) * (GRID WIDTH)) - (edge x))> then\n    set [camera x v] to (((32) * (GRID WIDTH)) - (edge x))\nend\nif <(CAMERA Y) > (((32) * (GRID HEIGHT)) - (edge y))> then\n    set [camera y v] to (((32) * (GRID HEIGHT)) - (edge y))\nend\n\nwhen I receive [level - stop! v]\nstop [other scripts in sprite v]\n\nwhen I receive [level - start game loop v]\nset [coins v] to (total score)\ngame loop\n\ndefine Check around player at x: (x) y: (y)\nget tile at x: (x) y: (y)\nif <(tile) = [24]> then\n    replace item (tile index) of [tile grid v] with [2]\n    change [coins v] by (1)\n    start sound [Coin v]\nend\n\nwhen I receive [level - start game loop - respawn v]\nreset player\nset [coins v] to (total score)\ngame loop\n\nwhen I receive [level - done loading... v]\nset [spawn index v] to (item # of [28] in [tile grid v])\nif <(EDITOR) < [1]> then\n    replace item (spawn index) of [tile grid v] with [2]\nend\n\nwhen I receive [move player after enemy v]\nif <(BOUNCE PLAYER) > [0]> then\n    change [bounce player v] by (-1)\n    set [speed y v] to [13]\n    set [falling v] to [2]\n    set [jumping v] to [1]\nend\nmove camera\npaint sprite\n\ndefine Bump head\nget tile at x: (x) y: ((y) + ((height) + (8)))\nif <(tile) = [20]> then\n    set [bump index v] to (tile index)\nend\n\nwhen I receive [mario - lose life v]\nstart sound [Lose Life v]\nset [player action v] to [lose life]\nstop [other scripts in sprite v]\nrepeat (25)\n    paint sprite\n    broadcast (position tiles v)\nend\nset [speed y v] to [17]\nrepeat until <((y) - (CAMERA Y)) < [-200]>\n    change [speed y v] by (-1)\n    change [y v] by (speed y)\n    paint sprite\n    broadcast (position tiles v)\nend\nrepeat (30)\n    broadcast (position tiles v)\nend\nbroadcast (LEVEL - Load v) and wait\nbroadcast (Level - Start Game Loop - Respawn v) and wait\n\nwhen I receive [mario - level complete v]\nstart sound [GoalCard1 v]\nstop [other scripts in sprite v]\nset [speed x v] to [0]\nrepeat until <(falling) < [1]>\n    handle keys - jump / crouch\n    move sprite x\n    move sprite y\n    paint sprite\n    broadcast (position tiles v)\nend\npoint in direction (90)\nrepeat until <(x position) > [260]>\n    change [x v] by (5)\n    change [player frame v] by (0.5)\n    paint sprite\n    broadcast (position tiles v)\nend\nrepeat (30)\n    broadcast (position tiles v)\nend\nchange [level # v] by (1)\nset [total score v] to (COINS)\nbroadcast (LEVEL - Load v) and wait\nbroadcast (Level - Start Game Loop - Respawn v) and wait\n\nset [speed y v] to [17]\nrepeat until <((y) - (CAMERA Y)) < [-200]>\n    change [speed y v] by (-1)\n    change [y v] by (speed y)\n    paint sprite\n    broadcast (position tiles v)\nend\n\ndefine handle - get up\nset [player action v] to []\nset [orig y v] to (y)\nfix collision in direction dx: [0] dy: [1]\nif <(solid) > [0]> then\n    set [player action v] to [crouch]\n    set [y v] to (orig y)\n    change [speed x v] by ((direction) / (-200))\nend\n\nwhen I receive [collect 1up v]\nif <not <(MARIO) = [Mini]>> then\n    stop [this script v]\nend\nstop [other scripts in sprite v]\nstart sound [Power Up v]\nwait (0) seconds\nLoop Transformation\nset [mario v] to [Mario]\nLoop Transformation\nbroadcast (LEVEL - Continue Game Loop v)\n\ndefine Loop Transformation\nrepeat (3)\n    switch costume to (mariotransform v)\n    repeat (2)\n        broadcast (position tiles v)\n    end\n    switch costume to (join (MARIO) [Walk1])\n    repeat (3)\n        broadcast (position tiles v)\n    end\nend\n\nwhen I receive [level - continue game loop v]\ngame loop\n\nwhen I receive [mario - hurt v]\nif <(invulnerable) > [0]> then\n    stop [this script v]\nend\nif <(MARIO) = [Mini]> then\n    broadcast (Mario - Lose life v)\n    stop [this script v]\nend\nstop [other scripts in sprite v]\nstart sound [Power Down v]\nwait (0) seconds\nset [invulnerable v] to [70]\nLoop Transformation\nset [mario v] to [Mini]\nLoop Transformation\nbroadcast (LEVEL - Continue Game Loop v)\n\nwhen I receive [position tiles v]\nif <(invulnerable) > [0]> then\n    change [invulnerable v] by (-1)\nend\nif <((invulnerable) mod (2)) < [1]> then\n    set [ghost v] effect to (0)\nelse\n    set [ghost v] effect to (99)\nend\n\nwhen I receive [start v]\ngo to [front v] layer\nbroadcast (generate level v) and wait\nbroadcast (clone level tiles v) and wait\nbroadcast (LEVEL - Done Loading... v) and wait\nbroadcast (Level - Start Game Loop - Respawn v) and wait\n\nwhen flag clicked\ngo to [back v] layer\n\nwhen I receive [start v]\nset [coins v] to (total score)\n\nwhen flag clicked\nset [total score v] to [0]\nset [coins v] to (total score)\nhide variable [level # v]\n\nwhen I receive [level - continue game loop v]\ncheck for lava\nbroadcast (check for lava v)\n\ndefine check for lava\nif <touching color (#ff0000)?> then\n    broadcast (Mario - Hurt v)\nend\n\nforever\n\nwhen I receive [check for lava v]\ncheck for lava\n\nwhen I receive [start v]\nset [coins v] to [0]\nset [total score v] to [0]\n\ndefine move sprite x\nset [orig y v] to (y)\nchange [x v] by (speed x)\nfix collision in direction dx: [0] dy: [-1]\nif <(y) > ((orig y) + (([abs v] of (speed x) ) + (4)))> then\n    set [y v] to (orig y)\n    fix collision in direction dx: (speed x) dy: [0]\n    if <(solid) > [0]> then\n        set [speed x v] to [0]\n    end\nelse\n    if <(y) > (orig y)> then\n        set [speed x v] to ((speed x) * (0.85))\n    end\nend\n\n@Tiles\n\ndefine setup\nshow\nset [tile index v] to [1]\nset [tile x v] to [16]\nrepeat (CLONE COUNT X)\n    set [tile y v] to [16]\n    repeat (CLONE COUNT Y)\n        create clone of (_myself_ v)\n        change [tile y v] by (32)\n        change [tile index v] by (1)\n    end\n    change [tile x v] by (32)\n    change [tile index v] by ((GRID HEIGHT) - (CLONE COUNT Y))\nend\nhide\nset [tile index v] to []\n\nwhen I receive [position tiles v]\nif <(tile index) = []> then\n    editor brush\nelse\n    if <([abs v] of ((tile x) - (CAMERA X)) ) > ((CLONE COUNT X) * (16))> then\n        if <(tile x) < (CAMERA X)> then\n            loop tile x (CLONE COUNT X)\n        else\n            loop tile x (() - (CLONE COUNT X))\n        end\n    end\n    if <([abs v] of ((tile y) - (CAMERA Y)) ) > ((CLONE COUNT Y) * (16))> then\n        if <(tile y) < (CAMERA Y)> then\n            loop tile y (CLONE COUNT Y)\n        else\n            loop tile y (() - (CLONE COUNT Y))\n        end\n    end\n    set [tile v] to (item (tile index) of [tile grid v])\nend\nswitch costume to (big v)\ngo to x: ((tile x) - (CAMERA X)) y: ((tile y) - (CAMERA Y))\nif <(tile) < [2]> then\n    set [tile v] to [2]\nelse\n    if <<(tile) = [20]> or <(tile) = [24]>> then\n        change [tile v] by (([floor v] of ((timer) * (8)) ) mod (4))\n        if <(EDITOR) < [1]> then\n            if <(BUMP INDEX) = (tile index)> then\n                replace item (tile index) of [tile grid v] with [9]\n                set [bumped v] to [180]\n                if <(item # of (tile index) in [object idx v]) = [0]> then\n                    add [coin] to [particles v]\n                    add (tile x) to [particles v]\n                    add ((tile y) + (32)) to [particles v]\n                end\n            end\n        end\n    end\nend\nif <(bumped) > [0]> then\n    change [bumped v] by (-30)\n    change y by ((24) * ([sin v] of (bumped) ))\nend\nswitch costume to (tile)\n\ndefine loop tile x (tile skip)\nchange [tile x v] by ((tile skip) * (32))\nchange [tile index v] by ((tile skip) * (GRID HEIGHT))\n\ndefine loop tile y (tile skip)\nchange [tile y v] by ((tile skip) * (32))\nchange [tile index v] by (tile skip)\n\nwhen I receive [clone level tiles v]\nset size to (200) %\nset [clone count x v] to [16]\nset [clone count y v] to [13]\nsetup\n\ndefine editor brush\nif <<(EDITOR) < [1]> or <mouse down?>> then\n    hide\n    stop [this script v]\nend\nset [tile x v] to (((32) * ([tile grid x v] of [edtior v])) + (16))\nset [tile y v] to (((32) * ([tile grid y v] of [edtior v])) + (16))\nset [tile v] to ([chosen brush v] of [edtior v])\nset [ghost v] effect to (60)\nshow\n\nwhen I receive [level - done loading... v]\nif <(tile index) > []> then\n    set [tile index v] to ((1) + ([floor v] of ((tile y) / (32)) ))\n    change [tile index v] by ((GRID HEIGHT) * ([floor v] of ((tile x) / (32)) ))\nend\n\n@Enemy\n\ndefine get tile at x: (x) y: (y)\nset [tile grid x v] to ([floor v] of ((x) / (32)) )\nset [tile grid y v] to ([floor v] of ((y) / (32)) )\nset [tile index v] to (((1) + (tile grid y)) + ((tile grid x) * (GRID HEIGHT)))\nif <(tile grid y) < [0]> then\n    set [tile v] to []\nelse\n    set [tile v] to (item (tile index) of [tile grid v])\nend\nset [tile shape v] to (item (tile) of [tile shape v])\n\ndefine fix collision at point x: (x) y: (y) Part: (part)\nget tile at x: (x) y: (y)\nif <(tile shape) = []> then\n    stop [this script v]\nend\nset [mod x v] to ((x) mod (32))\nset [mod y v] to ((y) mod (32))\nset [temp v] to (letter (1) of (tile shape))\nif <<(temp) = [/]> or <(temp) = [\]>> then\n    set [m v] to ((1) / (letter (2) of (tile shape)))\n    set [c v] to ((letter (3) of (tile shape)) * ((32) * (m)))\n    if <(temp) = [\]> then\n        set [m v] to (() - (m))\n        set [c v] to ((32) - (c))\n    end\n    set [offset y v] to ((mod y) - (((mod x) * (m)) + (c)))\n    if <not <(offset y) < [0]>> then\n        stop [this script v]\n    end\n    if <(fix dy) < [0]> then\n        change [y v] by ((0) - (offset y))\n        set [solid v] to [10]\n        stop [this script v]\n    end\n    if <<(fix dy) = [0]> and <<(fix dx) > [0]> = <(m) > [0]>>> then\n        change [x v] by ((offset y) / (m))\n        set [solid v] to [10]\n        stop [this script v]\n    end\nend\nif <(tile shape) = [=]> then\n    if <<not <(part) = [feet]>> or <((mod y) - (fix dy)) < [32]>> then\n        stop [this script v]\n    end\nend\nset [solid v] to [10]\nif <(fix dy) < [0]> then\n    change [y v] by ((32) - (mod y))\nend\nif <(fix dx) < [0]> then\n    change [x v] by ((32) - (mod x))\nend\nif <(fix dy) > [0]> then\n    change [y v] by ((-TINY) - (mod y))\nend\nif <(fix dx) > [0]> then\n    change [x v] by ((-TINY) - (mod x))\nend\n\ndefine fix collision in direction dx: (dx) dy: (dy)\nset [fix dx v] to (dx)\nset [fix dy v] to (dy)\nset [solid v] to []\nrepeat (2)\n    fix collision at point x: ((x) - (width)) y: ((y) - (height)) Part: [feet]\n    fix collision at point x: ((x) - (width)) y: (y) Part: []\n    fix collision at point x: ((x) - (width)) y: ((y) + (height)) Part: []\n    fix collision at point x: (((x) + (width)) + (-TINY)) y: ((y) - (height)) Part: [feet]\n    fix collision at point x: (((x) + (width)) + (-TINY)) y: (y) Part: []\n    fix collision at point x: (((x) + (width)) + (-TINY)) y: ((y) + (height)) Part: []\n    if <(solid) < [1]> then\n        stop [this script v]\n    end\nend\n\ndefine move sprite y\nchange [y v] by (speed y)\nchange [falling v] by (1)\nfix collision in direction dx: [0] dy: (speed y)\nif <(solid) > [0]> then\n    if <(speed y) < [0]> then\n        set [falling v] to [0]\n    else\n        set [jumping v] to [99]\n    end\n    set [speed y v] to [0]\nend\n\nwhen flag clicked\n\ndefine Paint sprite\nswitch costume to (big v)\ngo to x: ((x) - (CAMERA X)) y: ((y) - (CAMERA Y))\nswitch costume to (costume)\n\nwhen I receive [position tiles v]\nif <(type) > []> then\n    Paint sprite\nend\n\nwhen I receive [move enemy v]\nif <<(EDITOR) > [0]> or <(type) = []>> then\n    stop [this script v]\nend\nMove Enemy\nif <(visible) = [1]> then\n    hide\nend\n\ndefine tick goomba\nchange [speed y v] by (-1)\nmove sprite y\nif <(direction) > [0]> then\n    if <(speed x) < [1]> then\n        change [speed x v] by (0.1)\n    end\nelse\n    if <(speed x) > [-1]> then\n        change [speed x v] by (-0.1)\n    end\nend\nmove sprite x\nchange [frame v] by (0.25)\nset [costume v] to ((root costume) + ([floor v] of ((frame) mod (2)) ))\nPaint sprite\nif <touching (mario v)?> then\n    if <([bop y v] of [mario v]) > []> then\n        if <(type) = [Goomba]> then\n            start sound [Stomped v]\n            point in direction (90)\n            set [frame v] to [0]\n            set [type v] to [squish]\n            set [costume v] to [Goomba Squish]\n            set [bounce player v] to [5]\n        else\n            if <(type) = [Koopa]> then\n                set [type v] to [Koopa Shell]\n                set [root costume v] to [26]\n                set [height v] to [15]\n            end\n        end\n        add [Score 100] to [particles v]\n        add (x) to [particles v]\n        add (y) to [particles v]\n    else\n        broadcast (Mario - Hurt v)\n    end\nend\nCheck Flip\n\ndefine spawn type (tile type)\nset [frame v] to []\nif <(tile type) = [29]> then\n    Set Type [Goomba] costume [2] width [14] height [14]\nend\nif <(tile type) = [30]> then\n    set [frame v] to [-1]\n    Set Type [Life] costume [Life] width [16] height [16]\nend\nif <(tile type) = [47]> then\n    Set Type [EndBox] costume [EndBox] width [16] height [16]\nend\nif <(tile type) = [68]> then\n    Set Type [Piranha] costume [9] width [16] height [32]\nend\nif <(tile type) = [69]> then\n    Set Type [Koopa] costume [5] width [16] height [24]\nend\nif <(tile type) = [70]> then\n    Set Type [lava] costume [lava] width [16] height [16]\nend\nif <(tile type) = [71]> then\n    Set Type [Drone] costume [Drone] width [16] height [16]\nend\n\nwhen I receive [level - done loading... v]\nbroadcast (ENITIY - clear v)\nbroadcast (ENITIY - SETUP v)\n\nwhen I receive [enitiy - clear v]\ndelete this clone\n\nwhen I receive [enitiy - setup v]\nspawn loop\n\ndefine spawn loop\nset [object item # v] to [1]\nrepeat (length of [object idx v])\n    set [spawn index v] to (item (object item #) of [object idx v])\n    spawn type (item (object item #) of [object type v])\n    hide\n    change [object item # v] by (1)\nend\nset [object item # v] to []\nset [type v] to []\n\ndefine Set Type (type) costume (costume) width (width) height (height)\nset [type v] to (type)\nset [costume v] to (costume)\nset [root costume v] to (costume)\nset [width v] to (width)\nset [height v] to (height)\nset [x v] to ([floor v] of (((spawn index) - (1)) / (GRID HEIGHT)) )\nset [y v] to (((spawn index) - (1)) mod (GRID HEIGHT))\nset [x v] to (((x) * (32)) + (16))\nset [y v] to (((y) * (32)) + (height))\npoint in direction ([direction v] of [mario v])\nPaint sprite\nif <<(EDITOR) > [0]> or <(frame) = []>> then\n    set [visible v] to [1]\nend\ncreate clone of (_myself_ v)\nset [visible v] to []\n\nshow\n\ndefine Tick Life\nchange [frame v] by (1)\nif <(frame) < [16]> then\n    stop [this script v]\nend\nif <(frame) < [48]> then\n    if <(frame) = [16]> then\n        start sound [ItemSprout v]\n    end\n    set [visible v] to [1]\n    change [y v] by (-1)\nelse\n    if <touching (mario v)?> then\n        broadcast (Collect 1up v)\n        delete this clone\n    end\nend\n\nstart sound [1up v]\n\ndefine Check Flip\nif <(BUMP INDEX) < [1]> then\n    stop [this script v]\nend\nget tile at x: ((x) - (width)) y: (((y) - (height)) - (8))\nif <not <(tile index) = (BUMP INDEX)>> then\n    get tile at x: ((x) + (width)) y: (((y) - (height)) - (8))\n    if <not <(tile index) = (BUMP INDEX)>> then\n        stop [this script v]\n    end\nend\nFlip\n\nwhen I start as a clone\nif <(type) = [Piranha]> then\n    change [x v] by (16)\n    if <(EDITOR) < [1]> then\n        change [y v] by (-64)\n        go to [back v] layer\n        go [forward v] (LAYERS - BACKGROUND) layers\n    end\nend\n\ndefine Tick Piranha\nchange [frame v] by (1)\nset [costume v] to ((9) + (([floor v] of ((frame) / (4)) ) mod (2)))\nset [temp v] to (((frame) / (16)) mod (8))\nif <([floor v] of (temp) ) = [2]> then\n    change [y v] by (4)\nend\nif <([floor v] of (temp) ) = [7]> then\n    change [y v] by (-4)\nend\nif <(temp) > [2.5]> then\n    if <touching (mario v)?> then\n        broadcast (Mario - Hurt v)\n    end\nend\n\ndefine Tick - Shell\nset [costume v] to (root costume)\nchange [speed y v] by (-1)\nmove sprite y\nif <(frame) < [3]> then\n    change [frame v] by (1)\n    stop [this script v]\nend\nif <(frame) = [3]> then\n    if <not <touching (mario v)?>> then\n        stop [this script v]\n    end\n    if <([x v] of [mario v]) < (x)> then\n        point in direction (90)\n    else\n        point in direction (-90)\n    end\n    set [visible v] to [2]\nend\nchange [frame v] by (0.5)\nset [speed x v] to ((direction) / (9))\nmove sprite x\nchange [costume v] by ([floor v] of ((frame) mod (4)) )\nPaint sprite\nif <<(frame) > [10]> and <touching (mario v)?>> then\n    if <([bop y v] of [mario v]) > []> then\n        start sound [Stomped v]\n        set [frame v] to [0]\n        set [bounce player v] to [5]\n        add [Score 100] to [particles v]\n        add (x) to [particles v]\n        add (y) to [particles v]\n        set [visible v] to [1]\n    else\n        broadcast (Mario - Hurt v)\n    end\nend\nCheck Flip\nCheck around player at x: (x) y: (y)\n\nset [type v] to [squish]\nset [costume v] to [Goomba Squish]\n\nwhen I receive [position tiles v]\nif <(visible) > [0]> then\n    show\nend\n\ndefine Move Enemy\nif <(type) = [Flip]> then\n    change [x v] by (speed x)\n    change [speed y v] by (-1)\n    change [y v] by (speed y)\n    if <(y) < ((CAMERA Y) - (200))> then\n        delete this clone\n    end\n    stop [this script v]\nend\nif <(type) = [squish]> then\n    change [frame v] by (1)\n    if <(frame) > [10]> then\n        delete this clone\n    end\nend\nif <(frame) < [0]> then\n    if <(frame) = [-1]> then\n        if <(BUMP INDEX) = (spawn index)> then\n            set [frame v] to [0]\n            point in direction ([direction v] of [mario v])\n            go to [back v] layer\n            go [forward v] (LAYERS - BACKGROUND) layers\n        end\n        stop [this script v]\n    end\n    if <([abs v] of ((x) - (CAMERA X)) ) > [260]> then\n        stop [this script v]\n    end\n    if <([abs v] of ((y) - (CAMERA Y)) ) > [200]> then\n        stop [this script v]\n    end\n    if <(x) > ([x v] of [mario v])> then\n        point in direction (-90)\n    else\n        point in direction (90)\n    end\nend\nif <(type) = [Goomba]> then\n    tick goomba\n    stop [this script v]\nend\nif <(type) = [Life]> then\n    Tick Life\n    stop [this script v]\nend\nif <(type) = [lava]> then\n    Tick - lava\n    stop [this script v]\nend\nif <(type) = [EndBox]> then\n    change [frame v] by (0.15)\n    set [costume v] to ((23) + (([floor v] of (frame) ) mod (3)))\n    if <touching (mario v)?> then\n        if <(distance to [mario v]) < [28]> then\n            broadcast (Mario - Level Complete v)\n            set [type v] to [costume]\n            set [costume v] to [EndBox]\n        end\n    end\n    stop [this script v]\nend\nif <(type) = [Piranha]> then\n    Tick Piranha\n    stop [this script v]\nend\nif <(type) = [Koopa]> then\n    tick goomba\n    stop [this script v]\nend\nif <(type) = [Koopa Shell]> then\n    Tick - Shell\n    stop [this script v]\nend\nif <(type) = [Drone]> then\n    Tick - Evil Drone \n    stop [this script v]\nend\n\nwhen I receive [move player after enemy v]\nif <<(EDITOR) < [1]> and <(visible) = [1]>> then\n    show\n    if <touching (enemy v)?> then\n        Flip\n    end\n    hide\nend\n\ndefine Flip\nset [speed y v] to [14]\nset [speed x v] to (([direction v] of [mario v]) / (45))\nset [type v] to [Flip]\nset rotation style [all around v]\npoint in direction (-90)\n\ndefine Check around player at x: (x) y: (y)\nget tile at x: (x) y: (y)\nif <(tile) = [24]> then\n    replace item (tile index) of [tile grid v] with [2]\n    change [coins v] by (1)\n    start sound [Coin v]\nend\n\nwhen I receive [start v]\nset size to (200) %\nhide\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [type v] to []\nset [visible v] to []\n\ndefine Tick - lava\nchange [frame v] by (1)\nset [costume v] to ((34) + (([floor v] of ((frame) / (4)) ) mod (5)))\nmove sprite x\nPaint sprite\nif <(temp) > [2.5]> then\n    if <touching (mario v)?> then\n        broadcast (Mario - Hurt v)\n    end\nend\n\nTick Life\n\ndefine Tick - Evil Drone \nchange [frame v] by (1)\nset [costume v] to ((39) + (([floor v] of ((frame) / (4)) ) mod (2)))\nset [temp v] to (((frame) / (16)) mod (8))\nif <([floor v] of (temp) ) = [2]> then\n    change [y v] by (10)\nend\nif <([floor v] of (temp) ) = [7]> then\n    change [y v] by (-10)\nend\nif <(temp) > [2.5]> then\n    if <touching (mario v)?> then\n        broadcast (Mario - Hurt v)\n    end\nend\n\ndefine move sprite x\nset [orig y v] to (y)\nchange [x v] by (speed x)\nfix collision in direction dx: [0] dy: [-1]\nif <(y) > ((orig y) + (([abs v] of (speed x) ) + (4)))> then\n    set [y v] to (orig y)\n    fix collision in direction dx: (speed x) dy: [0]\n    if <(solid) > [0]> then\n        set [speed x v] to [0]\n        turn right (180) degrees\n    end\nelse\n    if <(y) > (orig y)> then\n        set [speed x v] to ((speed x) * (0.85))\n    end\nend\n\n@particles\n\nwhen I start as a clone\nset [frame v] to [1]\nif <(type) = [coin]> then\n    start sound [Coin v]\n    set [speed y v] to [12]\nend\n\nwhen I receive [position tiles v]\nif <(frame) = []> then\n    Spawn Particles\n    stop [this script v]\nend\nif <(type) = [coin]> then\n    Tick - Coin\n    stop [this script v]\nend\nif < (type) contains [Score]?> then\n    Tick Score\n    stop [this script v]\nend\ntick -  smoke\n\ndefine tick -  smoke\nif <not <(frame) < [3]>> then\n    delete this clone\nend\nPostion with costume ([floor v] of (frame) )\nchange [frame v] by (0.4)\n\ndefine Spawn Particles\nrepeat until <(length of [particles v]) = [0]>\n    set [type v] to (item (1) of [particles v])\n    set [x v] to (item (2) of [particles v])\n    set [y v] to (item (3) of [particles v])\n    create clone of (_myself_ v)\n    repeat (3)\n        delete (1) of [particles v]\n    end\nend\n\ndefine Tick - Coin\nchange [speed y v] by (-1)\nif <(speed y) < [-12]> then\n    change [coins v] by (1)\n    delete this clone\nend\nchange [y v] by (speed y)\nPostion with costume ((3) + (([floor v] of (frame) ) mod (4)))\nchange [frame v] by (0.4)\n\ndefine Postion with costume (costume)\nswitch costume to (big v)\ngo to x: ((x) - (CAMERA X)) y: ((y) - (CAMERA Y))\nswitch costume to (costume)\nshow\n\ndefine Tick Score\ngo to [front v] layer\ngo [backward v] (1) layers\nchange [y v] by (1)\nPostion with costume (type)\nchange [frame v] by (1)\nif <(frame) > [60]> then\n    delete this clone\nend\n\nwhen I receive [start v]\ndelete all of [particles v]\nset [frame v] to []\nset size to (200) %\nhide\n\n@Sounds\n\nwhen I receive [level - start game loop - respawn v]\nmusic\n\nwhen I receive [level - start game loop v]\nmusic\n\ndefine music\nstop [other scripts in sprite v]\nif <(EDITOR) < [1]> then\n    forever\n        play sound [Music L1 v] until done\n    end\nend\n\nwhen I receive [mario - lose life v]\nstop [other scripts in sprite v]\n\nwhen I receive [level - stop! v]\nstop [other scripts in sprite v]\n\nwhen I receive [mario - level complete v]\nstop [other scripts in sprite v]\n\n@controls\n\nwhen I receive [check controls v]\nset [left v] to <<key (left arrow v) pressed?> or <key (a v) pressed?>>\nset [right v] to <<key (right arrow v) pressed?> or <key (d v) pressed?>>\nset [down v] to <<key (down arrow v) pressed?> or <key (s v) pressed?>>\nset [up v] to <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <key (space v) pressed?>>>\nset [x axis v] to ((right) - (left))\nset [y axis v] to ((up) - (down))\n\nwhen I receive [enitiy - setup v]\nspawn loop\n\n@Background2\n\nwhen I receive [position tiles v]\nset [screen x v] to ((x) - ((CAMERA X) / (2)))\nset x to (((screen x) mod ((sprite width) * (2))) - (sprite width))\nset y to ((244) - ((CAMERA Y) / (2)))\n\nwhen I receive [start v]\nset [layers - background v] to [2]\nshow\ngo to [back v] layer\nswitch costume to (size 100% v)\nset size to (200) %\nswitch costume to (background-1-1 v)\nset [sprite width v] to ((256) * ((size) / (100)))\nset [x v] to [0]\ncreate clone of (_myself_ v)\nnext costume\nchange [x v] by (sprite width)\n\n@Sprite3\n\nwhen flag clicked\nhide\n\nwhen I receive [clicked the play button v]\ngo to [front v] layer\nclear graphic effects\nshow\nswitch costume to (costume1 v)\nrepeat until <(costume [number v]) = [6]>\n    wait until <key (space v) pressed?>\n    repeat (50)\n        change [pixelate v] effect by (0.5)\n    end\n    next costume\n    repeat (50)\n        change [pixelate v] effect by (0.5)\n    end\n    clear graphic effects\nend\nwait until <key (space v) pressed?>\nbroadcast (Start v)\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\nwhen I receive [hide story v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\n@Sprite2\n\nwhen flag clicked\nset size to (100) %\nwait (0.001) seconds\ngo to [front v] layer\nshow\nwait until <<mouse down?> and <touching (mouse-pointer v)?>>\nbroadcast (clicked the play button v)\nhide\n\nwhen flag clicked\nforever\n    if <touching (mouse-pointer v)?> then\n        set [ghost v] effect to (10)\n        set size to (120) %\n    else\n        clear graphic effects\n        set size to (100) %\n    end\nend\n\n@Sprite4\n\nwhen flag clicked\ngo to [front v] layer\nshow\n\nwhen I receive [clicked the play button v]\nhide\n\n@Sprite1\n\n@Counter (not mine) we'll give credits\n\ndefine text: (text) size: (size) x: (x) y: (y) spacing: (spacing) centered: (centered) textID: (id)\nif <(centered) = [true]> then\n    go to x: (((((length of (text)) * ((spacing) * (size))) * (-0.5)) + (((spacing) * (size)) / (2))) + (x)) y: (y)\nelse\n    go to x: (x) y: (y)\nend\nset size to (size) %\nset [~i v] to [1]\nrepeat (length of (text))\n    switch costume to (letter (~i) of (text))\n    set [~cloneid v] to (id)\n    create clone of (_myself_ v)\n    change x by ((spacing) * (size))\n    change [~i v] by (1)\nend\n\nwhen I start as a clone\nshow\nclear graphic effects\nset [brightness v] effect to (100)\nset [~clonex v] to (x position)\nset [~cloney v] to (y position)\nif <(~cloneID) = [1]> then\n    change y by (9)\nend\nforever\n    change x by (((~cloneX) - (x position)) / (5))\n    change y by (((~cloneY) - (y position)) / (5))\nend\n\nwhen I receive [deleteclones v]\ndelete this clone\n\nwhen I receive [start v]\nset [.value v] to []\nset [~updatecounter v] to ((.value) + (1))\nforever\n    go to [front v] layer\n    if <not <(~updateCounter) = (.value)>> then\n        broadcast (deleteClones v)\n        text: (COINS) size: [100] x: [-200] y: [135] spacing: [0.25] centered: [true] textID: [1]\n        set [~updatecounter v] to (Points)\n    end\nend\n\nshow\n\nwhen flag clicked\nhide\n\n@Level Store\n\ndefine write value (value) delimiter (letter)\nset [encoded v] to (join (encoded) (join (value) (letter)))\n\ndefine save level (level #)\nset [encoded v] to []\nwrite value [1] delimiter [_]\nsave - Tile Grid\nSave - Objects\nrepeat ((level #) - (length of [level store v]))\n    add [] to [level store v]\nend\nreplace item (level #) of [level store v] with (encoded)\n\ndefine load level (level #)\nset [encoded v] to (item (level #) of [level store v])\nset [read index v] to [1]\nread value\nif <not <(value) = [1]>> then\n    stop [this script v]\nend\nLoad - Tile Grid\nLoad - Objects\n\ndefine read letter\nset [letter v] to (letter (read index) of (encoded))\nchange [read index v] by (1)\n\ndefine read value\nset [value v] to []\nread letter\nrepeat until <<(letter) > [9]> or <(letter) = []>>\n    set [value v] to (join (value) (letter))\n    read letter\nend\n\nwhen I receive [level - save v]\nsave level (LEVEL #)\n\nwhen I receive [level - load v]\nload level (LEVEL #)\nbroadcast (LEVEL - Done Loading... v) and wait\n\nset [-tiny v] to [0]\n\ndefine save - Tile Grid\nwrite value (GRID WIDTH) delimiter [_]\nwrite value (GRID HEIGHT) delimiter [_]\nset [tile index v] to [1]\nset [tile v] to (item (tile index) of [tile grid v])\nset [length v] to [0]\nrepeat (GRID HEIGHT)\n    repeat (GRID WIDTH)\n        if <<(length) < [26]> and <(tile) = (item (tile index) of [tile grid v])>> then\n            change [length v] by (1)\n        else\n            if <(tile) = [2]> then\n                set [tile v] to []\n            end\n            write value (tile) delimiter (item (length) of [a to z v])\n            set [tile v] to (item (tile index) of [tile grid v])\n            set [length v] to [1]\n        end\n        change [tile index v] by (GRID HEIGHT)\n    end\n    change [tile index v] by ((1) - ((GRID WIDTH) * (GRID HEIGHT)))\nend\nwrite value (tile) delimiter (item (length) of [a to z v])\n\ndefine Load - Tile Grid\ndelete all of [tile grid v]\nread value\nset [grid width v] to (value)\nread value\nset [grid height v] to (value)\nrepeat ((GRID WIDTH) * (GRID HEIGHT))\n    add [00] to [tile grid v]\nend\nset [tile index v] to [1]\nrepeat until <(read index) > (length of (encoded))>\n    read value\n    if <(value) = []> then\n        set [value v] to [2]\n    end\n    repeat (item # of (letter) in [a to z v])\n        replace item (tile index) of [tile grid v] with (value)\n        change [tile index v] by (GRID HEIGHT)\n        if <(tile index) > ((GRID WIDTH) * (GRID HEIGHT))> then\n            change [tile index v] by ((1) - ((GRID WIDTH) * (GRID HEIGHT)))\n            if <(tile index) > (GRID HEIGHT)> then\n                stop [this script v]\n            end\n        end\n    end\nend\n\ndefine Save - Objects\nset [row v] to [1]\nwrite value (length of [object idx v]) delimiter [_]\nrepeat (length of [object idx v])\n    write value (item (row) of [object idx v]) delimiter [_]\n    write value (item (row) of [object type v]) delimiter [_]\n    change [row v] by (1)\nend\n\ndefine Load - Objects\ndelete all of [object idx v]\ndelete all of [object type v]\nread value\nrepeat (value)\n    read value\n    add (value) to [object idx v]\n    read value\n    add (value) to [object type v]\nend\n\n@Edtior\n\ndefine generate level\ndelete all of [tile grid v]\ndelete all of [object idx v]\ndelete all of [object type v]\nadd wall column\nrepeat ((GRID WIDTH) - (2))\n    add boxed column\nend\nadd wall column\n\nset [grid width v] to [100]\nset [grid height v] to [40]\n\ndefine add wall column\nrepeat (GRID HEIGHT)\n    add [10] to [tile grid v]\nend\n\ndefine add boxed column\nadd [7] to [tile grid v]\nrepeat ((GRID HEIGHT) - (2))\n    add [2] to [tile grid v]\nend\nadd [10] to [tile grid v]\n\nwhen I receive [generate level v]\nset [chosen brush v] to [10]\nset [level # v] to [1]\nset [brush v] to [0]\nset [editor v] to [0]\ndelete all of [tile grid v]\nbroadcast (LEVEL - load v) and wait\nif <(length of [tile grid v]) = [0]> then\n    generate level\nend\n\nwhen I receive [move player v]\nif <(EDITOR) < [1]> then\n    stop [this script v]\nend\nget tile at x: ((mouse x) + (CAMERA X)) y: ((mouse y) + (CAMERA Y))\nif <not <mouse down?>> then\n    set [brush v] to [0]\n    delete all of [edited indexes v]\n    stop [this script v]\nend\nif <(item (chosen brush) of [tile keymap v]) = [9]> then\n    Paint Entity\n    stop [this script v]\nend\nPaint Tile\n\ndefine get tile at x: (x) y: (y)\nset [tile grid x v] to ([floor v] of ((x) / (32)) )\nset [tile grid y v] to ([floor v] of ((y) / (32)) )\nset [tile index v] to (((1) + (tile grid y)) + ((tile grid x) * (GRID HEIGHT)))\nset [tile v] to (item (tile index) of [tile grid v])\n\nwhen [1 v] key pressed\nnext brush [1]\n\nwhen [2 v] key pressed\nnext brush [2]\n\nwhen [0 v] key pressed\nif <(username) = [giddledude]> then\n    if <(EDITOR) > [0]> then\n        broadcast (LEVEL - STOP! v) and wait\n        broadcast (LEVEL - save v) and wait\n        set [editor v] to [0]\n        hide variable [level # v]\n        broadcast (LEVEL - Done Loading... v) and wait\n        broadcast (LEVEL - Start Game Loop v)\n    else\n        set [editor v] to [1]\n        show variable [level # v]\n        broadcast (LEVEL - Load v) and wait\n        broadcast (LEVEL - Start Game Loop v)\n    end\nend\n\ndefine next brush (key)\nrepeat (length of [tile keymap v])\n    if <(chosen brush) < (length of [tile keymap v])> then\n        change [chosen brush v] by (1)\n    else\n        set [chosen brush v] to [0]\n    end\n    if <(item (chosen brush) of [tile keymap v]) = (key)> then\n        set [tile group v] to (item (chosen brush) of [tile groups v])\n        if <<(auto) < [1]> or <(tile group) = []>> then\n            stop [this script v]\n        end\n        if <(item # of (tile group) in [tile groups v]) = (chosen brush)> then\n            stop [this script v]\n        end\n    end\nend\n\nwhen [3 v] key pressed\nnext brush [3]\n\nwhen [e v] key pressed\nset [obj # v] to (item # of (tile index) in [object idx v])\nif <(obj #) > [0]> then\n    set [chosen brush v] to (item (obj #) of [object type v])\nelse\n    set [chosen brush v] to (tile)\nend\n\nwhen [4 v] key pressed\nnext brush [4]\n\nwhen [l v] key pressed\nif <(EDITOR) < [1]> then\n    stop [this script v]\nend\nask (join [enter Level Number \(Current ] (join (LEVEL #) [\)])) and wait\nif <(round (answer)) < [1]> then\n    stop [this script v]\nend\nbroadcast (LEVEL - STOP! v) and wait\nbroadcast (LEVEL - Save v) and wait\nset [level # v] to (round (answer))\nbroadcast (LEVEL - Load v) and wait\nbroadcast (LEVEL - Start Game Loop v)\n\nwhen [r v] key pressed\nif <(EDITOR) < [1]> then\n    stop [this script v]\nend\nask [Are you sure \(Y/N\)] and wait\nif <not <(answer) = [Y]>> then\n    stop [this script v]\nend\nbroadcast (LEVEL - STOP! v) and wait\nask (join [Enter Level Width \(Current ] (join (GRID WIDTH) [\)])) and wait\nif <not <(answer) = []>> then\n    set [grid width v] to (answer)\nend\nask (join [Enter Level Height \(Current ] (join (GRID HEIGHT) [\)])) and wait\nif <not <(answer) = []>> then\n    set [grid height v] to (answer)\nend\ngenerate level\nbroadcast (LEVEL - Done Loading... v) and wait\nbroadcast (LEVEL - Start Game Loop v)\n\nwhen [9 v] key pressed\nnext brush [9]\n\ndefine Paint Entity\nif <(brush) > [0]> then\n    stop [this script v]\nend\nset [brush v] to (chosen brush)\nset [found index v] to (item # of (tile index) in [object idx v])\nif <(found index) > [0]> then\n    delete (found index) of [object idx v]\n    delete (found index) of [object type v]\nelse\n    add (tile index) to [object idx v]\n    add (brush) to [object type v]\nend\nbroadcast (ENITIY - clear v)\nbroadcast (ENITIY - SETUP v)\n\ndefine Paint Tile\nif <(brush) = [0]> then\n    if <(tile) = (chosen brush)> then\n        set [brush v] to [2]\n    else\n        set [brush v] to (chosen brush)\n        if <(auto) > [0]> then\n            set [tile group v] to (item (chosen brush) of [tile groups v])\n            if <(tile group) > [0]> then\n                if <(tile group) = (item (tile) of [tile groups v])> then\n                    set [brush v] to [2]\n                end\n            end\n        end\n    end\nend\nif <(brush) = [28]> then\n    set [found index v] to (item # of (brush) in [tile grid v])\n    replace item (found index) of [tile grid v] with [2]\nend\nreplace item (tile index) of [tile grid v] with (brush)\nif <(auto) > [0]> then\n    if <not <[edited indexes v] contains (tile index)?>> then\n        add (tile index) to [edited indexes v]\n    end\n    fix costume at (tile index)\n    fix costume at ((tile index) + (1))\n    fix costume at ((tile index) + (GRID HEIGHT))\n    fix costume at ((tile index) - (1))\n    fix costume at ((tile index) - (GRID HEIGHT))\nend\n\ndefine fix costume at (idx)\nif <key (space v) pressed?> then\n    if <not <[edited indexes v] contains (idx)?>> then\n        stop [this script v]\n    end\nend\nset [tile v] to (item (idx) of [tile grid v])\nif <(item (tile) of [tile recipes v]) = []> then\n    stop [this script v]\nend\nset [tile group v] to (item (tile) of [tile groups v])\nif <(tile group) < [1]> then\n    stop [this script v]\nend\nset [recipe v] to []\nBuild recipe ((idx) + (1))\nBuild recipe ((idx) + (GRID HEIGHT))\nBuild recipe ((idx) - (1))\nBuild recipe ((idx) - (GRID HEIGHT))\nset [tile v] to [1]\nrepeat (length of [tile groups v])\n    if <(item (tile) of [tile groups v]) = (tile group)> then\n        if < (item (tile) of [tile recipes v]) contains (recipe)?> then\n            replace item (idx) of [tile grid v] with (tile)\n            stop [this script v]\n        end\n    end\n    change [tile v] by (1)\nend\n\ndefine Build recipe (edge index)\nif <key (space v) pressed?> then\n    if <not <[edited indexes v] contains (edge index)?>> then\n        set [recipe v] to (join (recipe) [0])\n        stop [this script v]\n    end\nend\nset [edge tile v] to (item (edge index) of [tile grid v])\nif <(tile group) = (item (edge tile) of [tile groups v])> then\n    set [recipe v] to (join (recipe) [1])\nelse\n    set [recipe v] to (join (recipe) [0])\nend\n\nwhen [q v] key pressed\nset [auto v] to ((1) - (auto))\n\nwhen [5 v] key pressed\nnext brush [5]\n\n@skip the story\n\nwhen flag clicked\nhide\n\nwhen I receive [clicked the play button v]\nshow\nrepeat until <<mouse down?> and <touching (mouse-pointer v)?>>\n    wait (0.01) seconds\n    go to [front v] layer\nend\nbroadcast (hide story v) and wait\nbroadcast (Start v)\nhide\n\nwhen I receive [start v]\nhide\n\n@end\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nwait (1) seconds\nwait until <(LEVEL #) = [15]>\nshow\nforever\n    repeat (5)\n        go to [front v] layer\n    end\n    show\n    stop [all v]\nend\n\n@Sprite5\n\nwhen flag clicked\nhide\n\nforever\n    go to [front v] layer\n    show\nend\n\n