Super Mario Bros 3 - A Scrolling Platformer
@Stage\n\nwhen I receive [game v]\nforever\n    if <<([costume # v] of [background v]) = [10]> or <([costume # v] of [background v]) = [11]>> then\n        switch backdrop to (light blue v)\n    else\n        if <<([costume # v] of [background v]) = [6]> or <([costume # v] of [background v]) = [7]>> then\n            switch backdrop to (sky blue v)\n        else\n            if <<([costume # v] of [background v]) = [8]> or <([costume # v] of [background v]) = [9]>> then\n                switch backdrop to (castle grey v)\n            else\n                if <<([costume # v] of [background v]) = [2]> or <([costume # v] of [background v]) = [3]>> then\n                    switch backdrop to (blue v)\n                else\n                    if <<([costume # v] of [background v]) = [14]> or <([costume # v] of [background v]) = [15]>> then\n                        switch backdrop to (dessert yellow v)\n                    else\n                        if <<([costume # v] of [background v]) = [16]> or <([costume # v] of [background v]) = [17]>> then\n                            switch backdrop to (marine blue v)\n                        else\n                            if <<([costume # v] of [background v]) = [18]> or <([costume # v] of [background v]) = [19]>> then\n                                switch backdrop to (thunder blue v)\n                            else\n                                if <<([costume # v] of [background v]) = [20]> or <([costume # v] of [background v]) = [21]>> then\n                                    switch backdrop to (cabin brown v)\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nswitch backdrop to (mainemenu v)\nwait (2.5) seconds\nswitch backdrop to (mainemenu2 v)\n\nwhen flag clicked\nwait until <(LEVEL #) = [6]>\nbroadcast (End v)\n\n@Blank\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\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 (((x) * (32)) + (16))\n    set [y v] to (((y) * (32)) + (height))\nend\nset [x v] to [100]\nset [y v] to [100]\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 [invunlerable v] to [0]\nset [fireballs v] to [0]\npoint in direction (90)\nmove camera\n\ndefine game loop\nset [mario time v] to [300]\nset size to (200) %\nbroadcast (TIME CHANGE v)\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    check speed\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\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]> or <(player action) = [slide]>> then\n    if <(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\n    else\n        if <([down v] of [controls v]) > [0]> then\n            stop [this script v]\n        end\n        set [player action v] to [walk]\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        if <<(temp) = [/]> or <(temp) = [\]>> then\n            set [player action v] to [slide]\n            if <(temp) = [/]> then\n                change [speed x v] by (-0.3)\n            end\n            if <(temp) = [\]> then\n                change [speed x v] by (0.3)\n            end\n            set [bop y v] to (y)\n            make skid smoke\n        else\n            set [player action v] to [crouch]\n        end\n    end\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                    if <(PLAYER) = [Luigi]> then\n                        set [speed y v] to [16]\n                    else\n                        set [speed y v] to [13]\n                    end\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)\ngo to x: ((x) - (CAMERA X)) y: ((y) - (CAMERA Y))\nif <(throw) > [0]> then\n    switch costume to (join (PLAYER) (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 (PLAYER) (join (MARIO) [Crouch]))\n    stop [this script v]\nend\nif <(player action) = [slide]> then\n    switch costume to (join (PLAYER) (join (MARIO) [Slide]))\n    stop [this script v]\nend\nif <(player action) = [lose life]> then\n    switch costume to (join (PLAYER) (join (MARIO) [Death]))\n    stop [this script v]\nend\nif <(falling) > [1]> then\n    if <(speed y) > [0]> then\n        switch costume to (join (PLAYER) (join (MARIO) [Jump]))\n        if <(MARIO SPEED) = [7]> then\n            switch costume to (join (PLAYER) (join (MARIO) [RunJump]))\n        end\n    else\n        switch costume to (join (PLAYER) (join (MARIO) [Walk3]))\n        if <(MARIO SPEED) = [7]> then\n            switch costume to (join (PLAYER) (join (MARIO) [RunJump]))\n        end\n    end\n    stop [this script v]\nend\nif <(player action) = [turn]> then\n    switch costume to (join (PLAYER) (join (MARIO) [Turn]))\n    stop [this script v]\nend\nswitch costume to (join (PLAYER) (join (MARIO) [Walk1]))\nif <(MARIO SPEED) = [7]> then\n    start sound [PMeter1 v]\n    switch costume to (join (PLAYER) (join (MARIO) [Run1]))\nend\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))\nif <not <(MARIO) = [Mini]>> then\n    check around player at x: (x) y: ((y) + (8))\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 [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 [score v] by (100)\n    change [coins v] by (1)\n    start sound [Coin v]\nend\nif <(tile) = [143]> then\n    broadcast (mario - lose life v)\nend\nif <(tile) = [259]> then\n    broadcast (mario - hurt 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 [Mammamia v]\nstart sound [Lose Life v]\nchange [mario lives v] by (-1)\nif <(MARIO LIVES) = [0]> then\n    broadcast (GAME OVER v)\n    stop [all v]\nend\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 [mario speed v] to [0]\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\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 (join (PLAYER) [Transform])\n    repeat (2)\n        broadcast (position tiles v)\n    end\n    switch costume to (join (PLAYER) (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 <(invunlerable) > [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 [Oh No v]\nstart sound [Power Down v]\nwait (0) seconds\nset [invunlerable v] to [70]\nset [throw v] to [0]\nif <[super powerups v] contains (MARIO)?> 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 <(invunlerable) > [0]> then\n    change [invunlerable v] by (-1)\nend\nif <((invunlerable) mod (2)) < [1]> then\n    set [ghost v] effect to (0)\nelse\n    set [ghost v] effect to (99)\nend\n\nwhen I receive [time change v]\nforever\n    if <(EDITOR) = [0]> then\n        wait (1) seconds\n        change [mario time v] by (-1)\n    end\n    if <(MARIO TIME) = [0]> then\n        broadcast (mario - instant kill v)\n    end\nend\n\nwhen I receive [mario - instant kill v]\nbroadcast (mario - lose life v)\n\nwhen I receive [mario speed change up v]\nchange [speed x v] by (1)\n\nwhen I receive [mario speed change down v]\nchange [speed x v] by (-1)\n\ndefine check speed\nif <[-10] > (speed x)> then\n    if <(MARIO SPEED) = [0]> then\n        set [speed x v] to [-10]\n    end\nend\nif <[-11] > (speed x)> then\n    if <(MARIO SPEED) = [2]> then\n        set [speed x v] to [-11]\n    end\nend\nif <[-12] > (speed x)> then\n    if <(MARIO SPEED) = [3]> then\n        set [speed x v] to [-12]\n    end\nend\nif <[-13] > (speed x)> then\n    if <(MARIO SPEED) = [4]> then\n        set [speed x v] to [-13]\n    end\nend\nif <[-14] > (speed x)> then\n    if <(MARIO SPEED) = [5]> then\n        set [speed x v] to [-14]\n    end\nend\nif <[-15] > (speed x)> then\n    if <(MARIO SPEED) = [6]> then\n        set [speed x v] to [-15]\n    end\nend\nif <[-15] > (speed x)> then\n    if <<(MARIO SPEED) = [7]> or <(MARIO SPEED) = [8]>> then\n        set [speed x v] to [-16]\n    end\nend\nif <(speed x) > [10]> then\n    if <(MARIO SPEED) = [0]> then\n        set [speed x v] to [10]\n    end\nend\nif <(speed x) > [11]> then\n    if <(MARIO SPEED) = [2]> then\n        set [speed x v] to [11]\n    end\nend\nif <(speed x) > [12]> then\n    if <(MARIO SPEED) = [3]> then\n        set [speed x v] to [12]\n    end\nend\nif <(speed x) > [13]> then\n    if <(MARIO SPEED) = [4]> then\n        set [speed x v] to [13]\n    end\nend\nif <(speed x) > [14]> then\n    if <(MARIO SPEED) = [5]> then\n        set [speed x v] to [14]\n    end\nend\nif <(speed x) > [15]> then\n    if <(MARIO SPEED) = [6]> then\n        set [speed x v] to [15]\n    end\nend\nif <(speed x) > [16]> then\n    if <<(MARIO SPEED) = [7]> or <(MARIO SPEED) = [8]>> then\n        set [speed x v] to [16]\n    end\nend\n\nwhen [n v] key pressed\nif <(EDITOR) < [1]> then\n    stop [this script v]\nend\nif <(PLAYER) = [Mario]> then\n    set [player v] to [Luigi]\nelse\n    if <(PLAYER) = [Luigi]> then\n        set [player v] to [Mario]\n    end\nend\n\nwhen I receive [level - start game loop v]\nforever\n    if <(EDITOR) = [0]> then\n        if <[0] < <<<(item # of ((tile index) - ((MARIO) + (1))) in [object idx v]) and (item (item # of ((tile index) - ((MARIO) + (1))) in [object idx v]) of [object type v])> = [143]> and <[0] = [0]>>> then\n            if <([down v] of [controls v]) > [0]> then\n                broadcast (Mario - Pipe Down v)\n            end\n        end\n        if <[0] < <<(item # of ((tile index) + (1)) in [object idx v]) and (item (item # of ((tile index) + (1)) in [object idx v]) of [object type v])> = [143]>> then\n            if <([up v] of [controls v]) > [0]> then\n                broadcast (Mario - Pipe Up v)\n            end\n        end\n    end\nend\n\nwhen I receive [boss end v]\nstop [other scripts in sprite v]\nrepeat (100)\n    broadcast (position tiles v)\nend\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\nwhen I receive [powerup score v]\nadd [Score 1000] to [particles v]\nadd (x) to [particles v]\nadd (((y) + (height)) + (16)) to [particles v]\nchange [score v] by (1000)\n\nwhen I receive [time change v]\nforever\n    if <(EDITOR) = [0]> then\n        if <(MARIO TIME) = [100]> then\n            start sound [Hurry v]\n        end\n    end\nend\n\nwhen I receive [game v]\nshow\nbroadcast (generate level v) and wait\nbroadcast (clone level tiles v) and wait\nbroadcast (LEVEL - Start Game Loop - Respawn v)\n\nwhen flag clicked\nhide\n\nwhen I receive [end v]\nstop [other scripts in sprite v]\n\nbroadcast (Game v)\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) = [239]> then\n        if <(EDITOR) > [0]> then\n            change [tile v] by (([floor v] of ((timer) * (8)) ) mod (4))\n        end\n        if <(EDITOR) < [1]> then\n            set [tile v] to [9]\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 (tile index) of [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                    change [score v] by (100)\n                end\n            end\n        end\n    end\n    if <(tile) = [259]> then\n        change [tile v] by (([floor v] of ((timer) * (8)) ) mod (4))\n    end\n    if <(tile) = [235]> 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                if <(item # of (tile index) in [object idx v]) = [0]> then\n                    if <(MARIO) = [Mini]> then\n                        start sound [Mini Brick Hit v]\n                        set [bumped v] to [180]\n                    else\n                        start sound [BrickShatter v]\n                        start sound [Mini Brick Hit v]\n                        replace item (tile index) of [tile grid v] with [2]\n                        add [brick1] to [particles v]\n                        add (tile x) to [particles v]\n                        add ((tile y) + (32)) to [particles v]\n                        add [brick2] to [particles v]\n                        add (tile x) to [particles v]\n                        add ((tile y) + (32)) to [particles v]\n                        change [score v] by (100)\n                    end\n                else\n                    replace item (tile index) of [tile grid v] with [9]\n                    start sound [Mini Brick Hit v]\n                    set [bumped v] to [180]\n                end\n            end\n        end\n    end\n    if <<(tile) = [143]> or <(tile) = [146]>> then\n        change [tile v] by (([floor v] of ((timer) * (8)) ) mod (4))\n    end\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                set [bump index v] to (tile index)\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                    change [score v] by (100)\n                end\n            end\n        end\n    end\nend\nif <(item (tile index) of [tile grid v]) = [239]> then\n    if <(EDITOR) = [0]> then\n        set [tile v] to [2]\n        set [ghost v] effect to (100)\n    else\n        set [ghost v] effect to (0)\n    end\nelse\n    if <(EDITOR) = [0]> then\n        set [ghost v] effect to (0)\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\nwhen I receive [end v]\nstop [other scripts in sprite v]\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\nif <<(type) = [Boo]> or <(type) = [Leaf]>> 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\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        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        change [score v] by (100)\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) = [148]> then\n    set [frame v] to [-1]\n    Set Type [Life] costume [1up] width [16] height [16]\nend\nif <(tile type) = [149]> then\n    set [enemy health v] to [3]\n    Set Type [BoomBoom Start] costume [44] width [32] height [24]\nend\nif <(tile type) = [233]> then\n    set [frame v] to [-1]\n    Set Type [Life] costume [FireFlower] width [16] height [16]\nend\nif <(tile type) = [234]> then\n    Set Type [Drybones] costume [47] width [14] height [28]\nend\nif <(tile type) = [245]> then\n    Set Type [Lava Bubble] costume [53] width [14] height [14]\nend\nif <(tile type) = [247]> then\n    Set Type [Fire Disk] costume [59] width [64] height [16]\nend\nif <(tile type) = [257]> then\n    Set Type [Boo] costume [62] width [16] height [16]\nend\nif <(tile type) = [258]> then\n    Set Type [Nipper Plant] costume [63] width [14] height [14]\nend\nif <(tile type) = [263]> then\n    set [frame v] to [-1]\n    Set Type [Leaf] costume [leaf] width [16] height [16]\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 this 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 <(type) = [Thwomp]> then\n    set [thowmp y v] to (y)\nend\nif <<(EDITOR) > [0]> or <(frame) = []>> then\n    set [visible v] to [1]\nend\ncreate clone of (_myself_ v)\nset [visible v] to []\n\ndefine Tick - Life\nif <(frame) > [-1]> then\n    change [frame v] by (1)\nend\nif <(frame) < [16]> then\n    go to [back v] layer\n    hide\n    stop [this script v]\nend\nif <([player action v] of [mario v]) = [lose life]> then\n    go to [back v] layer\n    hide\n    stop [this script v]\nend\nif <(frame) < [48]> then\n    if <(frame) = [24]> then\n        show\n        go [forward v] (LAYERS - BACKGROUND) layers\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)?> and <(frame) > [32]>> then\n        start sound [Just What I Needed v]\n        broadcast (Powerup Score v)\n        if <<(root costume) = [FireFlower]> and <not <(MARIO) = [Mini]>>> then\n            set [mario v] to [Fire]\n        else\n            if <(root costume) = [1up]> then\n                start sound [1up v]\n                change [mario lives v] by (1)\n            else\n                broadcast (Collect 1up v)\n            end\n        end\n        delete this clone\n    end\n    if <<(root costume) = [Life]> or <(root costume) = [1up]>> then\n        go to [front v] layer\n        change [speed y v] by (-1)\n        move sprite y\n        if <(direction) > [0]> then\n            if <(speed x) < [3]> then\n                change [speed x v] by (1)\n            end\n        else\n            if <(speed x) > [-3]> then\n                change [speed x v] by (-1)\n            end\n        end\n        move sprite x\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 [10]\n    else\n        set [speed x v] to [-10]\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    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        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    start sound [KickShell v]\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        change [score v] by (100)\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\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 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 ([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]) < [20]> 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) = [Koopa2]> 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) = [Koopa2 Shell]> then\n    Tick - Shell\n    stop [this script v]\nend\nif <(type) = [BoomBoom Start]> then\n    Tick - Boom Boom Start\n    stop [this script v]\nend\nif <(type) = [BoomBoom Stomp]> then\n    Tick - Boom Boom Stomp\n    stop [this script v]\nend\nif <(type) = [BoomBoom Move]> then\n    Tick - Boom Boom Move\n    stop [this script v]\nend\nif <(type) = [? Ball]> then\n    Tick - ? Ball\n    stop [this script v]\nend\nif <(type) = [Fireball]> then\n    Tick - Fireball\n    stop [this script v]\nend\nif <(type) = [Drybones]> then\n    Tick - Dry Bones\n    stop [this script v]\nend\nif <(type) = [Dry Bones Fall]> then\n    Tick - Drybones Fall\n    stop [this script v]\nend\nif <(type) = [Lava Bubble]> then\n    Tick - Lava Bubble\n    stop [this script v]\nend\nif <(type) = [Fire Disk]> then\n    Tick - Fire Disk\n    stop [this script v]\nend\nif <(type) = [Boo]> then\n    Tick - Boo\n    stop [this script v]\nend\nif <(type) = [Nipper Plant]> then\n    Tick - Nipper Plant\n    stop [this script v]\nend\nif <(type) = [Leaf]> then\n    Tick - Leaf\n    stop [this script v]\nend\n\nwhen I receive [move player after enemy v]\nif <(type) = [Flip]> 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\nif <<<not <(type) = [EndBox]>> and <not <(type) = [Life]>>> and <not <(type) = [Boo]>>> then\n    start sound [KickShell v]\n    set [speed y v] to [14]\n    set [speed x v] to (([direction v] of [mario v]) / (45))\n    set [type v] to [flip]\n    set rotation style [all around v]\n    point in direction (-90)\nend\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\ndefine Tick - Boom Boom Move\nchange [speed y v] by (-1)\nchange [frame v] by (1)\nset [costume v] to ((35) + (([floor v] of ((frame) / (4)) ) mod (4)))\nif <([x position v] of [mario v]) < (x position)> then\n    set [speed x v] to [-3]\nelse\n    set [speed x v] to [3]\nend\nif <touching (mario v)?> then\n    if <([bop y v] of [mario v]) > []> then\n        set [frame v] to [1]\n        set [bounce player v] to [5]\n        start sound [Stomped v]\n        if <(enemy health) = [3]> then\n            add [Score 1000] to [particles v]\n            add (x) to [particles v]\n            add (((y) + (height)) + (16)) to [particles v]\n            change [score v] by (1000)\n        else\n            if <(enemy health) = [2]> then\n                add [Score 2000] to [particles v]\n                add (x) to [particles v]\n                add (((y) + (height)) + (16)) to [particles v]\n                change [score v] by (2000)\n            else\n                add [Score 4000] to [particles v]\n                add (x) to [particles v]\n                add (((y) + (height)) + (16)) to [particles v]\n                change [score v] by (4000)\n            end\n        end\n        set [type v] to [BoomBoom Stomp]\n    else\n        broadcast (mario - hurt v)\n    end\nend\nmove sprite x\nmove sprite y\n\ndefine Tick - Boom Boom Start\nchange [speed y v] by (-1)\nchange [frame v] by (1)\nif <touching (mario v)?> then\n    broadcast (mario - hurt v)\nend\nif <(frame) > [30]> then\n    set [costume v] to ((35) + (([floor v] of ((frame) / (4)) ) mod (4)))\n    set [speed y v] to [10]\n    set [type v] to [BoomBoom Move]\nelse\n    if <[6] > (frame)> then\n        set [costume v] to [43]\n    else\n        set [costume v] to [44]\n    end\nend\nmove sprite x\nmove sprite y\n\ndefine Tick - Boom Boom Stomp\nchange [speed y v] by (-1)\nchange [frame v] by (1)\nset [costume v] to ((39) + (([floor v] of ((frame) / (2)) ) mod (4)))\nset [speed x v] to [0]\nif <(frame) > [10]> then\n    change [enemy health v] by (-1)\n    if <(enemy health) = [0]> then\n        set [frame v] to [1]\n        set [type v] to [? ball]\n        star particle\n    else\n        set [frame v] to [1]\n        set [type v] to [BoomBoom Start]\n    end\nend\nmove sprite x\nmove sprite y\n\ndefine Tick - ? Ball\npoint in direction (90)\nset [height v] to [16]\nset [width v] to [16]\nchange [frame v] by (1)\nset [costume v] to [45]\nchange [speed y v] by (-1)\nset [speed x v] to [0]\nif <(frame) = [2]> then\n    set [speed y v] to [10]\nend\nmove sprite x\nmove sprite y\nif <touching (mario v)?> then\n    broadcast (Boss End v)\n    delete this clone\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) > [2]> then\n    turn right (90) degrees\n    set [frame v] to [0]\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 [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 Tick - Dry Bones\nchange [speed y v] by (-1)\nmove sprite y\nget tile at x: (x) y: ((y) - ((height) + (8)))\nif <(item (tile) of [tile shape v]) = []> then\n    if <(direction) > [0]> then\n        point in direction (-90)\n        change [x v] by (-5)\n    else\n        point in direction (90)\n        change [x v] by (5)\n    end\nend\nif <(direction) > [0]> then\n    if <(speed x) < [1]> then\n        change [speed x v] by (1)\n    end\nelse\n    if <[-1] < (speed x)> then\n        change [speed x v] by (-1)\n    end\nend\nmove sprite x\nchange [frame v] by (0.25)\nset [costume v] to ((47) + ([floor v] of ((frame) mod (2)) ))\npaint sprite\nif <touching (mario v)?> then\n    if <([bop y v] of [mario v]) > []> then\n        if <not <([player action v] of [mario v]) = [slide]>> then\n            start sound [Dry Bones v]\n            point in direction (90)\n            set [frame v] to [1]\n            set [bounce player v] to [5]\n            set [type v] to [Dry Bones Fall]\n            change [score v] by (100)\n            add [Score 100] to [particles v]\n            add (x) to [particles v]\n            add (y) to [particles v]\n        end\n    else\n        if <not <([player action v] of [mario v]) = [slide]>> then\n            broadcast (mario - hurt v)\n        end\n    end\nend\ncheck flip\n\ndefine Tick - Drybones Fall\nchange [frame v] by (0.25)\nif <[2] > (frame)> then\n    set [costume v] to [49]\nelse\n    if <(frame) > [49]> then\n        if <(frame) > [52]> then\n            set [costume v] to [52]\n        else\n            set [costume v] to [51]\n            set [frame v] to [1]\n            set [type v] to [Drybones]\n        end\n    else\n        set [costume v] to [50]\n    end\nend\n\ndefine Tick - Lava Bubble\ngo to [back v] layer\ngo [forward v] (LAYERS - BACKGROUND) layers\nchange [frame v] by (1)\nif <(frame) = [53]> then\n    set [speed y v] to [0]\nend\nif <touching (mario v)?> then\n    broadcast (mario - hurt v)\nend\nif <(frame) < [52]> then\n    set [costume v] to ((56) + (([floor v] of ((frame) / (4)) ) mod (3)))\n    if <(speed y) > [-7]> then\n        change [speed y v] by (-0.2)\n    end\n    move sprite y\n    stop [this script v]\nelse\n    if <(frame) < [100]> then\n        set [costume v] to ((53) + (([floor v] of ((frame) / (4)) ) mod (3)))\n        if <[7] > (speed y)> then\n            change [speed y v] by (0.2)\n        end\n        move sprite y\n        stop [this script v]\n    end\nend\nset [speed y v] to [0]\nset [frame v] to [1]\n\ndefine Tick - Fire Disk\nset rotation style [all around v]\nturn right (5) degrees\nif <touching (mario v)?> then\n    broadcast (mario - hurt v)\nend\n\nwhen I receive [mario - level complete v]\nif <[all enemies v] contains (type)?> then\n    add [Score 100] to [particles v]\n    add (x) to [particles v]\n    add (y) to [particles v]\n    change [score v] by (100)\n    delete this clone\nend\nif <<(type) = [flip]> or <(type) = [squish]>> then\n    delete this clone\nend\n\ndefine Tick - Boo\nif <(x) > ([x v] of [mario v])> then\n    point in direction (90)\nelse\n    point in direction (-90)\nend\nif <([direction v] of [mario v]) = (direction)> then\n    set [costume v] to [61]\nelse\n    set [costume v] to [62]\n    if <(x) > ([x v] of [mario v])> then\n        change [x v] by (-1.5)\n    else\n        change [x v] by (1.5)\n    end\n    move sprite x\n    if <(y) > ([y v] of [mario v])> then\n        change [y v] by (-1.5)\n    else\n        change [y v] by (1.5)\n    end\n    move sprite y\nend\nif <touching (mario v)?> then\n    broadcast (mario - hurt v)\nend\n\ndefine Tick - Nipper Plant\nchange [speed y v] by (-1.5)\nmove sprite y\nchange [frame v] by (0.2)\nif <not <(falling) > [0]>> then\n    set [costume v] to ((63) + ([floor v] of ((frame) mod (2)) ))\n    if <(x) > ([x v] of [mario v])> then\n        point in direction (-90)\n    else\n        point in direction (90)\n    end\nelse\n    set [costume v] to ((65) + ([floor v] of ((frame) mod (2)) ))\nend\npaint sprite\nif <touching (mario v)?> then\n    broadcast (mario - hurt v)\nend\nif <<<<(falling) < [2]> and <(distance to [mario v]) < [150]>> and <([falling v] of [mario v]) > [5]>> and <([y v] of [mario v]) > (y)>> then\n    set [speed y v] to [14]\nend\nCheck Flip\n\ndefine Tick - Leaf\n\nwhen I receive [end v]\nstop [other scripts in sprite v]\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\n    set [grid width v] to [100]\n    set [grid height v] to [40]\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\nif <(STOP!!!!!) < [1]> then\n    set [fireballs v] to [0]\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        hide variable [auto arranging v]\n        broadcast (LEVEL - Done Loading... v) and wait\n        broadcast (LEVEL - Start Game Loop v)\n    else\n        broadcast (LEVEL - STOP!!! v) and wait\n        set [editor v] to [1]\n        show variable [level # v]\n        show variable [auto arranging 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 [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 Arranging) < [On]> 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 Arranging) > [Off]> 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 Arranging) > [Off]> 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\nif <(EDITOR) < [1]> then\n    stop [this script v]\nend\nif <(Auto Arranging) = [On]> then\n    set [auto arranging v] to [Off]\nelse\n    if <(Auto Arranging) = [Off]> then\n        set [auto arranging v] to [On]\n    end\nend\n\nwhen [5 v] key pressed\nnext brush [5]\n\nwhen [m v] key pressed\nif <(EDITOR) < [1]> then\n    stop [this script v]\nend\nif <(MARIO) = [Mini]> then\n    set [mario v] to [Mario]\nelse\n    if <(MARIO) = [Mario]> then\n        set [mario v] to [Fire]\n    else\n        if <(MARIO) = [Fire]> then\n            set [mario v] to [Tanooki]\n        else\n            if <(MARIO) = [Tanooki]> then\n                set [mario v] to [Mini]\n            end\n        end\n    end\nend\n\nwhen [6 v] key pressed\nnext brush [6]\n\nwhen [7 v] key pressed\nnext brush [7]\n\nwhen [t v] key pressed\nif <(EDITOR) < [1]> then\n    stop [this script v]\nend\nask (join [Set Lives \(Current ] (join (MARIO LIVES) [\)])) and wait\nif <(round (answer)) < [1]> then\n    stop [this script v]\nend\nset [mario lives v] to (round (answer))\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]\n    change [score v] by (100)\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\nif <(type) = [brick1]> then\n    Tick - Brick1\n    stop [this script v]\nend\nif <(type) = [brick2]> then\n    Tick - Brick2\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\ndefine Tick - Brick1\nif <[1] < (speed x)> then\n    change [speed x v] by (-0.75)\nend\nchange [speed y v] by (-1.5)\nchange [x v] by (speed x)\nchange [y v] by (speed y)\nif <(speed y) < [-24]> then\n    delete this clone\nend\nPosition with Costume [brick]\nturn right (15) degrees\n\ndefine Tick - Brick2\nif <(speed x) < [1]> then\n    change [speed x v] by (0.75)\nend\nchange [speed y v] by (-1.5)\nchange [x v] by (speed x)\nchange [y v] by (speed y)\nif <(speed y) < [-24]> then\n    delete this clone\nend\nPosition with Costume [brick]\nturn right (15) degrees\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 (j v) pressed?>>\nset [x axis v] to ((right) - (left))\nset [y axis v] to ((up) - (down))\nif <<key (b v) pressed?> or <key (l v) pressed?>> then\n    change [button b v] by (1)\nelse\n    set [button b v] to []\nend\nif <<key (x v) pressed?> or <key (k v) pressed?>> then\n    change [button x v] by (1)\nelse\n    set [button x v] to []\nend\n\n@Title Screen\n\nwhen flag clicked\nbroadcast (Game - Title v)\n\nwhen I receive [game - title v]\nset [player v] to [Mario]\nset size to (100) %\nset [id v] to [0]\nshow\nswitch costume to (logo v)\ngo to x: (0) y: (252)\nrepeat (100)\n    change y by (((round (68)) - (y position)) / (30))\nend\nrepeat (2)\n    change [id v] by (1)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nif <(ID) = [1]> then\n    switch costume to (playe button v)\n    go to x: (0) y: (-106)\n    forever\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (20)\n            if <mouse down?> then\n                broadcast (Game v)\n            end\n        else\n            set [brightness v] effect to (0)\n        end\n    end\nend\n\nwhen I receive [game v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\nwhen I start as a clone\nif <(ID) = [2]> then\n    go to x: (-224) y: (171)\n    set size to (200) %\n    switch costume to (mario v)\n    forever\n        if <<touching (mouse-pointer v)?> and <mouse down?>> then\n            if <(costume [number v]) = [3]> then\n                switch costume to (luigi v)\n                set [player v] to [Luigi]\n                play sound [Luigi v] until done\n            end\n            wait until <<touching (mouse-pointer v)?> and <mouse down?>>\n            if <(costume [number v]) = [4]> then\n                switch costume to (mario v)\n                set [player v] to [Mario]\n                play sound [Mario v] until done\n            end\n        end\n    end\nend\n\n@Level Store\n\nwhen [i v] key pressed\nask [Paste your level code here to import] and wait\nif <(EDITOR) < [1]> then\n    stop [this script v]\nend\nif <[0] < (length of (answer))> then\n    replace item (LEVEL #) of [level store v] with (answer)\nend\nbroadcast (LEVEL - Load v) and wait\n\nwhen [u v] key pressed\nif <(EDITOR) < [1]> then\n    stop [this script v]\nend\nbroadcast (LEVEL - Save v) and wait\nhide list [export level code v]\ndelete all of [export level code v]\nadd [To copy code double click the level code and copy it ] to [export level code v]\nadd (item (LEVEL #) of [level store v]) to [export level code v]\nadd [Press Y to hide] to [export level code v]\nwait until <key (y v) pressed?>\nshow list [export level code v]\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\nLoad - Auto Scroll\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\ndefine Save - Autoscroll\nwrite value (AUTOSCROLL) delimiter [_]\n\ndefine Load - Auto Scroll\nread value\nset [autoscroll v] to (value)\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 all sounds\nstop [other scripts in sprite v]\nif <(EDITOR) < [1]> then\n    forever\n        if <(LEVEL #) = [1]> then\n            play sound [Music L1 v] until done\n        end\n        if <(LEVEL #) = [2]> then\n            play sound [SMA4 World 1-2 v] until done\n        end\n        if <(LEVEL #) = [3]> then\n            play sound [Music L1 v] until done\n        end\n        if <(LEVEL #) = [4]> then\n            play sound [SMA4 World 1-2 v] until done\n        end\n        if <(LEVEL #) = [5]> then\n            play sound [Fortress v] until done\n        end\n        if <(LEVEL #) = [6]> then\n            play sound [Fortress v] until done\n        end\n        if <(LEVEL #) = [7]> then\n            play sound [Boss Music v] until done\n        end\n        if <(LEVEL #) = [8]> then\n            play sound [Underground v] until done\n        end\n        if <(LEVEL #) = [11]> then\n            play sound [Bonus v] until done\n        end\n        if <(LEVEL #) = [12]> then\n            play sound [Bonus v] until done\n        end\n        if <(LEVEL #) = [13]> then\n            play sound [Music L1 v] until done\n        end\n    end\nend\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]\nplay sound [GoalCard1 v] until done\n\nwhen I receive [pipe level transition v]\nstart sound [Power Down v]\n\nwhen I receive [mario - lose life v]\nstop [other scripts in sprite v]\n\nwhen I receive [boss end v]\nstop [other scripts in sprite v]\nplay sound [34 Fortress Clear v] until done\nchange [level # v] by (1)\nbroadcast (LEVEL - Load v)\nbroadcast (LEVEL - Start Game Loop v)\n\nwhen I receive [end v]\nstop [other scripts in sprite v]\n\nwhen flag clicked\nset [level # v] to [0]\nrepeat until <(LEVEL #) = [1]>\n    play sound [Super Mario Bros v] until done\nend\n\n@Background\n\nwhen flag clicked\nset [layers - background v] to [2]\nshow\nforever\n    go to [back v] layer\nend\n\nwhen I receive [position tiles v]\ngo to [back v] layer\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 [level - start game loop - respawn v]\nshow\nwait (0) seconds\nbackground set\n\nwhen I start as a clone\nforever\n    go to [back v] layer\nend\n\ndefine background set\nswitch costume to (size 100% v)\nset size to (200) %\nif <(LEVEL #) = [1]> then\n    switch costume to (overworld1 v)\nend\nif <(LEVEL #) = [2]> then\n    switch costume to (athletic1 v)\nend\nif <(LEVEL #) = [3]> then\n    switch costume to (overworld1 v)\nend\nif <(LEVEL #) = [4]> then\n    switch costume to (sky1 v)\nend\nif <(LEVEL #) = [5]> then\n    switch costume to (fortress1 v)\nend\nif <(LEVEL #) = [6]> then\n    switch costume to (fortress1 v)\nend\nif <(LEVEL #) = [7]> then\n    switch costume to (fortress1 v)\nend\nif <(LEVEL #) = [8]> then\n    switch costume to (underground1 v)\nend\nif <(LEVEL #) = [11]> then\n    switch costume to (bonus1 v)\nend\nif <(LEVEL #) = [12]> then\n    switch costume to (bonus1 v)\nend\nif <(LEVEL #) = [13]> then\n    switch costume to (overworld1 v)\nend\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 [level - start game loop - respawn v]\ndelete this clone\n\nwhen [b v] key pressed\nif <(EDITOR) < [1]> then\n    stop [this script v]\nend\nask [What Background do you want?] and wait\nswitch costume to (size 100% v)\nset size to (200) %\nif <(answer) = [Overworld]> then\n    switch costume to (overworld1 v)\nend\nif <(answer) = [Athletic]> then\n    switch costume to (athletic1 v)\nend\nif <(answer) = [Sky]> then\n    switch costume to (sky1 v)\nend\nif <(answer) = [Fortress]> then\n    switch costume to (fortress1 v)\nend\nif <(answer) = [Underground]> then\n    switch costume to (underground1 v)\nend\nif <(answer) = [Vines]> then\n    switch costume to (vines1 v)\nend\nif <(answer) = [Dessert]> then\n    switch costume to (dessert1 v)\nend\nif <(answer) = [Underwater]> then\n    switch costume to (underwater1 v)\nend\nif <(answer) = [Thunderstorm]> then\n    switch costume to (thunderstorm1 v)\nend\nif <(answer) = [Cabin]> then\n    switch costume to (cabin1 v)\nend\nif <(answer) = [Bonus]> then\n    switch costume to (bonus1 v)\nend\nset [background v] to (costume [number 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 flag clicked\nhide\n\n@Thumbnail\n\nwhen flag clicked\nswitch costume to (ep 19 part 2 v)\ngo to x: (0) y: (0)\nhide variable [coins v]\nhide variable [level # v]\nhide variable [auto arranging v]\nhide\nforever\n    set [timer v] to ((timer) + (0.1))\nend\n\nwhen [timer v] > (timer)\nswitch costume to (ep 19 part 2 v)\nset [ghost v] effect to (100)\nshow\nhide variable [coins v]\nhide variable [level # v]\nrepeat (20)\n    change [ghost v] effect by (-20)\nend\n\nwhen flag clicked\nforever\n    go to [front v] layer\nend\n\n@Mario Score\n\nwhen I start as a clone\nforever\n    life\nend\n\nwhen I start as a clone\nforever\n    if <(type) = [score]> then\n        go to x: (-85) y: (160)\n        switch costume to (type)\n    end\nend\n\nwhen I start as a clone\nforever\n    coin\nend\n\nwhen I start as a clone\nforever\n    time\nend\n\nwhen I start as a clone\nforever\n    score\nend\n\ndefine score\nif <[2] > (length of (SCORE))> then\n    set [score v] to (join [0] (SCORE))\nend\nif <[3] > (length of (SCORE))> then\n    set [score v] to (join [0] (SCORE))\nend\nif <[4] > (length of (SCORE))> then\n    set [score v] to (join [0] (SCORE))\nend\nif <[5] > (length of (SCORE))> then\n    set [score v] to (join [0] (SCORE))\nend\nif <[6] > (length of (SCORE))> then\n    set [score v] to (join [0] (SCORE))\nend\nif <[7] > (length of (SCORE))> then\n    set [score v] to (join [0] (SCORE))\nend\nif <(type) = [game score]> then\n    switch costume to ((12) + (letter (num) of (SCORE)))\n    go to x: (120) y: (160)\n    change x by (((num) - (1)) * (16))\nend\n\ndefine life\nif <[2] > (length of (MARIO LIVES))> then\n    set [mario lives v] to (join [0] (MARIO LIVES))\nend\nif <(type) = [life]> then\n    switch costume to ((12) + (letter (num) of (MARIO LIVES)))\n    go to x: (-72) y: (160)\n    change x by (((num) - (1)) * (16))\nend\n\ndefine time\nif <[2] > (length of (MARIO TIME))> then\n    set [mario time v] to (join [0] (MARIO TIME))\nend\nif <[3] > (length of (MARIO TIME))> then\n    set [mario time v] to (join [0] (MARIO TIME))\nend\nif <(type) = [time]> then\n    switch costume to ((2) + (letter (num) of (MARIO TIME)))\n    go to x: (0) y: (160)\n    change x by (((num) - (1)) * (16))\nend\n\ndefine coin\nif <[2] > (length of (COINS))> then\n    set [coins v] to (join [0] (COINS))\nend\nif <(type) = [coin]> then\n    switch costume to ((12) + (letter (num) of (COINS)))\n    go to x: (72) y: (160)\n    change x by (((num) - (1)) * (16))\nend\nif <(COINS) > [99]> then\n    start sound [1up v]\n    change [mario lives v] by (1)\n    change [coins v] by (-100)\nend\n\ndefine write\nset [num v] to [0]\nrepeat (1)\n    change [num v] by (1)\n    set [type v] to [score]\n    create clone of (_myself_ v)\nend\nset [num v] to [0]\nrepeat (2)\n    change [num v] by (1)\n    set [type v] to [life]\n    create clone of (_myself_ v)\nend\nset [num v] to [0]\nrepeat (2)\n    change [num v] by (1)\n    set [type v] to [coin]\n    create clone of (_myself_ v)\nend\nset [num v] to [0]\nrepeat (3)\n    change [num v] by (1)\n    set [type v] to [time]\n    create clone of (_myself_ v)\nend\nset [num v] to [0]\nrepeat (7)\n    change [num v] by (1)\n    set [type v] to [game score]\n    create clone of (_myself_ v)\nend\n\nwhen flag clicked\nset [mario lives v] to [5]\n\nwhen flag clicked\nset [mario time v] to [300]\n\nwhen flag clicked\nset [score v] to [0]\nhide\n\nwhen I receive [game v]\nforever\n    if <(PLAYER) = [Mario]> then\n        show\n    else\n        if <(PLAYER) = [Luigi]> then\n            hide\n        end\n    end\nend\n\nwhen I receive [game v]\nwrite\n\n@Luigi Score\n\nwhen I start as a clone\nforever\n    life\nend\n\nwhen I start as a clone\nforever\n    if <(type) = [score]> then\n        go to x: (-85) y: (160)\n        switch costume to (type)\n    end\nend\n\nwhen I start as a clone\nforever\n    coin\nend\n\nwhen I start as a clone\nforever\n    time\nend\n\nwhen I start as a clone\nforever\n    score\nend\n\ndefine score\nif <[2] > (length of (SCORE))> then\n    set [score v] to (join [0] (SCORE))\nend\nif <[3] > (length of (SCORE))> then\n    set [score v] to (join [0] (SCORE))\nend\nif <[4] > (length of (SCORE))> then\n    set [score v] to (join [0] (SCORE))\nend\nif <[5] > (length of (SCORE))> then\n    set [score v] to (join [0] (SCORE))\nend\nif <[6] > (length of (SCORE))> then\n    set [score v] to (join [0] (SCORE))\nend\nif <[7] > (length of (SCORE))> then\n    set [score v] to (join [0] (SCORE))\nend\nif <(type) = [game score]> then\n    switch costume to ((12) + (letter (num) of (SCORE)))\n    go to x: (120) y: (160)\n    change x by (((num) - (1)) * (16))\nend\n\ndefine life\nif <[2] > (length of (MARIO LIVES))> then\n    set [mario lives v] to (join [0] (MARIO LIVES))\nend\nif <(type) = [life]> then\n    switch costume to ((12) + (letter (num) of (MARIO LIVES)))\n    go to x: (-72) y: (160)\n    change x by (((num) - (1)) * (16))\nend\n\ndefine time\nif <[2] > (length of (MARIO TIME))> then\n    set [mario time v] to (join [0] (MARIO TIME))\nend\nif <[3] > (length of (MARIO TIME))> then\n    set [mario time v] to (join [0] (MARIO TIME))\nend\nif <(type) = [time]> then\n    switch costume to ((2) + (letter (num) of (MARIO TIME)))\n    go to x: (0) y: (160)\n    change x by (((num) - (1)) * (16))\nend\n\ndefine coin\nif <[2] > (length of (COINS))> then\n    set [coins v] to (join [0] (COINS))\nend\nif <(type) = [coin]> then\n    switch costume to ((12) + (letter (num) of (COINS)))\n    go to x: (72) y: (160)\n    change x by (((num) - (1)) * (16))\nend\nif <(COINS) > [99]> then\n    start sound [1up v]\n    change [mario lives v] by (1)\n    change [coins v] by (-100)\nend\n\ndefine write\nset [num v] to [0]\nrepeat (1)\n    change [num v] by (1)\n    set [type v] to [score]\n    create clone of (_myself_ v)\nend\nset [num v] to [0]\nrepeat (2)\n    change [num v] by (1)\n    set [type v] to [life]\n    create clone of (_myself_ v)\nend\nset [num v] to [0]\nrepeat (2)\n    change [num v] by (1)\n    set [type v] to [coin]\n    create clone of (_myself_ v)\nend\nset [num v] to [0]\nrepeat (3)\n    change [num v] by (1)\n    set [type v] to [time]\n    create clone of (_myself_ v)\nend\nset [num v] to [0]\nrepeat (7)\n    change [num v] by (1)\n    set [type v] to [game score]\n    create clone of (_myself_ v)\nend\n\nwhen flag clicked\nset [mario lives v] to [5]\n\nwhen flag clicked\nset [mario time v] to [300]\n\nwhen flag clicked\nset [score v] to [0]\nhide\n\nwhen I receive [game v]\nforever\n    if <(PLAYER) = [Mario]> then\n        hide\n    else\n        if <(PLAYER) = [Luigi]> then\n            show\n        end\n    end\nend\n\nwhen I receive [game v]\nwrite\n\n@GAME OVER SCREEN\n\nwhen flag clicked\nset [stop!!!!! v] to [0]\nforever\n    set y to (-10)\n    go to [front v] layer\n    hide\nend\n\nwhen I receive [game over v]\nstop all sounds\nforever\n    show\n    go to [front v] layer\n    stop [all v]\nend\n\nwhen I receive [game over v]\nbroadcast (mario - stop music v)\nplay sound [GameOver v] until done\nstop [all v]\n\nwhen I receive [game over v]\nset [stop!!!!! v] to [1]\nif <(PLAYER) = [Mario]> then\n    switch costume to (mario game over v)\nelse\n    if <(PLAYER) = [Luigi]> then\n        switch costume to (luigi game over v)\n    end\nend\n\n@speedbar\n\nwhen flag clicked\nhide\nset [mario speed v] to [0]\nset [flash v] to [0]\nset [wait v] to [0]\ngo to x: (-90) y: (-170)\n\nwhen I receive [level - done loading... v]\nshow\nset [mario speed v] to [0]\nset [flash v] to [0]\nset [wait v] to [0]\nbroadcast (SPEEDBAR v)\n\nwhen I receive [speedbar v]\nforever\n    change [flash v] by (-1)\n    change [wait v] by (-1)\n    if <(MARIO SPEED) > [6]> then\n        if <<(MARIO SPEED) = [7]> and <[0] > (flash)>> then\n            set [flash v] to [10]\n        end\n        if <(flash) = [10]> then\n            switch costume to (8 v)\n        end\n        if <(flash) = [5]> then\n            switch costume to (9 v)\n        end\n    else\n        switch costume to ((MARIO SPEED) + (1))\n    end\n    if <<[0] > (wait)> and <([button x v] of [controls v]) > [0]>> then\n        if <<[0] < ([button x v] of [controls v])> or <[0] < ([right v] of [controls v])>> then\n            if <([falling v] of [mario v]) < [1]> then\n                if <not <[7] = (MARIO SPEED)>> then\n                    change [mario speed v] by (1)\n                    set [wait v] to [9]\n                    broadcast (MARIO SPEED CHANGE UP v)\n                end\n            end\n        end\n    end\n    if <<[0] > (wait)> and <<not <[0] < ([left v] of [controls v])>> and <not <[0] < ([right v] of [controls v])>>>> then\n        if <not <[0] = (MARIO SPEED)>> then\n            change [mario speed v] by (-1)\n            set [wait v] to [16]\n            broadcast (MARIO SPEED CHANGE DOWN v)\n        end\n    else\n        if <<[0] > (wait)> and <([button x v] of [controls v]) < [1]>> then\n            if <not <[0] = (MARIO SPEED)>> then\n                change [mario speed v] by (-1)\n                set [wait v] to [16]\n                broadcast (MARIO SPEED CHANGE DOWN v)\n            end\n        else\n            if <<[0] > (wait)> and <[2] < ([falling v] of [mario v])>> then\n                if <not <[0] = (MARIO SPEED)>> then\n                    change [mario speed v] by (-1)\n                    set [wait v] to [16]\n                    broadcast (MARIO SPEED CHANGE DOWN v)\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [mario - stop music v]\nset [mario speed v] to [0]\nset [flash v] to [0]\nset [wait v] to [0]\nhide\n\nwhen I receive [mario - level complete v]\nhide\nset [mario speed v] to [0]\nset [flash v] to [0]\nset [wait v] to [0]\n\nwhen I receive [game v]\nforever\n    if <(EDITOR) = [1]> then\n        hide\n    else\n        show\n    end\nend\n\n@The End\n\nwhen flag clicked\nhide\n\nwhen I receive [end v]\nshow\nset [ghost v] effect to (100)\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\n\n
Use right/left arrow keys for run. Press l for throw fire. Press up arrow for jump. Click to mario icon in title screen for change player to luigi or if then player luigi to mario.\n\nIf you have an opinion that this is stolen, do not write stolen, write that it seems to you that this is a copy, I will answer you.\n\n@CreatorWindowsLove 2021 - 2022