-MARIO- Tile Scrolling Platformer v2.0
@Stage\n\n@Mario\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 flag clicked\nbroadcast (generate level v) and wait\nbroadcast (clone level tiles v) and wait\nbroadcast (LEVEL - Start Game Loop - Respawn v) and wait\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\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 [width v] to [8]\nset [height v] to [24]\nset [camera x v] to (x)\nset [camera y 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]\nset [fireballs v] to [0]\nset [star power 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 (hide fireballs v)\n    broadcast (check fireballs 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\n    handle keys - fire\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]> or <(MARIO) = [Mini]>>> 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 ((0) - (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        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 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        make 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                    make 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                        if <(MARIO) = [Mini]> then\n                            set [jumping v] to [3]\n                        end\n                    end\n                end\n            end\n        else\n            set [jumping v] to [0]\n        end\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    end\nelse\n    if <(y) > (orig y)> then\n        set [speed x v] to ((speed x) * (0.85))\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)\nif <(STAR POWER) > [0]> then\n    change [color v] effect by (10)\nelse\n    set [color v] effect to (0)\nend\ngo to x: ((x) - (CAMERA X)) y: ((y) - (CAMERA Y))\nif <(throw) > [0]> then\n    switch costume to (join (MARIO) (join [Throw] ([ceiling v] of (throw) )))\n    change [throw v] by (-0.25)\n    stop [this script v]\nend\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 make 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\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\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 [0]\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 [0]\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)\n\nwhen I receive [mario - level complete 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.6)\n    paint sprite\n    broadcast (position tiles v)\nend\nrepeat (30)\n    broadcast (position tiles v)\nend\nchange [level # v] by (1)\nbroadcast (LEVEL - Load v) and wait\nbroadcast (LEVEL - Start Game Loop - Respawn v)\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\nset [mario v] to [Mario]\n\nset [mario v] to [Mini]\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]\nset [throw v] to [0]\nif <(MARIO) = [Fire]> then\n    set [mario v] to [Mario]\n    paint sprite\n    repeat (30)\n        broadcast (position tiles v)\n    end\nelse\n    Loop Transformation\n    set [mario v] to [Mini]\n    Loop Transformation\nend\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 [f v] key pressed\nset [mario v] to [Fire]\n\ndefine handle keys - fire\nif <([button b v] of [controls v]) = [1]> then\n    if <(MARIO) = [Fire]> then\n        if <(FIREBALLS) < [2]> then\n            change [fireballs v] by (1)\n            set [throw v] to [2]\n            start sound [Fireball v]\n            broadcast (Mario - Fireball v)\n        end\n    end\nend\n\nif <key (0 v) pressed?> then\n    set [color v] effect to (0)\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 ((0) - (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 ((0) - (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                    change [coins v] by (1)\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 [editor v])) + (16))\nset [tile y v] to (((32) * ([tile grid y v] of [editor v])) + (16))\nset [tile v] to ([chosen brush v] of [editor v])\nset [ghost v] effect to (50)\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 ((0) - (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 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\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\nset size to (200) %\nhide\nset [type v] to []\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [visible v] to []\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 [g v] key pressed\nif <(type) = []> then\n    set [spawn index v] to ([tile index v] of [editor v])\n    spawn type [29]\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\nGeneral Move [0.1] max x [1]\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 <(STAR POWER) > [0]> then\n        Flip\n        stop [this script v]\n    end\n    if <([bop y v] of [mario v]) > []> then\n        start sound [Stomped v]\n        point in direction (90)\n        set [frame v] to [0]\n        set [bounce player v] to [5]\n        if <(type) = [Goomba]> then\n            set [type v] to [squish]\n            set [costume v] to [Goomba Squish]\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) = [46]> then\n    set [frame v] to [-1]\n    Set Type [Life] costume [Star] width [16] height [16]\nend\nif <(tile type) = [70]> then\n    set [frame v] to [-1]\n    Set Type [Life] costume [FireFlower] 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\n\nwhen I receive [level - done loading... v]\nbroadcast (ENTITY - clear v)\nbroadcast (ENTITY - setup v)\n\nwhen I receive [entity - clear v]\nDelete Clone\n\nwhen I receive [entity - 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\nset [frame v] to [0]\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)\n    if <(frame) = [47]> then\n        go to [front v] layer\n    end\nelse\n    if <(root costume) = [Life]> then\n        General Move [3] max x [1]\n    end\n    if <touching (mario v)?> then\n        start sound [Just What I Needed v]\n        if <<(root costume) = [FireFlower]> and <(MARIO) = [Mario]>> then\n            set [mario v] to [Fire]\n        else\n            if <(root costume) = [Star]> then\n                broadcast (Collect Star Power v)\n            else\n                broadcast (Collect 1up v)\n            end\n        end\n        delete this clone\n    end\nend\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\nif <(type) = [Fireball]> then\n    set [root costume v] to [Flame]\n    set [costume v] to (root costume)\n    set [width v] to [8]\n    set [height v] to [8]\n    set [x v] to ([x v] of [mario v])\n    set [y v] to (([y v] of [mario v]) + (14))\n    set rotation style [all around v]\n    if <([direction v] of [mario v]) > [0]> then\n        set [speed x v] to [12]\n    else\n        set [speed x v] to [-12]\n    end\n    set [speed y v] to [-6]\n    paint sprite\n    set [visible v] to [2]\n    set [frame v] to [0]\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) ) < [4]> then\n    if <([abs v] of ((x) - ([x v] of [mario v])) ) < [45]> then\n        set [frame v] to [1]\n    end\nend\nif <([floor v] of (temp) ) = [4]> then\n    change [y v] by (4)\nend\nif <([floor v] of (temp) ) = [7]> then\n    change [y v] by (-4)\nend\nif <(temp) > [4.2]> then\n    if <touching (mario v)?> then\n        if <(STAR POWER) > [0]> then\n            Flip\n            stop [this script v]\n        end\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        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\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 Clone\n    end\n    stop [this script v]\nend\nif <(y) < [-32]> then\n    Delete Clone\nend\nif <(type) = [squish]> then\n    change [frame v] by (1)\n    if <(frame) > [10]> then\n        Delete 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 ((0) - ([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) = [Piranha]> then\n    Tick Piranha\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) = [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) = [Fireball]> then\n    Tick - Fireball\n    stop [this script v]\nend\n\nwhen I receive [move player after enemy v]\nif < [Flip Life EndBox] contains (type)?> then\n    stop [this script v]\nend\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\nstart sound [KickShell v]\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 [mario - fireball v]\nif <(type) = []> then\n    set [type v] to [Fireball]\n    create clone of (_myself_ v)\n    set [type v] to []\nend\n\ndefine Tick - Fireball\nchange [frame v] by (1)\nif <((frame) mod (3)) = [0]> then\n    turn right (90) degrees\nend\nmove sprite x\nif <(speed x) = [0]> then\n    Delete Clone\nend\nif <([abs v] of ((x) - (CAMERA X)) ) > [240]> then\n    Delete Clone\nend\nif <(speed y) > [-12]> then\n    change [speed y v] by (-1.5)\nend\nmove sprite y\nif <(falling) = [0]> then\n    set [speed y v] to [11]\nend\n\ndefine Delete Clone\nif <(type) = [Fireball]> then\n    change [fireballs v] by (-1)\nend\ndelete this clone\n\nwhen I receive [position tiles v]\nif <(visible) > [0]> then\n    show\nend\n\nwhen I receive [hide fireballs v]\nif <(type) = [FireBall]> then\n    hide\n    stop [this script v]\nend\nif <(visible) > [0]> then\n    show\nend\n\nwhen I receive [check fireballs v]\nif <(type) = [FireBall]> then\n    show\n    if <touching (enemy v)?> then\n        Delete Clone\n    end\n    hide\nend\n\ndefine General Move (acc x) max x (max)\nchange [speed y v] by (-1)\nmove sprite y\nif <(direction) > [0]> then\n    if <(speed x) < (max)> then\n        change [speed x v] by (acc x)\n    end\nelse\n    if <(speed x) > (() - (max))> then\n        change [speed x v] by (() - (acc x))\n    end\nend\nmove sprite x\n\n@Editor\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\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 [editor v] to [0]\nset [level # v] to [1]\ndelete all of [tile grid v]\nbroadcast (LEVEL - Load v) and wait\nset [brush v] to [0]\nset [chosen brush v] to [10]\nif <(length of [tile grid v]) = [0]> then\nend\n\nset [grid width v] to [200]\nset [grid height v] to [40]\ngenerate level\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 <(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)\nelse\n    broadcast (LEVEL - STOP!!! v) and wait\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)\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 [1]\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 [4 v] key pressed\nnext brush [4]\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 [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 - Respawn v)\n\nwhen [r v] key pressed\nif <(EDITOR) < [1]> then\n    stop [this script v]\nend\nask [Reset Level - 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 - Respawn 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 (ENTITY - clear v)\nbroadcast (ENTITY - 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@particles\n\nwhen flag clicked\ndelete all of [particles v]\nset [frame v] to []\nset size to (200) %\nhide\n\nwhen I start as a clone\nset [frame v] to [1]\nif <(type) = [coin]> then\n    set [speed y v] to [12]\n    start sound [Coin v]\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\nPosition 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    delete this clone\nend\nchange [y v] by (speed y)\nPosition with Costume ((3) + (([floor v] of (frame) ) mod (4)))\nchange [frame v] by (0.5)\n\ndefine Position 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\nchange [y v] by (1)\nPosition with Costume (type)\nchange [frame v] by (1)\nif <(frame) > [60]> then\n    delete this clone\nend\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?>>\nset [x axis v] to ((right) - (left))\nset [y axis v] to ((up) - (down))\nif <key (x v) pressed?> then\n    change [button b v] by (1)\nelse\n    set [button b v] to []\nend\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\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 [] 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@Background2\n\nwhen flag clicked\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\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\n@Sounds\n\nwhen I receive [level - start game loop v]\nmusic\n\nwhen I receive [level - start game loop - respawn 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 [collect star power v]\nstop [other scripts in sprite v]\nset [star power v] to [1000]\nplay sound [Star Power v] until done\nplay sound [Level Select v] until done\nset [star power v] to []\nmusic\n\nwhen I receive [mario - level complete v]\nstop [other scripts in sprite v]\nplay sound [Course Clear v] until done\n\n@Thumbnail\n\nwhen flag clicked\nhide variable [level # v]\nshow variable [coins v]\ngo to x: (0) y: (0)\nforever\n    go to [front v] layer\n    set [ghost v] effect to (100)\nend\n\nwhen [timer v] > (Check Time)\nerase all\nshow\nset [ghost v] effect to (100)\nswitch costume to (pick random (1) to (4))\nhide variable [level # v]\nhide variable [coins v]\nrepeat (50)\n    change [ghost v] effect by (-2.5)\nend\n\nwhen flag clicked\nhide\nforever\n    set [check time v] to ((timer) + (0.1))\nend\n\n@❤️⭐\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nforever\n    show\n    set [ghost v] effect to (100)\n    go to x: (180) y: (140)\n    set size to (25) %\n    wait (pick random (9) to (12)) seconds\n    point in direction (90)\n    go to [front v] layer\n    repeat (20)\n        change [ghost v] effect by (-5)\n    end\n    repeat (100)\n        point in direction ((([sin v] of ((timer) * (200)) ) * (5)) + (90))\n    end\n    repeat until <[4] > (size)>\n        change size by (((0) - (size)) / (5))\n        turn right (((180) - (direction)) / (5)) degrees\n    end\n    hide\nend\n\n
   ------❗⠀READ THE ENTIRE DESCRIPTION!⠀❗------\n\nUpdated! Part 20! - Fixed some bugs \nand added Star Power up!\n(Unfinished)\n\n★★★ Controls: ★★★                                        \nW/A/S/D or Arrow keys to move \nLaunch the Fireballs by pressing the 'X' key \n(only when Fire Mario)\n[ 0 ] - to toggle Editor Mode\n \nIn Editing Mode:\n\n[ 1, 2, 3, 4, 5 ] - Change tile item, \nclick multiple times for different tiles.\n[ 5 ] - Solid bushes, Slopes (Doesn't support\nauto arranging) \n[ 9 ] - Places "Enemies"-  \nGoombas - Piranha Plants & Life Mushroom, Koopas, Fire Flower, place, and then press "0". You can place Life Mushroom (or Fire Flower) on the [ ? ] block.                   \n[ E ] - Eyedropper, Press 'E' to pick \ntile under the cursor\n[ L ] - Make a copy of the previous\nlevel, or load an existing level. Level 1 -> Level 2 \n[ R ] - Reset level, can change the width and height of the level and clear the level.\n[ Q ] - To toggle the auto arrange tiles feature.\n[Space key] - For example === If you want a draw blue platform (semi-solid) in front of the orange platform, Press 'Space Key' while you dragging :)\n\nGood luck :) Oh, and don't forget to ❤️and⭐ :)