Mario Multiverse - A Platformer Creator
@Stage\n\nwhen I receive [load backdrop v]\nswitch backdrop to (BACKDROP)\n\nwhen I receive [shake camera v]\nrepeat (3)\n    set [shake v] to [-20]\n    wait (0.05) seconds\nend\n\nwhen I receive [position tiles v]\nif <(SHAKE) < [0]> then\n    change [shake v] by (5)\nelse\n    if <(SHAKE) > [0]> then\n        change [shake v] by (-1)\n    end\nend\n\nwhen I receive [level - load v]\nset [shake v] to [0]\n\n@Mario\n\ndefine move camera\nif <(AUTOSCROLL) = [1]> then\n    set [camera x v] to (x)\nelse\n    if <(EDITOR) < [1]> then\n        if <(AUTOSCROLL) = [2]> then\n            change [camera x v] by (1)\n        else\n            if <(AUTOSCROLL) = [3]> then\n                change [camera x v] by (2)\n            else\n                if <(AUTOSCROLL) = [4]> then\n                    change [camera x v] by (3)\n                else\n                    if <(AUTOSCROLL) = [5]> then\n                        change [camera x v] by (5)\n                    else\n                        if <(AUTOSCROLL) = [6]> then\n                            change [camera x v] by (7)\n                        else\n                            if <(AUTOSCROLL) = [7]> then\n                                change [camera x v] by (-1)\n                            else\n                                if <(AUTOSCROLL) = [8]> then\n                                    change [camera x v] by (-2)\n                                else\n                                    if <(AUTOSCROLL) = [9]> then\n                                        change [camera x v] by (-3)\n                                    else\n                                        if <(AUTOSCROLL) = [10]> then\n                                            change [camera x v] by (-5)\n                                        else\n                                            if <(AUTOSCROLL) = [11]> then\n                                                change [camera x v] by (-7)\n                                            else\n                                                change [camera x v] by (((x) - (CAMERA X)) / (80))\n                                            end\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n        if <<((CAMERA X) - (300)) > (x)> or <((CAMERA X) + (300)) < (x)>> then\n            if <touching (_edge_ v)?> then\n                set [mario v] to [Mini]\n                broadcast (mario - lose life v)\n            end\n        end\n    else\n        change [camera x v] by (((x) - (CAMERA X)) / (80))\n    end\nend\nif <(EDITOR) < [1]> then\n    if <(AUTOSCROLL) = [12]> then\n        change [camera y v] by (1)\n    else\n        if <(AUTOSCROLL) = [13]> then\n            change [camera y v] by (3)\n        else\n            if <(AUTOSCROLL) = [14]> then\n                change [camera y v] by (5)\n            else\n                if <(AUTOSCROLL) = [15]> then\n                    change [camera y v] by (-1)\n                else\n                    if <(AUTOSCROLL) = [16]> then\n                        change [camera y v] by (-3)\n                    else\n                        if <(AUTOSCROLL) = [17]> then\n                            change [camera y v] by (-5)\n                        else\n                            change [camera y v] by (((y) - (CAMERA Y)) / (4))\n                        end\n                    end\n                end\n            end\n        end\n    end\n    if <<((CAMERA Y) - (200)) > (y)> or <((CAMERA Y) + (200)) < (y)>> then\n        if <touching (_edge_ v)?> then\n            set [mario v] to [Mini]\n            hide\n            broadcast (mario - lose life v)\n        end\n    end\nelse\n    change [camera y v] by (((y) - (CAMERA Y)) / (4))\nend\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\nshow\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 [fireballs v] to [0]\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]\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 []\nset [stomp index \(mario\) v] to []\nset [stomp index \(enemy\) v] to []\nif <(EDITOR) > [0]> then\n    set [invulnerable v] to [0]\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    tick power-up abilities\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) = []> or <(tile shape) = [OE]>> 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 <(tile shape) = [IB]> then\n    if <(fix dy) < [0]> then\n        set [solid v] to []\n    end\n    if <(fix dx) < [0]> then\n        set [solid v] to []\n    end\n    if <(fix dx) > [0]> then\n        set [solid v] to []\n    end\n    stop [this script v]\nend\nif <(fix dy) < [0]> then\n    change [y v] by ((32) - (mod y))\n    add (tile index) to [stomp indexes v]\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    if <not <([player action v] of [mario v]) = [lose life]>> then\n        set [player action v] to [walk]\n    end\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 <key (space v) pressed?> then\n                if <(speed x) > [0.6]> then\n                    change [speed x v] by (-0.4)\n                else\n                    if <(speed x) < [-0.6]> 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            else\n                if <(speed x) > [0.1]> then\n                    change [speed x v] by (-0.1)\n                else\n                    if <(speed x) < [-0.1]> then\n                        change [speed x v] by (0.1)\n                    else\n                        set [speed x v] to [0]\n                        set [player frame v] to [0]\n                    end\n                end\n            end\n        end\n    else\n        point in direction ((90) * (KEY WALK))\n        if <key (space v) pressed?> then\n            if <(RUN SPEED) = [9]> then\n                if <((KEY WALK) * (speed x)) < [13]> then\n                    if <((KEY WALK) * (speed x)) < [0]> then\n                        change [speed x v] by ((KEY WALK) * (0.4))\n                        if <(falling) < [2]> then\n                            if <not <([player action v] of [mario v]) = [lose life]>> then\n                                set [player action v] to [turn]\n                            end\n                            make skid smoke\n                        end\n                    else\n                        change [speed x v] by ((KEY WALK) * (0.4))\n                    end\n                end\n            else\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                            if <not <([player action v] of [mario v]) = [lose life]>> then\n                                set [player action v] to [turn]\n                            end\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        else\n            if <((KEY WALK) * (speed x)) < [5]> 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                        if <not <([player action v] of [mario v]) = [lose life]>> then\n                            set [player action v] to [turn]\n                        end\n                        make skid smoke\n                    end\n                else\n                    change [speed x v] by ((KEY WALK) * (0.2))\n                end\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 [player action v] to [jump]\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)\ncheck around player at x: ((x) - ((width) / (2))) y: (((y) - (height)) - (8))\ncheck around player at x: ((x) + ((width) / (2))) y: (((y) - (height)) - (8))\ncheck around player at x: (x) y: (((y) - (height)) - (8))\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\ngo to [front v] layer\nswitch costume to (big v)\ngo to x: ((x) - (CAMERA X)) y: (((y) - (CAMERA Y)) + (SHAKE))\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 (minideath v)\n    stop [this script v]\nend\nif <(player action) = [editor]> then\n    switch costume to (join (MARIO) [Walk1])\nend\nif <(EDITOR) < [1]> then\n    if <(falling) > [1]> then\n        if <<(player action) = [jump]> and <(speed y) > [0]>> then\n            switch costume to (join (MARIO) [Jump])\n            if <(RUN SPEED) = [9]> then\n                switch costume to (join (MARIO) [RunJump])\n                if <(MARIO) = [Hammer]> then\n                    switch costume to (join (MARIO) [Jump])\n                end\n            end\n        else\n            switch costume to (join (MARIO) [Walk3])\n            if <(RUN SPEED) = [9]> then\n                switch costume to (join (MARIO) [RunJump])\n                if <(MARIO) = [Hammer]> then\n                    switch costume to (join (MARIO) [Jump])\n                end\n            end\n        end\n        stop [this script v]\n    end\n    if <(player action) = [turn]> then\n        switch costume to (join (MARIO) [Turn])\n        stop [this script v]\n    end\n    switch costume to (join (MARIO) [Walk1])\n    if <(RUN SPEED) = [9]> then\n        switch costume to (join (MARIO) [Run1])\n    end\n    switch costume to ((costume [number v]) + (([floor v] of (player frame) ) mod (4)))\nend\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\nset [player action v] to [editor]\nswitch costume to (join (MARIO) [Walk1])\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    if <(level clear progress) = [0]> then\n        broadcast (mario - fall off cliff v)\n    else\n        hide\n    end\nend\ncheck around player at x: (x) y: ((y) - (8))\nif <<not <(player action) = [crouch]>> or <not <(MARIO) = [Mini]>>> then\n    check around player at x: (x) y: ((y) + (8))\nend\n\ndefine limit camera edge x: (edge x) edge y: (edge y)\nif <(CAMERA X) < (edge x)> then\n    set [camera x v] to (edge x)\nend\nif <(CAMERA Y) < (edge y)> then\n    set [camera y v] to (edge y)\nend\nif <(CAMERA X) > (((32) * (GRID WIDTH)) - (edge x))> then\n    set [camera x v] to (((32) * (GRID WIDTH)) - (edge x))\nend\nif <(CAMERA Y) > (((32) * (GRID HEIGHT)) - (edge y))> then\n    set [camera y v] to (((32) * (GRID HEIGHT)) - (edge y))\nend\n\nwhen I receive [level - stop!!! v]\nstop [other scripts in sprite v]\n\nwhen I receive [level - start game loop v]\nset [coins v] to [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    start sound [Coin v]\n    replace item (tile index) of [tile grid v] with [2]\n    change [coins v] by (1)\n    change [score v] by (200)\nend\nif <<<(tile) = [133]> or <(tile) = [137]>> or <(tile) = [140]>> then\n    if <not <(player action) = [lose life]>> then\n        set [mario v] to [Mini]\n        broadcast (mario - lose life v)\n    end\nend\nget tile at x: ((x) - (width)) y: ((y) - ((height) / (2)))\nif <(tile shape) = [^]> then\n    set [stomp index \(mario\) v] to (tile index)\n    set [bounce player v] to [5]\nend\nget tile at x: ((x) + (width)) y: ((y) - ((height) / (2)))\nif <(tile shape) = [^]> then\n    set [stomp index \(mario\) v] to (tile index)\n    set [bounce player v] to [5]\nend\n\nwhen I receive [level - start game loop - respawn v]\nset [player action v] to [walk]\nset [coins v] to [0]\nreset player\ngame loop\n\nwhen I receive [level - done loading... v]\nbroadcast (load backdrop 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)\n    set [jumping v] to [0]\n    stop [this script v]\nend\nif <(tile) = [85]> then\n    set [bump index v] to (tile index)\n    set [jumping v] to [0]\n    stop [this script v]\nend\nif <(tile) = [105]> then\n    set [bump index v] to (tile index)\n    set [jumping v] to [0]\n    stop [this script v]\nend\nif <(tile) = [149]> then\n    set [bump index v] to (tile index)\n    set [jumping v] to [0]\n    stop [this script v]\nend\nif <(tile) = [154]> then\n    set [bump index v] to (tile index)\n    set [jumping v] to [0]\n    stop [this script v]\nend\n\nwhen I receive [mario - lose life v]\nstart sound [Lose Life v]\nset [freeze particles v] to [1]\nset [player action v] to [lose life]\nstop [other scripts in sprite v]\nrepeat (25)\n    set [player action v] to [lose life]\n    paint sprite\n    broadcast (position tiles v)\nend\nset [speed y v] to [17]\nrepeat until <((y) - (CAMERA Y)) < [-400]>\n    set [player action v] to [lose life]\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    set [player action v] to [lose life]\n    paint sprite\n    broadcast (position tiles v)\nend\nbroadcast (LEVEL - Load v) and wait\nbroadcast (LEVEL - Start Game Loop - Respawn v)\n\nwhen flag clicked\nset volume to (100) %\n\nwhen I receive [mario - level complete v]\nset [level clear progress v] to [1]\nstart sound [GoalCard1 v]\nstop [other scripts in sprite v]\nset [speed x v] to [0]\nrepeat until <(falling) < [1]>\n    paint sprite\n    move camera\n    handle keys - jump / Crouch\n    move sprite x\n    move sprite y\n    broadcast (position tiles v)\nend\npoint in direction (90)\nset [level clear progress v] to [2]\nrepeat (100)\n    set [speed x v] to [5]\n    change [x v] by (speed x)\n    change [player frame v] by (0.4)\n    paint sprite\n    broadcast (position tiles v)\n    handle keys - jump / Crouch\nend\nset [editor v] to [1]\nbroadcast (LEVEL - Load v) and wait\nbroadcast (LEVEL - Start Game Loop - Respawn v)\n\nwhen flag clicked\nset [ghost v] effect to (100)\n\nwhen I receive [move player after enemy v]\ndelete all of [stomp indexes 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 [level - start game loop v]\nif <(speed x) > [10]> then\n    set [speed x v] to [10]\nend\nif <(speed x) < [-10]> then\n    set [speed x v] to [-10]\nend\n\nwhen I receive [mario - fall off cliff v]\nstart sound [Lose Life v]\nset [freeze particles v] to [1]\nset [y v] to [-300]\nstop [other scripts in sprite v]\nrepeat (95)\n    paint sprite\n    broadcast (position tiles v)\nend\nbroadcast (LEVEL - Load v) and wait\nbroadcast (LEVEL - Start Game Loop - Respawn v)\n\nwhen [0 v] key pressed\nshow\nswitch costume to (mariowalk1 v)\n\nwhen flag clicked\ngo to [front v] layer\n\nwhen [timer v] > (stop sign detector)\ngo to [back v] layer\n\nwhen I receive [level - start game loop v]\nset [level clear progress v] to [0]\n\nwhen I receive [level - start game loop v]\ngo to [front v] layer\ngo [backward v] (1) layers\n\nwhen I receive [level - start game loop - respawn v]\ngo to [front v] layer\ngo [backward v] (1) layers\n\nwhen I receive [position tiles v]\nif <(player action) = [lose life]> then\n    set [player action v] to [lose life]\nend\n\nwhen I receive [level - start game loop - respawn v]\nset [freeze particles v] to [0]\n\nwhen I receive [level - start game loop v]\nset [freeze particles v] to [0]\n\ndefine Loop Transformation\nrepeat (3)\n    if <(MARIO) = [Hammer]> then\n        switch costume to (hammertransform v)\n    else\n        switch costume to (mariotransform v)\n    end\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 [collect mushroom v]\nset [freeze particles v] to [1]\nif <not <(MARIO) = [Mini]>> then\n    stop [this script v]\nend\nstop [other scripts in sprite v]\nwait (0) seconds\nLoop Transformation\nset [mario v] to [Mario]\nLoop Transformation\nset [freeze particles v] to [0]\nbroadcast (LEVEL - Continue Game Loop v)\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\nset [freeze particles v] to [1]\nstart sound [Power Down v]\nstop [other scripts in sprite v]\nwait (0) seconds\nset [invulnerable v] to [70]\nset [throw v] to [0]\nif <<(MARIO) = [Fire]> or <(MARIO) = [Hammer]>> 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\nset [freeze particles v] to [0]\nbroadcast (LEVEL - Continue Game Loop v)\n\nwhen I receive [position tiles v]\nif <(invulnerable) > [0]> then\n    change [invulnerable v] by (-1)\nend\nif <((invulnerable) mod (2)) < [1]> then\n    set [ghost v] effect to (0)\nelse\n    set [ghost v] effect to (99)\nend\n\nwhen I receive [green flag v]\nclear graphic effects\n\nwhen flag clicked\nhide variable [level # v]\nhide variable [time v]\nset [coins v] to [0]\n\nwhen I receive [collect hammer suit v]\nset [freeze particles v] to [1]\nif <(MARIO) = [Hammer]> then\n    stop [this script v]\nend\nstop [other scripts in sprite v]\nwait (0) seconds\nLoop Transformation\nset [mario v] to [Hammer]\nLoop Transformation\nset [freeze particles v] to [0]\nbroadcast (LEVEL - Continue Game Loop v)\n\ndefine tick power-up abilities\nif <not <key (space v) pressed?>> then\n    set [space key v] to [0]\nend\nif <(MARIO) = [Hammer]> then\n    if <(fire rate) > [0]> then\n        change [fire rate v] by (-1)\n    else\n        if <key (space v) pressed?> then\n            if <(space key) = [0]> then\n                set [throw v] to [2]\n                start sound [Fireball v]\n                set [space key v] to [1]\n                broadcast (mario - hammer v)\n                set [fire rate v] to [20]\n            end\n        end\n    end\nend\n\nwhen I receive [mario - fix collision v]\nif <(fix dy) < [0]> then\n    change [y v] by ((32) - (mod y))\n    add (tile index) to [stomp indexes v]\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\nwhen I receive [collect fire flower v]\nset [freeze particles v] to [1]\nif <(MARIO) = [Fire]> then\n    stop [this script v]\nend\nstop [other scripts in sprite v]\nwait (0) seconds\nLoop Transformation\nset [mario v] to [Fire]\nLoop Transformation\nset [freeze particles v] to [0]\nbroadcast (LEVEL - Continue Game Loop v)\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            start sound [Fireball v]\n            set [throw v] to [2]\n            broadcast (mario - fireball v)\n        end\n    end\nend\n\nwhen I receive [level - load v]\nset [level clear progress v] to [0]\n\nwhen I receive [game v]\nbroadcast (green flag v)\nbroadcast (generate level v) and wait\nbroadcast (clone level tiles v) and wait\nbroadcast (LEVEL - Start Game Loop - Respawn v) and wait\n\n@Controls\n\nwhen I receive [check controls v]\ngo to x: (0) y: (0)\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 (space v) pressed?> then\n    change [button b v] by (1)\nelse\n    set [button b v] to []\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)) + (SHAKE))\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                start sound [block hit v]\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 (200)\n                end\n            end\n        end\n        if <(EDITOR) < [1]> then\n            if <(ENEMY BUMP INDEX) = (tile index)> then\n                start sound [block hit v]\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 (200)\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\nif <(bumped) < [0]> then\n    change [bumped v] by (30)\n    change y by ((24) * ([sin v] of (bumped) ))\nend\nif <([abs v] of (bumped) ) < [30]> then\n    set [bumped v] to [0]\nend\nif <(tile) = [85]> then\n    change [tile v] by (([floor v] of ((timer) * (8)) ) mod (3))\n    if <(EDITOR) < [1]> then\n        if <(BUMP INDEX) = (tile index)> then\n            start sound [block hit v]\n            set [bumped v] to [180]\n        end\n        if <<(STOMP INDEX \(MARIO\)) = (tile index)> or < (STOMP INDEXES) contains (tile index)?>> then\n            start sound [block hit v]\n            delete (item # of (tile index) in [stomp indexes v]) of [stomp indexes v]\n            set [bumped v] to [-180]\n            set [stomp index \(mario\) v] to []\n        end\n        if <<(STOMP INDEX \(ENEMY\)) = (tile index)> or < (STOMP INDEXES) contains (tile index)?>> then\n            start sound [block hit v]\n            delete (item # of (tile index) in [stomp indexes v]) of [stomp indexes v]\n            set [bumped v] to [-180]\n            set [stomp index \(enemy\) v] to []\n        end\n    end\nend\nif <(tile) = [133]> then\n    go to [front v] layer\n    go [backward v] (2) layers\n    change [tile v] by (([floor v] of ((timer) * (8)) ) mod (4))\nend\nif <(tile) = [137]> then\n    go to [front v] layer\n    go [backward v] (2) layers\nend\nif <(tile) = [140]> then\n    change [tile v] by (([floor v] of ((timer) * (8)) ) mod (4))\nend\nif <(tile) = [149]> 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 [block hit v]\n                    set [bumped v] to [180]\n                else\n                    start sound [BrickShatter v]\n                    start sound [block hit v]\n                    replace item (tile index) of [tile grid v] with [2]\n                    add [brick] 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 [block hit v]\n                set [bumped v] to [180]\n            end\n        end\n        if <(ENEMY BUMP INDEX) = (tile index)> then\n            if <(item # of (tile index) in [object idx v]) = [0]> then\n                start sound [BrickShatter v]\n                replace item (tile index) of [tile grid v] with [2]\n                add [brick] 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            else\n                replace item (tile index) of [tile grid v] with [9]\n                start sound [block hit v]\n                set [bumped v] to [180]\n            end\n        end\n    end\nend\nif <(tile) = [154]> 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            start sound [block hit v]\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 (200)\n            end\n        end\n    end\nend\nif <(item (tile index) of [tile grid v]) = [30]> then\n    set [ghost v] effect to (100)\nend\nif <(item (tile index) of [tile grid v]) = [154]> 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 <(tile) = [159]> then\n    change [tile v] by (([floor v] of ((timer) * (8)) ) mod (4))\nend\nif <(tile) = [163]> then\n    change [tile v] by (([floor v] of ((timer) * (8)) ) mod (4))\nend\nif <(tile) = [167]> then\n    if <not <([player action v] of [mario v]) = [lose life]>> then\n        if <touching (mario v)?> then\n            set [frame v] to [0]\n        else\n            change [frame v] by (1)\n            if <((frame) mod (69)) = [0]> then\n                start sound [SMA4-BulletBill v]\n                add [bullet] to [particles v]\n                add (tile x) to [particles v]\n                add (tile y) to [particles v]\n            end\n        end\n    end\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 [clone count x v] to [16]\nset [clone count y v] to [13]\nsetup\n\ndefine editor brush\ngo to [front v] layer\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 start as a clone\ngo to [back v] layer\ngo [forward v] ((LAYERS - BACKGROUND) + (1)) layers\n\nwhen I receive [green flag v]\nstop all sounds\ngo to [front v] layer\nset size to (200) %\ndelete all of [stomp indexes v]\nset [ghost v] effect to (100)\nwait (0) seconds\nclear graphic effects\n\nwhen flag clicked\nhide\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) = []> or <<(tile shape) = [IB]> or <(tile shape) = [Q]>>> then\n    stop [this script v]\nend\nif <<<(type) = [Podoboo]> or <(type) = [Boo]>> or <<(type) = [Lakitu]> 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\nif <(type) = [Hammer Bro]> then\n    if <(hammer bro jumping?) = [1]> then\n        if <<not <(part) = [feet]>> or <((mod y) - (fix dy)) < [32]>> then\n            stop [this script v]\n        end\n        if <(drop) = [1]> then\n            stop [this script v]\n        end\n    end\nend\nset [solid v] to [10]\nif <(fix dy) < [0]> then\n    change [y v] by ((32) - (mod y))\n    add (tile index) to [stomp indexes v]\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) + (-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    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    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)\nif <<not <(type) = [boo]>> and <<not <(type) = [Hammer]>> and <not <(type) = [Leaf]>>>> then\n    fix collision in direction dx: [0] dy: [-1]\n    if <(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            if <(type) = [Boom Boom]> then\n                point in direction ([direction v] of [mario v])\n            else\n                if <<not < (type) contains [shell]?>> and <not <(type) = [Hammer Bro]>>> then\n                    turn right (180) degrees\n                else\n                    if < (type) contains [shell]?> then\n                        if <(assigned direction) = [90]> then\n                            set [assigned direction v] to [-90]\n                        else\n                            set [assigned direction v] to [90]\n                        end\n                    end\n                end\n            end\n        end\n    else\n        if <(y) > (orig y)> then\n            set [speed x v] to ((speed x) * (0.85))\n        end\n    end\nend\n\ndefine move sprite y\nchange [y v] by (speed y)\nchange [falling v] by (1)\nif <<<not <(type) = [Podoboo]>> and <not <(type) = [Boo]>>> and <<not <(type) = [Hammer]>> and <not <(type) = [Leaf]>>>> then\n    fix collision in direction dx: [0] dy: (speed y)\n    check bounce at x: ((x) - ((width) / (2))) y: (((y) - (height)) - (8))\n    check bounce at x: ((x) + ((width) / (2))) y: (((y) - (height)) - (8))\n    check bounce at x: (x) y: (((y) - (height)) - (8))\nend\nif <(solid) > [0]> then\n    if <(speed y) < [0]> then\n        set [hammer bro jumping? v] to [0]\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\ndefine paint sprite\nswitch costume to (big v)\ngo to x: ((x) - (CAMERA X)) y: (((y) - (CAMERA Y)) + (SHAKE))\nswitch costume to (costume)\n\nwhen I receive [position tiles v]\nif <(type) > []> then\n    paint sprite\nend\n\nwhen I receive [move enemy v]\nclear sound effects\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 ((2) + ([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 [type v] to [squish]\n        set [costume v] to [Goomba Squish]\n        set [bounce player v] to [5]\n        add [Score 100] to [particles v]\n        add (x) to [particles v]\n        add (y) to [particles v]\n        change [score v] by (100)\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) = [196]> then\n    set [frame v] to [-1]\n    Set Type [Hammer Suit] costume [85] width [16] height [16]\nend\nif <(tile type) = [197]> then\n    set [frame v] to [-1]\n    Set Type [Fire Flower] costume [86] width [16] height [16]\nend\nif <(tile type) = [198]> then\n    Set Type [Leaf] costume [88] width [16] height [16]\nend\nif <(tile type) = [47]> then\n    Set Type [EndBox] costume [EndBox] width [16] height [16]\nend\nif <(tile type) = [83]> then\n    Set Type [Spiny] costume [27] width [14] height [14]\nend\nif <(tile type) = [126]> then\n    Set Type [Paragoomba] costume [28] width [14] height [14]\nend\nif <(tile type) = [127]> then\n    Set Type [Nipper Plant] costume [30] width [14] height [14]\nend\nif <(tile type) = [138]> then\n    set [falling v] to [10]\n    Set Type [Thwomp] costume [36] width [17] height [50]\nend\nif <(tile type) = [139]> then\n    Set Type [Podoboo] costume [38] width [14] height [14]\nend\nif <(tile type) = [144]> then\n    Set Type [Dry Bones] costume [43] width [16] height [24]\nend\nif <(tile type) = [145]> then\n    Set Type [Piranha Plant] costume [9] width [16] height [32]\nend\nif <(tile type) = [146]> then\n    Set Type [Green Koopa] costume [5] width [16] height [24]\nend\nif <(tile type) = [147]> then\n    Set Type [Buzzy Beetle] costume [65] width [16] height [16]\nend\nif <(tile type) = [148]> then\n    Set Type [Boo] costume [72] width [16] height [16]\nend\nif <(tile type) = [158]> then\n    Set Type [Boom Boom] costume [73] width [32] height [24]\nend\nif <(tile type) = [194]> then\n    Set Type [Hammer Bro] costume [49] width [16] height [24]\nend\nif <(tile type) = [195]> then\n    Set Type [Lakitu] costume [83] width [16] height [32]\nend\nif <(tile type) = [199]> then\n    Set Type [Door] costume [89] width [16] height [32]\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    change [object item # v] by (1)\n    hide\nend\nset [object item # v] to []\nset [type v] to []\n\ndefine Set Type (type) costume (costume) width (width) height (height)\nshow\ngo to [front v] layer\nset [tick v] to [0]\nset [type v] to (type)\nset [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])\nif <(type) = [Piranha Plant]> 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) = [Thwomp]> then\n    point in direction (90)\n    set [thwomp y v] to (y)\nend\nif <(type) = [Podoboo]> then\n    set [podoboo y v] to (y)\nend\nif <(type) = [Boom Boom]> then\n    change [y v] by (-4)\nend\npaint sprite\nif <<<(EDITOR) > [0]> or <(frame) = []>> or <(frame) = [-1]>> then\n    set [visible v] to [1]\nend\ncreate clone of (_myself_ v)\nset [visible v] to []\n\ndefine Tick Leaf\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        start sound [Power Up v]\n        change [score v] by (1000)\n        broadcast (Collect Mushroom v)\n        delete this clone\n    end\n    go to [front v] layer\n    change [speed y v] by (-0.1)\n    move sprite y\n    if <(direction) > [0]> then\n        if <(speed x) < [5]> then\n            change [speed x v] by (0.2)\n        else\n            set [speed x v] to [0]\n            set [speed y v] to [-0.5]\n            turn left (180) degrees\n        end\n    else\n        if <(speed x) > [-5]> then\n            change [speed x v] by (-0.2)\n        else\n            set [speed x v] to [0]\n            set [speed y v] to [-0.5]\n            turn left (180) degrees\n        end\n    end\n    move sprite x\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\ndefine Check Life Bump\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\nset [speed y v] to [11]\n\nwhen [0 v] key pressed\nstop all sounds\n\ndefine Tick - Spiny\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 ((26) + ([floor v] of ((frame) mod (2)) ))\npaint sprite\nif <touching (mario v)?> then\n    broadcast (mario - hurt v)\nend\nCheck Flip\n\ndefine check bounce at x: (x) y: (y)\nget tile at x: (x) y: (y)\nif <not <(type) = [podoboo]>> then\n    if <not <(type) = [boo]>> then\n        if <(tile shape) = [^]> then\n            set [stomp index \(enemy\) v] to (tile index)\n            set [speed y v] to [12]\n            move sprite y\n        end\n    end\nend\n\nwhen I receive [mario - level complete v]\nif <<<<(type) = [Goomba]> or <(type) = [Paragoomba]>> or <<(type) = [Nipper Plant]> or <(type) = [Thwomp]>>> or <<<(type) = [Dry Bones]> or <(type) = [Dry Bones Shell]>> or <<<(type) = [Podoboo]> or <(type) = [Spiny]>> or <<<<(type) = [Green Koopa]> or <(type) = [Green Koopa Shell]>> or <(type) = [flip]>> or <<<(type) = [Spiny Shell]> or <(type) = [Buzzy Beetle Shell]>> or <<<(type) = [Hammer Bro]> or <(type) = [Lakitu]>> or <<(type) = [Boo]> or <(type) = [Boom Boom]>>>>>>>> then\n    add [explosion] to [particles v]\n    add (x) to [particles v]\n    add (y) to [particles v]\n    delete this clone\nend\nif <<(type) = [squish]> or <(type) = [flip]>> then\n    delete this clone\nend\n\nwhen I receive [level - done loading... v]\nset [score v] to [0]\n\ndefine Tick - Paragoomba\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\nif <(falling) < [2]> then\n    change [paragoomba jump v] by (1)\n    if <(paragoomba jump) = [35]> then\n        set [speed y v] to [10]\n    end\nelse\n    set [paragoomba jump v] to [0]\nend\nmove sprite x\nchange [frame v] by (0.2)\nset [costume v] to ((28) + ([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        set [frame v] to [0]\n        set [type v] to [goomba]\n        set [bounce player v] to [5]\n        add [Score 100] to [particles v]\n        add (x) to [particles v]\n        add ((y) + (8)) to [particles v]\n        change [score v] by (100)\n    else\n        broadcast (mario - hurt v)\n    end\nend\nCheck Flip\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 ((30) + ([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 ((32) + ([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 - Thwomp\nif <(distance to [mario v]) < [300]> then\n    if <not <(falling) < [1]>> then\n        set [visible v] to [2]\n        change [speed y v] by (-1.5)\n        move sprite y\n        set [tick v] to [0]\n    end\n    if <touching (mario v)?> then\n        broadcast (mario - hurt v)\n    end\nend\nchange [tick v] by (1)\nif <<(falling) < [1]> and <(tick) < [2]>> then\n    broadcast (shake camera v)\n    start sound [Thwomp v]\nend\nif <(tick) > [5]> then\n    set [visible v] to [1]\nend\nif <(tick) > [50]> then\n    if <(falling) < [1]> then\n        if <not <(y) > ((thwomp y) - (1))>> then\n            if <touching (mario v)?> then\n                if <not <([player action v] of [mario v]) = [lose life]>> then\n                    broadcast (mario - hurt v)\n                end\n            end\n            if <not <([player action v] of [mario v]) = [lose life]>> then\n                change [y v] by (3)\n            end\n        else\n            set [falling v] to [9]\n            set [tick v] to [0]\n        end\n    end\nend\nif <touching (mario v)?> then\n    broadcast (mario - hurt v)\nend\n\nwhen I start as a clone\nset [tick v] to [0]\nif <(type) = [Fireball]> then\n    set [costume v] to [15]\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\nif <(type) = [Hammer]> then\n    set [costume v] to [87]\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    paint sprite\n    set [speed y v] to [20]\n    if <([direction v] of [mario v]) > [0]> then\n        set [speed x v] to [4]\n    else\n        set [speed x v] to [-4]\n    end\n    set [visible v] to [2]\n    set [frame v] to [0]\nend\n\ndefine Tick - Podoboo (Lava Bubble)\nif <(y) > [-100]> then\n    if <(speed y) > [-18]> then\n        change [speed y v] by (-1.2)\n    end\nend\nmove sprite y\nif <(y) < [-100]> then\n    set [speed y v] to [0]\n    set [falling v] to [0]\n    change [tick v] by (1)\n    if <(tick) > [20]> then\n        set [podoboo jumping v] to [1]\n        set [tick v] to [0]\n    end\nend\nif <(podoboo jumping) = [1]> then\n    if <not <(y) > ((podoboo y) - (1))>> then\n        set [speed y v] to [12]\n    else\n        set [podoboo jumping v] to [0]\n    end\nend\nchange [frame v] by (0.5)\nif <(speed y) > [0]> then\n    set [costume v] to ((37) + ([floor v] of ((frame) mod (3)) ))\nelse\n    set [costume v] to ((40) + ([floor v] of ((frame) mod (3)) ))\nend\nif <touching (mario v)?> then\n    broadcast (mario - hurt v)\nend\n\ndefine Tick - Dry Bones\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        set [speed x v] to [0]\n    else\n        point in direction (90)\n        change [x v] by (5)\n        set [speed x v] to [0]\n    end\nend\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.15)\nset [costume v] to ((43) + ([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 [dry bones v]\n        set [frame v] to [1]\n        set [dry bones shell phase v] to [1]\n        set [type v] to [Dry Bones Downed]\n        set [bounce player v] to [5]\n        add [Score 100] to [particles v]\n        add (x) to [particles v]\n        add (y) to [particles v]\n        change [score v] by (100)\n    else\n        broadcast (mario - hurt v)\n    end\nend\nCheck Flip\n\ndefine Tick - Dry Bones Downed\nchange [speed y v] by (-1)\nmove sprite y\nif <(dry bones shell phase) = [1]> then\n    change [frame v] by (0.2)\n    set [costume v] to ((45) + ([floor v] of ((frame) mod (2)) ))\n    if <(costume) = [46]> then\n        set [tick v] to [0]\n        set [dry bones shell phase v] to [2]\n    end\nend\nif <(dry bones shell phase) = [2]> then\n    set [frame v] to [1]\n    set [costume v] to [46]\n    change [tick v] by (1)\n    if <(tick) > [99]> then\n        set [dry bones shell phase v] to [3]\n    end\nend\nif <(dry bones shell phase) = [3]> then\n    change [frame v] by (0.2)\n    set [costume v] to ((47) + ([floor v] of ((frame) mod (2)) ))\n    if <(costume) = [48]> then\n        set [type v] to [Dry Bones]\n    end\nend\n\nwhen I receive [level - start game loop v]\nset [tick v] to [0]\nset [shake v] to [0]\nset [boss? v] to [0]\n\ndefine Tick - Piranha Plant\nchange [frame v] by (1)\nif <(frame) < [2]> then\n    go to [back v] layer\n    go [forward v] (LAYERS - BACKGROUND) layers\nend\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]> then\n    if <touching (mario v)?> then\n        broadcast (mario - hurt v)\n    end\nend\n\nwhen I start as a clone\nif <<<(type) = [Life]> or <(type) = [Hammer Suit]>> or <<(type) = [Fire Flower]> or <(type) = [Leaf]>>> then\n    set [frame v] to [-1]\nend\nforever\n    if <<<not <(type) = [Piranha Plant]>> and <not <(type) = [Life]>>> and <<<not <(type) = [Thwomp]>> and <not <(type) = [Hammer Suit]>>> and <<not <(type) = [Fire Flower]>> and <not <(type) = [Leaf]>>>>> then\n        go to [front v] layer\n        go [backward v] (1) layers\n    end\nend\n\ndefine Tick - Green Koopa\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 ((5) + ([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        set [frame v] to [0]\n        set [costume v] to [54]\n        set [type v] to [Green Koopa Shell]\n        set [height v] to [15]\n        set [bounce player v] to [5]\n        add [Score 100] to [particles v]\n        add (x) to [particles v]\n        add (y) to [particles v]\n        change [score v] by (100)\n    else\n        broadcast (mario - hurt v)\n    end\nend\nCheck Flip\n\ndefine Tick - Green Koopa Shell\nif <(flipped shell?) = [1]> then\n    point in direction (-90)\n    set rotation style [all around v]\nelse\n    point in direction (90)\nend\nchange [speed y v] by (-1)\nmove sprite y\nif <(frame) < [3]> then\n    set [costume v] to [53]\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 <(flipped shell?) = [1]> then\n        point in direction (-90)\n        set rotation style [all around v]\n    else\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 rotation style [left-right v]\n    end\n    if <([x v] of [mario v]) < (x)> then\n        set [assigned direction v] to [90]\n    else\n        set [assigned direction v] to [-90]\n    end\n    start sound [KickShell v]\n    set [visible v] to [2]\nend\nchange [frame v] by (0.4)\nset [speed x v] to ((assigned direction) / (9))\nmove sprite x\nset [costume v] to ((54) + ([floor v] of ((frame) mod (3)) ))\npaint sprite\nif <<touching (mario v)?> and <(frame) > [5]>> 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\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)) < [-450]> then\n        delete this 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 this clone\n    end\nend\nif <(frame) = [-1]> then\n    go to [back v] layer\n    if <(BUMP INDEX) = (spawn index)> then\n        set [frame v] to [0]\n        point in direction ([direction v] of [mario v])\n        go [forward v] (LAYERS - BACKGROUND) layers\n    end\n    if <(ENEMY BUMP INDEX) = (spawn index)> then\n        set [frame v] to [0]\n        point in direction ([direction v] of [mario v])\n        go [forward v] (LAYERS - BACKGROUND) layers\n    end\n    stop [this script v]\nend\nif <(frame) < [0]> then\n    if <(type) = [thwomp]> then\n        point in direction (90)\n    else\n        if <(type) = [spiny shell]> then\n            point in direction (-90)\n        else\n            if <(type) = [boo]> then\n                point in direction (-90)\n            else\n                if <(x) > ([x v] of [mario v])> then\n                    point in direction (-90)\n                else\n                    point in direction (90)\n                end\n            end\n        end\n    end\nend\nif <(frame) = [0]> then\n    if <([abs v] of ((x) - (CAMERA X)) ) > [260]> then\n        if <(type) = [Boom Boom]> then\n            set [boss? v] to [0]\n        end\n        stop [this script v]\n    end\n    if <([abs v] of ((y) - (CAMERA Y)) ) > [200]> then\n        if <(type) = [Boom Boom]> then\n            set [boss? v] to [0]\n        end\n        stop [this script v]\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) = [Leaf]> then\n    Tick Leaf\n    stop [this script v]\nend\nif <(type) = [Piranha Plant]> then\n    Tick - Piranha Plant\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    set [tick v] to [0]\n    if <touching (mario v)?> then\n        set [type v] to [costume]\n        start sound [Goal v]\n        broadcast (mario - level complete v)\n        set [costume v] to [EndBox]\n    end\nend\nif <(type) = [Spiny]> then\n    Tick - Spiny\n    stop [this script v]\nend\nif <(type) = [Paragoomba]> then\n    Tick - Paragoomba\n    stop [this script v]\nend\nif <(type) = [Nipper Plant]> then\n    Tick - Nipper Plant\n    stop [this script v]\nend\nif <(type) = [Thwomp]> then\n    Tick - Thwomp\n    stop [this script v]\nend\nif <(type) = [Podoboo]> then\n    Tick - Podoboo (Lava Bubble)\n    stop [this script v]\nend\nif <(type) = [Dry Bones]> then\n    Tick - Dry Bones\n    stop [this script v]\nend\nif <(type) = [Dry Bones Downed]> then\n    Tick - Dry Bones Downed\n    stop [this script v]\nend\nif <(type) = [Green Koopa]> then\n    Tick - Green Koopa\n    stop [this script v]\nend\nif <(type) = [Green Koopa Shell]> then\n    Tick - Green Koopa Shell\n    stop [this script v]\nend\nif <(type) = [Spiny Shell]> then\n    Tick - Spiny Shell\n    stop [this script v]\nend\nif <(type) = [Buzzy Beetle]> then\n    Tick - Buzzy Beetle\n    stop [this script v]\nend\nif <(type) = [Buzzy Beetle Shell]> then\n    Tick - Buzzy Beetle Shell\n    stop [this script v]\nend\nif <(type) = [Boo]> then\n    Tick - Boo\n    stop [this script v]\nend\nif <(type) = [Boom Boom]> then\n    Tick - Boom Boom\n    stop [this script v]\nend\nif <(type) = [Hammer Bro]> then\n    Tick - Hammer Bro\n    stop [this script v]\nend\nif <(type) = [Lakitu]> then\n    Tick - Lakitu\n    stop [this script v]\nend\nif <(type) = [Hammer Suit]> then\n    Tick - Hammer Suit\n    stop [this script v]\nend\nif <(type) = [Fire Flower]> then\n    Tick - Fire Flower\n    stop [this script v]\nend\nif <(type) = [Fireball]> then\n    Tick - Fireball\n    stop [this script v]\nend\nif <(type) = [Hammer]> then\n    Tick - Hammer\n    stop [this script v]\nend\nif <(type) = [Door]> then\n    change [frame v] by (0.15)\n    set [costume v] to [Door]\n    set [tick v] to [0]\n    if <<touching (mario v)?> and <key (down arrow v) pressed?>> then\n        set [costume v] to [Door Open]\n    end\nend\n\nchange [level # v] by (1)\nbroadcast (LEVEL - Load v) and wait\nbroadcast (LEVEL - Start Game Loop - Respawn v)\n\nwhen I receive [move player after enemy v]\nif <<(EDITOR) < [1]> and <(visible) = [1]>> then\n    show\n    if <touching (enemy v)?> then\n        Flip\n    end\n    hide\nend\n\ndefine Flip\nif <not <(type) = [flip]>> then\n    if <<<not <(type) = [Thwomp]>> and <not <(type) = [Life]>>> and <<not <(type) = [Endbox]>> and <<not <(type) = [Hammer Suit]>> and <not <(type) = [Fire Flower]>>>>> then\n        if <not <(type) = [Green Koopa]>> then\n            if <not <(type) = [Spiny]>> then\n                if <not <(type) = [Buzzy Beetle]>> then\n                    if <not <(type) = [Paragoomba]>> then\n                        if <<not <(type) = [Piranha Plant]>> and <<not <(type) = [Boom Boom]>> and <not <(type) = [Lakitu]>>>> then\n                            start sound [KickShell v]\n                            set rotation style [all around v]\n                            point in direction (-90)\n                            set [type v] to [flip]\n                            change [score v] by (100)\n                            set [speed y v] to [14]\n                            set [speed x v] to (([direction v] of [mario v]) / (45))\n                            add [Score 100] to [particles v]\n                            add (x) to [particles v]\n                            add (y) to [particles v]\n                            stop [this script v]\n                        else\n                            if <<(temp) > [5]> or <(frame) = [0]>> then\n                                add [explosion] 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\n                            end\n                        end\n                    else\n                        start sound [KickShell v]\n                        go to [front v] layer\n                        point in direction (-90)\n                        set rotation style [all around v]\n                        set [type v] to [flip]\n                        set [costume v] to [2]\n                        change [score v] by (100)\n                        set [speed y v] to [14]\n                        set [speed x v] to (([direction v] of [mario v]) / (45))\n                        add [Score 100] to [particles v]\n                        add (x) to [particles v]\n                        add (y) to [particles v]\n                    end\n                else\n                    start sound [KickShell v]\n                    go to [front v] layer\n                    point in direction (-90)\n                    set rotation style [all around v]\n                    set [type v] to [flip]\n                    change [score v] by (100)\n                    set [speed y v] to [14]\n                    set [speed x v] to (([direction v] of [mario v]) / (45))\n                    add [Score 100] to [particles v]\n                    add (x) to [particles v]\n                    add (y) to [particles v]\n                end\n            else\n                go to [front v] layer\n                start sound [KickShell v]\n                point in direction (-90)\n                set rotation style [all around v]\n                set [type v] to [flip]\n                change [score v] by (100)\n                set [speed y v] to [14]\n                set [speed x v] to (([direction v] of [mario v]) / (45))\n                add [Score 100] to [particles v]\n                add (x) to [particles v]\n                add (y) to [particles v]\n            end\n        else\n            start sound [KickShell v]\n            go to [front v] layer\n            point in direction (-90)\n            set rotation style [all around v]\n            set [type v] to [flip]\n            change [score v] by (100)\n            set [speed y v] to [14]\n            set [speed x v] to (([direction v] of [mario v]) / (45))\n            add [Score 100] to [particles v]\n            add (x) to [particles v]\n            add (y) to [particles v]\n        end\n    end\nend\n\nwhen I start as a clone\npoint in direction (90)\nset rotation style [left-right v]\n\ndefine check around player at x: (x) y: (y)\nget tile at x: (x) y: (y)\nif <(tile) = [24]> then\n    start sound [Coin v]\n    replace item (tile index) of [tile grid v] with [2]\n    change [coins v] by (1)\n    change [score v] by (200)\nend\n\ndefine Tick - Spiny Shell\nif <(flipped shell?) = [1]> then\n    point in direction (-90)\n    set rotation style [all around v]\nelse\n    point in direction (90)\nend\nchange [speed y v] by (-1)\nmove sprite y\nif <(frame) < [3]> then\n    set [costume v] to [61]\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 <(flipped shell?) = [1]> then\n        point in direction (-90)\n        set rotation style [all around v]\n    else\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 rotation style [left-right v]\n    end\n    if <([x v] of [mario v]) < (x)> then\n        set [assigned direction v] to [90]\n    else\n        set [assigned direction v] to [-90]\n    end\n    start sound [KickShell v]\n    set [visible v] to [2]\nend\nchange [frame v] by (0.4)\nset [speed x v] to ((assigned direction) / (9))\nmove sprite x\nset [costume v] to ((62) + ([floor v] of ((frame) mod (3)) ))\npaint sprite\nif <<touching (mario v)?> and <(frame) > [5]>> 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 Tick - Buzzy Beetle\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 ((65) + ([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        set [frame v] to [0]\n        set [costume v] to [67]\n        set [type v] to [Buzzy Beetle Shell]\n        set [bounce player v] to [5]\n        add [Score 100] to [particles v]\n        add (x) to [particles v]\n        add (y) to [particles v]\n        change [score v] by (100)\n    else\n        broadcast (mario - hurt v)\n    end\nend\nCheck Flip\n\ndefine Tick - Buzzy Beetle Shell\nif <(flipped shell?) = [1]> then\n    point in direction (-90)\n    set rotation style [all around v]\nelse\n    point in direction (90)\nend\nchange [speed y v] by (-1)\nmove sprite y\nif <(frame) < [3]> then\n    set [costume v] to [67]\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 <(flipped shell?) = [1]> then\n        point in direction (-90)\n        set rotation style [all around v]\n    else\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 rotation style [left-right v]\n    end\n    if <([x v] of [mario v]) < (x)> then\n        set [assigned direction v] to [90]\n    else\n        set [assigned direction v] to [-90]\n    end\n    start sound [KickShell v]\n    set [visible v] to [2]\nend\nchange [frame v] by (0.4)\nset [speed x v] to ((assigned direction) / (9))\nmove sprite x\nset [costume v] to ((68) + ([floor v] of ((frame) mod (3)) ))\npaint sprite\nif <<touching (mario v)?> and <(frame) > [5]>> 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\nwhen I start as a clone\nset [flipped shell? v] to [0]\n\ndefine bump\nif <(visible) = [2]> then\n    get tile at x: ((x) + ((width) + (8))) y: ((y) - (12))\n    if <(tile) = [20]> then\n        set [enemy bump index v] to (tile index)\n    end\n    if <(tile) = [149]> then\n        set [enemy bump index v] to (tile index)\n    end\n    get tile at x: ((x) - ((width) + (8))) y: ((y) - (12))\n    if <(tile) = [20]> then\n        set [enemy bump index v] to (tile index)\n    end\n    if <(tile) = [149]> then\n        set [enemy bump index v] to (tile index)\n    end\nend\n\nwhen I receive [check controls v]\nif < (type) contains [shell]?> then\n    bump\nend\n\nwhen I receive [level - start game loop v]\nif <<not <(type) = [life]>> and <not <(type) = [Hammer Suit]>>> then\n    set [frame v] to [0]\nelse\n    set [frame v] to [-1]\nend\nset [bump index v] to []\nset [enemy bump index v] to []\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 [71]\nelse\n    set [costume v] to [72]\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\nwhen I receive [position tiles v]\nif <(type) = [Life]> then\n    if <(FREEZE PARTICLES) = [1]> then\n        if <(frame) = [-1]> then\n            go to [back v] layer\n        end\n    end\nend\n\ndefine Tick - Boom Boom\nset [boss? v] to [1]\nchange [speed y v] by (-1)\nmove sprite y\nif <(tick) < [1]> then\n    change [frame v] by (0.35)\n    set [costume v] to ((73) + (([floor v] of (frame) ) mod (4)))\n    if <([x v] of [mario v]) > (x)> then\n        set [speed x v] to [4]\n    else\n        set [speed x v] to [-4]\n    end\n    move sprite x\n    if <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 [bounce player v] to [5]\n            change [boom boom hits v] by (1)\n            set [tick v] to [1]\n            add [Score 100] to [particles v]\n            add (x) to [particles v]\n            add ((y) + (16)) to [particles v]\n            change [score v] by (100)\n        else\n            broadcast (mario - hurt v)\n        end\n    end\nend\nif <<not <(tick) < [1]>> and <(tick) < [20]>> then\n    change [tick v] by (1)\n    change [frame v] by (1)\n    set [costume v] to ((77) + (([floor v] of (frame) ) mod (4)))\n    if <(tick) > [18]> then\n        if <(boom boom hits) < [3]> then\n            set [frame v] to [0.1]\n        else\n            set [boss? v] to [0]\n            set [costume v] to [77]\n            set [frame v] to [0]\n            Flip\n            stop [this script v]\n        end\n    end\nend\nif <<<not <(tick) < [20]>> and <(tick) > [19]>> and <not <(tick) > [49]>>> then\n    change [frame v] by (0.27)\n    set [costume v] to ((81) + (([floor v] of (frame) ) mod (2)))\nend\nif <<<(tick) > [19]> and <(costume) = [82]>> and <not <(tick) > [49]>>> then\n    set [tick v] to [50]\nend\nif <(tick) > [49]> then\n    change [tick v] by (1)\n    if <(tick) > [69]> then\n        set [speed y v] to [10]\n        set [tick v] to [0]\n    end\nend\nif <<(costume) = [81]> or <(costume) = [82]>> then\n    if <touching (mario v)?> then\n        broadcast (mario - hurt v)\n    end\nend\n\nwhen I receive [level - start game loop v]\nset [boom boom hits v] to [0]\n\nwhen I receive [mario - lose life v]\nset [shake v] to [0]\n\nwhen I receive [green flag v]\nset size to (200) %\nhide\nset [visible v] to []\nset [type v] to []\nset [speed x v] to [0]\nset [speed y v] to [0]\n\ndefine Tick - Hammer Bro\nchange [tick v] by (1)\nchange [frame v] by (0.2)\nset [costume v] to ((49) + ([floor v] of ((frame) mod (2)) ))\nchange [speed y v] by (-1)\nif <(falling) < [2]> then\n    if <(tick) > [85]> then\n        if <(pick random (1) to (2)) = [1]> then\n            get tile at x: (x) y: ((y) - ((height) * (2)))\n            if <<<<<(tile) = [9]> or <(tile) = [10]>> or <(tile) = [20]>> or <<(tile) = [32]> or <(tile shape) = [=]>>> or <(tile) = [149]>> then\n                set [hammer bro jumping? v] to [1]\n                set [drop v] to [1]\n                set [speed y v] to [5]\n            else\n                set [drop v] to [0]\n            end\n        else\n            set [hammer bro jumping? v] to [1]\n            set [speed y v] to [18]\n        end\n        set [tick v] to [0]\n    end\nend\nif <touching (mario v)?> then\n    if <([bop y v] of [mario v]) > []> then\n        set [frame v] to [0]\n        set [bounce player v] to [5]\n        Flip\n        stop [this script v]\n    else\n        broadcast (mario - hurt v)\n    end\nend\nif <(x) > ([x v] of [mario v])> then\n    point in direction (-90)\nelse\n    point in direction (90)\nend\nif <not <(hammer bro jumping?) = [1]>> then\n    change [speed x v] by (pick random (-0.25) to (0.25))\nend\nif <(hammer bro jumping?) = [1]> then\n    set [speed x v] to [0]\nend\nif <(tick) = [50]> then\n    add [Hammer] to [particles v]\n    add (x) to [particles v]\n    add (y) to [particles v]\nend\nmove sprite x\nmove sprite y\nget tile at x: (x) y: ((y) - ((height) * (2)))\nif <(tile shape) = []> then\n    set [drop v] to [0]\nend\nCheck Flip\n\nwhen I receive [level - start game loop v]\nset [drop v] to [0]\n\nwhen I receive [level - start game loop - respawn v]\nset [drop v] to [0]\n\ndefine Tick - Lakitu\nset [frame v] to [1]\nchange [tick v] by (1)\nif <([x v] of [mario v]) > (x)> then\n    if <(speed x) < [12]> then\n        change [speed x v] by (0.5)\n    end\nelse\n    if <(speed x) > [-12]> then\n        change [speed x v] by (-0.5)\n    end\nend\nmove sprite x\nif <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        Flip\n        stop [this script v]\n    else\n        broadcast (mario - hurt v)\n    end\nend\nif <(tick) < [49]> then\n    set [costume v] to [83]\nelse\n    set [costume v] to [84]\nend\nif <(tick) > [59]> then\n    add [spiny egg] to [particles v]\n    add (x) to [particles v]\n    add (y) to [particles v]\n    set [tick v] to [0]\nend\n\ndefine Tick - Hammer Suit\nif <(frame) > [-1]> then\n    change [frame v] by (1)\nend\nif <(frame) < [16]> then\n    go to [back v] layer\n    stop [this script v]\nend\nif <([player action v] of [mario v]) = [lose life]> then\n    go to [back v] layer\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 [Power Up v]\n        change [score v] by (1000)\n        broadcast (Collect Hammer Suit v)\n        delete this clone\n    end\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    if <(falling) < [2]> then\n        set [speed y v] to [15]\n    end\nend\n\nwhen I receive [enemy kill check v]\nif <touching (particles v)?> then\n    if <not <(type) = [flip]>> then\n        Flip\n        start sound [Kick1 v]\n    end\nend\n\ndefine Tick - Fire Flower\nchange [frame v] by (1)\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        start sound [Power Up v]\n        change [score v] by (1000)\n        broadcast (Collect Fire Flower v)\n        delete this clone\n    end\n    go to [front v] layer\n    change [speed y v] by (-1)\n    move sprite y\nend\n\nwhen I receive [level - start game loop v]\nif <<<<(type) = [Life]> or <(type) = [Hammer Suit]>> or <(type) = [Fire Flower]>> or <(type) = [Leaf]>> then\n    set [frame v] to [-1]\nend\n\nwhen I receive [level - start game loop - respawn v]\nif <<<<(type) = [Life]> or <(type) = [Hammer Suit]>> or <(type) = [Fire Flower]>> or <(type) = [Leaf]>> then\n    set [frame v] to [-1]\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\nwhen I receive [mario - hammer v]\nif <(type) = []> then\n    set [type v] to [Hammer]\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    add [explosion] to [particles v]\n    add (x) to [particles v]\n    add (y) to [particles v]\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\nif <(falling) = [0]> then\n    set [speed y v] to [11]\nend\nmove sprite y\n\ndefine delete clone\nif <(type) = [Fireball]> then\n    change [fireballs v] by (-1)\nend\ndelete this clone\n\nwhen I receive [level - start game loop v]\nset [fireballs v] to [0]\n\nwhen I receive [level - start game loop - respawn v]\nset [fireballs v] to [0]\n\ndefine Tick - Hammer\nset rotation style [all around v]\nif <(speed x) > [0]> then\n    turn right (30) degrees\nelse\n    turn left (30) degrees\nend\nmove sprite x\nif <(speed y) > [-20]> then\n    change [speed y v] by (-1.5)\nend\nmove sprite y\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 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        start sound [Power Up v]\n        change [score v] by (1000)\n        broadcast (Collect Mushroom v)\n        delete this clone\n    end\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    Check Life Bump\nend\n\n@Editor\n\ndefine generate level\nif <(BACKDROP ANSWER) = [1]> then\n    set [backdrop v] to [1]\nelse\n    if <(BACKDROP ANSWER) = [2]> then\n        set [backdrop v] to [2]\n    else\n        if <(BACKDROP ANSWER) = [3]> then\n            set [backdrop v] to [3]\n        else\n            if <(BACKDROP ANSWER) = [4]> then\n                set [backdrop v] to [4]\n            else\n                if <(BACKDROP ANSWER) = [5]> then\n                    set [backdrop v] to [6]\n                else\n                    if <(BACKDROP ANSWER) = [6]> then\n                        set [backdrop v] to [5]\n                    else\n                        if <(BACKDROP ANSWER) = [7]> then\n                            set [backdrop v] to [5]\n                        else\n                            if <(BACKDROP ANSWER) = [8]> then\n                                set [backdrop v] to [7]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\ndelete all of [tile grid v]\ndelete all of [object idx v]\ndelete all of [object type v]\nset [autoscroll v] to [1]\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\nif <(BACKDROP ANSWER) = [1]> then\n    add [7] to [tile grid v]\nelse\n    if <(BACKDROP ANSWER) = [2]> then\n        add [59] to [tile grid v]\n    else\n        if <(BACKDROP ANSWER) = [3]> then\n            add [89] to [tile grid v]\n        else\n            if <(BACKDROP ANSWER) = [4]> then\n                add [106] to [tile grid v]\n            else\n                if <(BACKDROP ANSWER) = [5]> then\n                    add [106] to [tile grid v]\n                else\n                    if <(BACKDROP ANSWER) = [6]> then\n                        add [131] to [tile grid v]\n                    else\n                        if <(BACKDROP ANSWER) = [7]> then\n                            add [132] to [tile grid v]\n                        else\n                            if <(BACKDROP ANSWER) = [8]> then\n                                add [2] to [tile grid v]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\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\nbroadcast (load backdrop v)\nset [brush v] to [0]\nset [chosen brush v] to [10]\nif <(length of [tile grid v]) = [0]> then\n    set [backdrop v] to [1]\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\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 [e v] key pressed\nset [object item # v] to (item # of (tile index) in [object idx v])\nif <not <(tile) = [2]>> then\n    if <not <(object item #) > [0]>> then\n        set [chosen brush v] to (tile)\n    end\nend\nif <(object item #) > [0]> then\n    set [chosen brush v] to (item (object item #) of [object type v])\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\nif <(GRID WIDTH) < [19]> then\n    set [grid width v] to [20]\nend\nask (join [Enter Level Height \(Current ] (join (GRID HEIGHT) [\)])) and wait\nif <not <(answer) = []>> then\n    set [grid height v] to (answer)\nend\nask [Enter Theme Number \(Enter numbers 1-8, the themes include Ground, Mountain, Desert, Underground, Underground 2, Castle 1, Castle 2, Sky\).] and wait\nif <not <(answer) = []>> then\n    set [backdrop answer v] to (answer)\nend\nif <<(answer) > [8]> or <(answer) < [1]>> then\n    set [backdrop answer v] to [1]\nend\ngenerate level\nbroadcast (LEVEL - Done Loading... v) and wait\nbroadcast (LEVEL - Start Game Loop - Respawn v)\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 flag clicked\nhide variable [level # v]\nhide variable [auto v]\n\nwhen [b v] key pressed\nif <(EDITOR) = [1]> then\n    change [backdrop v] by (1)\n    if <(BACKDROP) > [7]> then\n        set [backdrop v] to [1]\n    end\n    broadcast (load backdrop v)\nend\n\nwhen [1 v] key pressed\nnext brush [1]\n\nwhen [2 v] key pressed\nnext brush [2]\n\nwhen [4 v] key pressed\nnext brush [4]\n\nwhen [5 v] key pressed\nnext brush [5]\n\nwhen [9 v] key pressed\nnext brush [9]\n\nwhen [0 v] key pressed\nif <not <(timer) > (stop sign detector)>> then\n    stop all sounds\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        set [coins v] to [0]\n        hide variable [autoscroll 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        set [coins v] to [0]\n        show variable [autoscroll v]\n        broadcast (LEVEL - Load v) and wait\n        broadcast (LEVEL - Start Game Loop v)\n    end\nend\n\nwhen flag clicked\nset [backdrop answer v] to [1]\n\nwhen I receive [level - start game loop v]\nset [coins v] to [0]\n\nwhen [c v] key pressed\nif <(EDITOR) = [1]> then\n    change [autoscroll v] by (1)\n    if <(AUTOSCROLL) > [17]> then\n        set [autoscroll v] to [1]\n    end\nend\n\nwhen [8 v] key pressed\nnext brush [8]\n\nwhen [p 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 [Hammer]\n    else\n        if <(MARIO) = [Hammer]> then\n            set [mario v] to [Fire]\n        else\n            set [mario v] to [Mini]\n        end\n    end\nend\n\nwhen [v v] key pressed\nif <(EDITOR) = [1]> then\n    ask (join [Enter timer count \(Current ] (join (SAVE TIME) [\)])) and wait\n    if <not <[499] > (SAVE TIME)>> then\n        set [save time v] to (answer)\n    else\n        set [save time v] to [500]\n    end\nend\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\nset volume to (100) %\nstop [other scripts in sprite v]\nforever\n    if <(EDITOR) < [1]> then\n        if <(BOSS?) < [1]> then\n            if <(BACKDROP) < [2]> then\n                play sound [Music L1 v] until done\n            end\n            if <(BACKDROP) = [2]> then\n                play sound [Music L2 v] until done\n            end\n            if <(BACKDROP) = [3]> then\n                play sound [Music L1 v] until done\n            end\n            if <(BACKDROP) = [4]> then\n                play sound [Music L3 v] until done\n            end\n            if <(BACKDROP) = [5]> then\n                play sound [Music L4 v] until done\n            end\n            if <(BACKDROP) = [6]> then\n                play sound [Music L3 v] until done\n            end\n            if <(BACKDROP) = [7]> then\n                play sound [Music L2 v] until done\n            end\n        else\n            play sound [Boss Music v] until done\n        end\n    else\n        play sound [152 - Ground \(Maker\) \[Super Mario Bros v] until done\n    end\nend\n\nwhen I receive [mario - lose life v]\nstop [other scripts in sprite v]\n\nwhen I receive [level - stop!!! v]\nstop [other scripts in sprite v]\n\nwhen I receive [mario - level complete v]\nstop [other scripts in sprite v]\n\nwhen I receive [p switch v]\nstop [other scripts in sprite v]\n\nwhen I receive [music v]\nmusic\n\nwhen I receive [mario - fall off cliff v]\nstop [other scripts in sprite v]\n\nwhen I receive [move player v]\nif <(BOSS?) = [1]> then\n    if <(PLAYING BOSS MUSIC?) = [0]> then\n        stop [other scripts in sprite v]\n        set [playing boss music? v] to [1]\n        broadcast (Music v)\n    end\nelse\n    if <(PLAYING BOSS MUSIC?) = [1]> then\n        stop [other scripts in sprite v]\n        set [playing boss music? v] to [0]\n        broadcast (Music v)\n    end\nend\n\n\n\n@particles\n\nwhen I start as a clone\npoint in direction (90)\nhide\nset [frame v] to [1]\nset [speed x v] to [0]\nset [speed y v] to [0]\nif <(type) = [coin]> then\n    start sound [Coin v]\n    set [speed y v] to [12]\nend\nif <(type) = [brick]> then\n    set [speed y v] to [12]\nend\nif < (type) contains [hammer]?> then\n    set [speed y v] to [15]\nend\nif <(type) = [spiny egg]> then\n    set [speed y v] to [10]\nend\nif <(type) = [bullet]> then\n    set [frame v] to [1]\n    set rotation style [left-right v]\n    if <(x) > ([x v] of [mario v])> then\n        set [root direction v] to [1]\n        point in direction (-90)\n        get tile at x: ((x) - (24)) y: ((y) - (12))\n        if <(tile shape) = [#]> then\n            delete this clone\n        end\n    else\n        set [root direction v] to [2]\n        point in direction (90)\n        get tile at x: ((x) + (24)) y: ((y) - (12))\n        if <(tile shape) = [#]> then\n            delete this clone\n        end\n    end\nend\nif <(type) = [hammer]> then\n    set [frame v] to [1]\n    set rotation style [all around v]\n    if <(x) > ([x v] of [mario v])> then\n        set [root direction v] to [1]\n        point in direction (-90)\n    else\n        set [root direction v] to [2]\n        point in direction (90)\n    end\nend\nif <(type) = [spiny egg]> then\n    set [width v] to [16]\n    set [height v] to [16]\n    if <(pick random (1) to (2)) = [1]> then\n        set [speed x v] to [3]\n    else\n        set [speed x v] to [-3]\n    end\nend\nif <(type) = [spiny]> then\n    set [width v] to [16]\n    set [height v] to [16]\n    go to [front v] layer\nend\nif <(type) = [HammerMario]> then\n    set [visible v] to [2]\n    set [frame v] to [1]\n    set rotation style [all around v]\n    if <([direction v] of [mario v]) = [-90]> then\n        set [root direction v] to [1]\n        point in direction (-90)\n    else\n        set [root direction v] to [2]\n        point in direction (90)\n    end\nend\n\nif <(COINS) > [99]> then\n    start sound [1up v]\n    set [coins v] to [0]\nend\n\nwhen I receive [position tiles v]\nif <(FREEZE PARTICLES) = [0]> then\n    show\n    switch costume to (blank v)\nend\nif <(frame) = []> then\n    go to [back v] layer\n    go [forward v] (8) layers\n    Spawn Particles\n    stop [this script v]\nend\nif <(type) = [coin]> then\n    if <(EDITOR) = [1]> then\n        delete this clone\n    end\n    Tick - Coin\n    stop [this script v]\nend\nif < (type) contains [score]?> then\n    if <(EDITOR) = [1]> then\n        delete this clone\n    end\n    go to [front v] layer\n    Tick - Score\n    stop [this script v]\nend\nif < (type) contains [brick]?> then\n    if <(EDITOR) = [1]> then\n        delete this clone\n    end\n    go to [front v] layer\n    Tick - Break\n    stop [this script v]\nend\nif < (type) contains [bullet]?> then\n    if <(EDITOR) = [1]> then\n        delete this clone\n    end\n    Tick - Bullet Bill\n    stop [this script v]\nend\nif <(type) = [hammer]> then\n    if <(EDITOR) = [1]> then\n        delete this clone\n    end\n    Tick - Hammer\n    stop [this script v]\nend\nif < (type) contains [explosion]?> then\n    if <(EDITOR) = [1]> then\n        delete this clone\n    end\n    Tick - Explosion\n    stop [this script v]\nend\nif < (type) contains [spiny egg]?> then\n    if <(EDITOR) = [1]> then\n        delete this clone\n    end\n    Tick - Spiny Egg\n    stop [this script v]\nend\nif < (type) contains [spiny]?> then\n    if <(EDITOR) = [1]> then\n        delete this clone\n    end\n    Tick - Spiny\n    stop [this script v]\nend\nif <(type) = [HammerMario]> then\n    Tick - HammerMario\nend\nTick - Smoke\n\ndefine Tick - Smoke\nshow\ngo to [front v] layer\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\nset [root direction v] to []\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    if <(type) = [brick]> then\n        set [root direction v] to [1]\n        create clone of (_myself_ v)\n        set [root direction v] to [2]\n        create clone of (_myself_ v)\n        set [root direction v] to [3]\n        create clone of (_myself_ v)\n        set [root direction v] to [4]\n        create clone of (_myself_ v)\n    else\n        create clone of (_myself_ v)\n    end\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) < [-13]> 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)\nshow\nswitch costume to (big v)\ngo to x: ((x) - (CAMERA X)) y: (((y) - (CAMERA Y)) + (SHAKE))\nswitch costume to (costume)\n\ndefine Tick - Score\npoint in direction (90)\nchange [y v] by (2)\nPosition with Costume [Score 100]\nchange [frame v] by (2)\nif <(frame) > [50]> then\n    delete this clone\nend\n\ndefine Tick - Break\nif <(root direction) = [1]> then\n    set [speed x v] to [1.5]\n    change [tick v] by (1)\n    if <(tick) = [2]> then\n        turn right (180) degrees\n        set [tick v] to [0]\n    end\nelse\n    if <(root direction) = [2]> then\n        set [speed x v] to [-1.5]\n        change [tick v] by (1)\n        if <(tick) = [2]> then\n            turn left (180) degrees\n            set [tick v] to [0]\n        end\n    else\n        if <(root direction) = [3]> then\n            set [speed x v] to [3]\n            change [tick v] by (1)\n            if <(tick) = [2]> then\n                turn right (180) degrees\n                set [tick v] to [0]\n            end\n        else\n            set [speed x v] to [-3]\n            change [tick v] by (1)\n            if <(tick) = [2]> then\n                turn left (180) degrees\n                set [tick v] to [0]\n            end\n        end\n    end\nend\nchange [speed y v] by (-1)\nchange [x v] by (speed x)\nchange [y v] by (speed y)\nPosition with Costume [9]\nif <(y) < [0]> then\n    delete this clone\nend\n\nwhen I receive [level - start game loop v]\nset [tick v] to [0]\n\nwhen I receive [level - start game loop - respawn v]\nset [tick v] to [0]\n\nwhen flag clicked\nset [type v] to []\n\ndefine Tick - Bullet Bill\nif <(FREEZE PARTICLES) = [0]> then\n    if <not <([player action v] of [mario v]) = [lose life]>> then\n        if <(frame) > [8]> then\n            go to [front v] layer\n        else\n            if <not <(frame) = [0]>> then\n                go to [back v] layer\n                go [forward v] (LAYERS - BACKGROUND) layers\n                change [frame v] by (1)\n            end\n        end\n        if <(frame) = [7]> then\n            start sound [SMA4-BulletBill v]\n        end\n    end\n    if <[300] < ([abs v] of ((x) - (CAMERA X)) )> then\n        delete this clone\n    end\n    Position with Costume (type)\n    if <not <(frame) = [0]>> then\n        if <not <([player action v] of [mario v]) = [lose life]>> then\n            set [speed y v] to [0]\n            if <(root direction) = [1]> then\n                set [speed x v] to [-4]\n            else\n                set [speed x v] to [4]\n            end\n            change [x v] by (speed x)\n            if <touching (mario v)?> then\n                if <([y v] of [mario v]) > (y)> then\n                    if <([falling v] of [mario v]) > [2]> then\n                        set [frame v] to [0]\n                        start sound [Stomped v]\n                        set [bounce player v] to [5]\n                        add [Score 100] to [particles v]\n                        add (x) to [particles v]\n                        add ((y) + (16)) to [particles v]\n                        change [score v] by (100)\n                    end\n                else\n                    broadcast (mario - hurt v)\n                end\n            end\n        end\n    end\n    if <(frame) = [0]> then\n        if <(y) < [0]> then\n            delete this clone\n        else\n            if <(root direction) = [1]> then\n                set [speed x v] to [-2]\n            else\n                set [speed x v] to [2]\n            end\n            change [speed y v] by (-1)\n            change [x v] by (speed x)\n            change [y v] by (speed y)\n        end\n    end\nend\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\nwhen I receive [mario - lose life v]\nif <<<(type) = [bullet]> or <(type) = [hammer]>> or <(type) = [spiny egg]>> then\n    set [speed x v] to [0]\n    set [speed y v] to [0]\n    stop [this script v]\nend\nif < (type) contains [bullet]?> then\n    if <(EDITOR) = [1]> then\n        delete this clone\n    end\n    Tick - Bullet Bill\n    stop [this script v]\nend\n\nwhen I receive [green flag v]\nset [frame v] to []\nset size to (200) %\nforever\n    hide\nend\n\ndefine Tick - Hammer\nif <not <(FREEZE PARTICLES) = [1]>> then\n    go to [front v] layer\n    change [speed y v] by (-1)\n    change [y v] by (speed y)\n    if <(root direction) = [1]> then\n        turn left (30) degrees\n        change [x v] by (-4)\n    else\n        turn right (30) degrees\n        change [x v] by (4)\n    end\n    if <[300] < ([abs v] of ((y) - (CAMERA Y)) )> then\n        delete this clone\n    end\n    Position with Costume [14]\n    if <touching (mario v)?> then\n        broadcast (mario - hurt v)\n    end\nend\n\ndefine Tick - Explosion\nshow\ngo to [front v] layer\nif <not <(frame) < [4]>> then\n    delete this clone\nend\nPosition with Costume ((15) + ([floor v] of ((frame) mod (4)) ))\nchange [frame v] by (0.4)\n\ndefine Tick - Spiny Egg\nif <not <(FREEZE PARTICLES) = [1]>> then\n    Position with Costume [19]\n    if <(speed y) < [20]> then\n        change [speed y v] by (-1)\n    end\n    move sprite y\n    show\n    if <(falling) = [0]> then\n        add [spiny] to [particles v]\n        add (x) to [particles v]\n        add (y) to [particles v]\n        delete this clone\n    end\n    move sprite x\n    if <(y) < [-50]> then\n        delete this clone\n    end\n    if <touching (mario v)?> then\n        broadcast (mario - hurt v)\n    end\nend\n\ndefine Tick - Spiny\nif <not <(FREEZE PARTICLES) = [1]>> then\n    Position with Costume [7]\n    change [speed y v] by (-1)\n    move sprite y\n    if <(direction) > [0]> then\n        if <(speed x) < [1]> then\n            change [speed x v] by (0.1)\n        end\n    else\n        if <(speed x) > [-1]> then\n            change [speed x v] by (-0.1)\n        end\n    end\n    move sprite x\n    change [frame v] by (0.25)\n    Position with Costume ((20) + ([floor v] of ((frame) mod (2)) ))\n    if <touching (mario v)?> then\n        broadcast (mario - hurt v)\n    end\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) + (-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    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    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) = []> or <<(tile shape) = [IB]> or <(tile shape) = [Q]>>> then\n    stop [this script v]\nend\nif <<(type) = [Podoboo]> or <(type) = [Boo]>> 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))\n    add (tile index) to [stomp indexes v]\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 move sprite x\nset [orig y v] to (y)\nchange [x v] by (speed x)\nif <not <(type) = [boo]>> then\n    fix collision in direction dx: [0] dy: [-1]\n    if <(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            if <(type) = [Boom Boom]> then\n                point in direction ([direction v] of [mario v])\n            else\n                if <<not < (type) contains [shell]?>> and <not <(type) = [Hammer Bro]>>> then\n                    turn right (180) degrees\n                else\n                    if < (type) contains [shell]?> then\n                        if <(assigned direction) = [90]> then\n                            set [assigned direction v] to [-90]\n                        else\n                            set [assigned direction v] to [90]\n                        end\n                    end\n                end\n            end\n        end\n    else\n        if <(y) > (orig y)> then\n            set [speed x v] to ((speed x) * (0.85))\n        end\n    end\nend\n\ndefine move sprite y\nchange [y v] by (speed y)\nchange [falling v] by (1)\nif <<not <(type) = [Podoboo]>> or <not <(type) = [Boo]>>> then\n    fix collision in direction dx: [0] dy: (speed y)\n    check bounce at x: ((x) - ((width) / (2))) y: (((y) - (height)) - (8))\n    check bounce at x: ((x) + ((width) / (2))) y: (((y) - (height)) - (8))\n    check bounce at x: (x) y: (((y) - (height)) - (8))\nend\nif <(solid) > [0]> then\n    if <(speed y) < [0]> then\n        set [hammer bro jumping? v] to [0]\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\ndelete all of [particles v]\n\ndefine Tick - HammerMario\nif <not <(FREEZE PARTICLES) = [1]>> then\n    set [frame v] to [0]\n    go to [front v] layer\n    change [speed y v] by (-1)\n    change [y v] by (speed y)\n    if <(root direction) = [1]> then\n        turn left (45) degrees\n        change [x v] by (-4)\n    else\n        turn right (45) degrees\n        change [x v] by (4)\n    end\n    if <[300] < ([abs v] of ((y) - (CAMERA Y)) )> then\n        delete this clone\n    end\n    Position with Costume [23]\n    if <touching (enemy v)?> then\n        broadcast (enemy kill check v)\n    end\nend\n\nwhen I receive [level - start game loop v]\ndelete this clone\n\nwhen I receive [level - start game loop - respawn v]\ndelete this clone\n\nwhen flag clicked\nset [visible v] to [1]\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\nSave - Backdrops\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 - Backdrops\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 - Backdrops\nwrite value (BACKDROP) delimiter [_]\nwrite value (AUTOSCROLL) delimiter [_]\n\ndefine Load - Backdrops\nread value\nset [backdrop v] to (value)\nread value\nset [autoscroll v] to (value)\n\nwhen [x v] key pressed\n\nwhen flag clicked\nshow list [level store v]\ndelete all of [level store v]\nwait (0.001) seconds\nadd [1_100_40_10a7z7z7z7t10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10bzzzt10z10z10z10w0_1_1_] to [level store v]\n\nwhen [n v] key pressed\nif <(EDITOR) = [1]> then\n    ask [Enter level code.] and wait\n    replace item (LEVEL #) of [level store v] with (answer)\n    broadcast (LEVEL - Load v)\nend\n\nwhen [m v] key pressed\nbroadcast (LEVEL - Save v)\nif <(EDITOR) = [1]> then\n    hide list [level store v]\n    add [Press Ctrl + a + Ctrl + c] to [a to z v]\nend\n\nwhen flag clicked\nforever\n    delete (Next.Level.) of [level store v]\nend\n\n@Backgrounds\n\nwhen I receive [load backdrop v]\nforever\n    set [costume v] to (costume [number v])\n    go to [back v] layer\n    switch costume to (black v)\n    set [screen x v] to ((x) - ((CAMERA X) / (2)))\n    set x to (((screen x) mod ((sprite width) * (2))) - (sprite width))\n    set y to (((244) - ((CAMERA Y) / (2))) + (SHAKE))\n    switch costume to (costume)\nend\n\nwhen I receive [load backdrop v]\nset [layers - background v] to [2]\nshow\ngo to [back v] layer\nswitch costume to (size 100% v)\nset size to (200) %\nset costume\nset [x v] to [0]\ncreate clone of (_myself_ v)\nnext costume\nchange [x v] by (sprite width)\n\nwhen I receive [load backdrop v]\ndelete this clone\n\nwhen I receive [next backdrop v]\ndelete this clone\n\nwhen I start as a clone\nif <(TITLE SCREEN) = [0]> then\n    set costume\n    forever\n        set [costume v] to (costume [number v])\n        go to [back v] layer\n        switch costume to (black v)\n        set [screen x v] to ((x) - ((CAMERA X) / (2)))\n        set x to (((screen x) mod ((sprite width) * (2))) - (sprite width))\n        set y to (((244) - ((CAMERA Y) / (2))) + (SHAKE))\n        switch costume to (costume)\n    end\nend\n\ndefine set costume\ngo to [back v] layer\nif <(BACKDROP) < [1]> then\n    switch costume to (background-1-1 v)\nend\nif <(BACKDROP) = [1]> then\n    switch costume to (background-1-1 v)\nend\nif <(BACKDROP) = [2]> then\n    switch costume to (background-2-1 v)\nend\nif <(BACKDROP) = [3]> then\n    switch costume to (background-3-1 v)\nend\nif <(BACKDROP) = [4]> then\n    switch costume to (background-4-1 v)\nend\nif <(BACKDROP) = [5]> then\n    switch costume to (background-5-1 v)\nend\nif <(BACKDROP) = [6]> then\n    switch costume to (background-4-1 v)\nend\nif <(BACKDROP) = [7]> then\n    switch costume to (background-7-1 v)\nend\n\nwhen I receive [green flag v]\nbroadcast (load backdrop v)\nset [sprite width v] to ((256) * ((size) / (100)))\nset [layers - background v] to [2]\nshow\ngo to [back v] layer\nswitch costume to (size 100% v)\nset size to (200) %\nset costume\nset [x v] to [0]\ncreate clone of (_myself_ v)\nnext costume\nchange [x v] by (sprite width)\n\nwhen I receive [green flag v]\nset [ghost v] effect to (100)\nwait (0) seconds\nclear graphic effects\n\nwhen I receive [green flag v]\nset [title screen v] to [0]\ndelete this clone\n\nwhen flag clicked\nhide\n\n@Thumbnail\n\nwhen flag clicked\nhide variable [coins v]\nforever\n    go to [front v] layer\n    switch costume to (thumbnail v)\n    go to x: (0) y: (0)\n    set [ghost v] effect to (100)\n    show\nend\n\nwhen flag clicked\nhide variable [backdrop v]\nhide variable [autoscroll v]\nhide variable [time v]\nhide variable [coins v]\nforever\n    set [stop sign detector v] to ((timer) + (0.1))\nend\n\nwhen [timer v] > (stop sign detector)\nhide variable [time v]\ngo to [front v] layer\nhide variable [autoscroll v]\nhide variable [coins v]\n\n@UI\n\nwhen [timer v] > (stop sign detector)\nhide\nhide variable [coins v]\nhide variable [score v]\nhide variable [level # v]\nhide variable [backdrop v]\nhide variable [auto v]\n\nwhen flag clicked\nhide\nforever\n    go to [front v] layer\nend\n\nwhen I receive [green flag v]\ngo to x: (0) y: (0)\nswitch costume to (display v)\nshow\nset size to (100) %\nforever\n    set [stop sign detector v] to ((timer) + (0.001))\n    if <(EDITOR) < [1]> then\n        show\n        hide variable [autoscroll v]\n        show variable [coins v]\n        show variable [time v]\n    else\n        hide\n        show variable [autoscroll v]\n        hide variable [coins v]\n        hide variable [score v]\n        hide variable [time v]\n    end\nend\n\nwhen I receive [entity - setup v]\nset [time v] to (SAVE TIME)\nforever\n    if <not <(TIME) < [1]>> then\n        change [time v] by (-1)\n        if <(TIME) > [90]> then\n            set [pitch v] effect to (100)\n            wait (1) seconds\n        else\n            set [pitch v] effect to (150)\n            wait (0.6) seconds\n        end\n    else\n        broadcast (mario - lose life v)\n        stop [this script v]\n    end\nend\n\nwhen flag clicked\nset [save time v] to [200]\n\n@Speed Bar\n\nwhen flag clicked\nforever\n    if <(RUN SPEED) = [9]> then\n        switch costume to (speedbar-8 v)\n        start sound [SMA4-PMeter1 v]\n        wait (0.1) seconds\n        next costume\n        start sound [SMA4-PMeter1 v]\n        wait (0.1) seconds\n    end\nend\n\nwhen flag clicked\nforever\n    if <<([level clear progress v] of [mario v]) > [0]> or <([player action v] of [mario v]) = [lose life]>> then\n        set [run speed v] to [0]\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [game v]\ngo to x: (-185) y: (-168)\nset [run speed v] to [0]\nswitch costume to (speedbar-1 v)\nforever\n    go to [front v] layer\n    if <(EDITOR) > [0]> then\n        set [run speed v] to [0]\n        hide\n    else\n        show\n        if <not <(RUN SPEED) = [9]>> then\n            switch costume to (RUN SPEED)\n            if <(RUN SPEED) = [0]> then\n                switch costume to (speedbar-1 v)\n            end\n        end\n        if <<([button b v] of [controls v]) > [0]> and <<<([speed x v] of [mario v]) > [1]> or <([speed x v] of [mario v]) < [-1]>> and <not <([player action v] of [mario v]) = [turn]>>>> then\n            if <(RUN SPEED) < [9]> then\n                change [tick v] by (1)\n                if <(tick) > [10]> then\n                    change [run speed v] by (1)\n                    set [tick v] to [0]\n                end\n            end\n        else\n            if <not <(RUN SPEED) < [1]>> then\n                if <not <([player action v] of [mario v]) = [turn]>> then\n                    change [tick v] by (1)\n                    if <(tick) > [5]> then\n                        change [run speed v] by (-1)\n                        set [tick v] to [0]\n                    end\n                else\n                    set [tick v] to [0]\n                    set [run speed v] to [0]\n                end\n            else\n                set [run speed v] to [0]\n            end\n        end\n    end\nend\n\n@HUD\n\nwhen flag clicked\nforever\n    if <(EDITOR) = [1]> then\n        change y by (((0) - (y position)) / (3))\n    else\n        change y by (((122) - (y position)) / (6))\n    end\nend\n\n@-MrGame-\n\nwhen I receive [fade v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [title screen v]\nshow\ngo to [front v] layer\nclear graphic effects\ngo to x: (-182) y: (-163)\nforever\n    if <touching (mouse-pointer v)?> then\n        change size by (((110) - (size)) / (3))\n        set [brightness v] effect to (30)\n    else\n        change size by (((100) - (size)) / (3))\n        set [brightness v] effect to (0)\n    end\nend\n\n@Button Select\n\nwhen I receive [fade v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\nwhen I receive [title screen v]\ngo to x: (-122) y: (-100)\nforever\n    if <<key (right arrow v) pressed?> and <(x position) = [0]>> then\n        change x by (122)\n        wait until <not <key (right arrow v) pressed?>>\n    end\n    if <<key (left arrow v) pressed?> and <(x position) = [-0]>> then\n        change x by (-122)\n        wait until <not <key (left arrow v) pressed?>>\n    end\n    if <<key (left arrow v) pressed?> and <(x position) = [122]>> then\n        change x by (-122)\n        wait until <not <key (left arrow v) pressed?>>\n    end\n    if <<key (right arrow v) pressed?> and <(x position) = [-122]>> then\n        change x by (122)\n        wait until <not <key (right arrow v) pressed?>>\n    end\nend\n\nwhen I receive [title screen v]\nforever\n    if <(x position) = [-122]> then\n        if <key (space v) pressed?> then\n            set [button clicked v] to [1]\n            broadcast (Fade v)\n            stop [this script v]\n        end\n    end\nend\n\nwhen I receive [title screen v]\nshow\nclear graphic effects\nset size to (100) %\nforever\n    change [timer v] by (7)\n    set size to (((2) * ([cos v] of (Timer) )) + (110)) %\nend\n\nwhen flag clicked\nhide\n\nwhen flag clicked\ngo to [front v] layer\n\n@Play Button\n\nwhen I receive [fade v]\nwait until <touching (logo v)?>\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\nwhen I receive [title screen v]\nclear graphic effects\nshow\ngo to x: (0) y: (-100)\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nforever\n    if <<touching (button select v)?> and <key (space v) pressed?>> then\n        say [Use the load button in the editor] for (2) seconds\n    end\nend\n\nwhen I receive [game v]\nstop [other scripts in sprite v]\n\n@Make\n\nwhen I receive [fade v]\nwait until <touching (logo v)?>\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nwait (0.5) seconds\nif <(Button Clicked) = [1]> then\n    broadcast (Game v)\n    repeat (10)\n        set [editor v] to [1]\n    end\nend\n\nwhen I receive [title screen v]\nclear graphic effects\nshow\ngo to x: (0) y: (-100)\n\nwhen flag clicked\nset [editor v] to [0]\nhide\n\n@Logo\n\nwhen I receive [fade v]\npoint in direction (90)\nstop [other scripts in sprite v]\nset [yvelocity v] to [0]\nrepeat (13)\n    change [yvelocity v] by (-1)\n    change y by (Yvelocity)\nend\nset [yvelocity v] to [6]\nrepeat (30)\n    change [yvelocity v] by (-1)\n    change y by (Yvelocity)\nend\nhide\nbroadcast (Hide Title background v)\nstop [this script v]\n\nwhen I receive [title screen v]\nshow\ngo to x: (0) y: (80)\nset [yvelocity v] to [0]\nset [speed v] to [0]\nforever\n    change [speed v] by (6)\n    set y to ((([sin v] of (Speed) ) * (3)) + (80))\n    point in direction ((([sin v] of (Speed) ) * (1)) + (90))\n    if <(direction) = [91]> then\n        set [speed v] to [90]\n    end\nend\n\nwhen flag clicked\nhide\n\n@? Button\n\nwhen I receive [fade v]\nwait until <touching (logo v)?>\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\nwhen I receive [title screen v]\nclear graphic effects\nshow\ngo to x: (0) y: (-100)\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nforever\n    if <<touching (button select v)?> and <key (space v) pressed?>> then\n        say (item (pick random (1) to (14)) of [tips v]) for (2) seconds\n    end\nend\n\nwhen I receive [game v]\nstop [other scripts in sprite v]\n\n@Title background\n\nwhen I receive [hide title background v]\nhide\n\nwhen I receive [title screen v]\ngo to x: (0) y: (154)\nshow\ngo to [back v] layer\nswitch costume to (pick random (1) to (6))\nif <(costume [number v]) = [4]> then\n    go to x: (0) y: (-20)\nend\n\nwhen I receive [title screen v]\nset [pitch v] effect to (0)\nforever\n    play sound [001 - Title v] until done\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [game v]\nstop [other scripts in sprite v]\n\n@Start Logo\n\nwhen flag clicked\nclear graphic effects\nshow\nplay sound [Coin v] until done\nwait (1) seconds\nbroadcast (Title Screen v)\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\n@Cursor\n\nwhen flag clicked\nforever\n    if <<(EDITOR) = [1]> and <not <mouse down?>>> then\n        go to (tiles v)\n        change x by (16)\n        change y by (-16)\n        go to [front v] layer\n        go [backward v] (3) layers\n        show\n    else\n        hide\n    end\nend\n\n@NextLevelDeleter\n\nwhen flag clicked\nforever\n    set [next.level. v] to ((LEVEL #) + (1))\nend\n\n
(CLICK THE GREEN FLAG TWICE)\n\nRelease Data: 3/5/2022\n\nInstructions:\nMovement: WASD/Arrow keys\nItems - 1-9\nJumping - Space/Up arrow\nCrouch - S/Down arrow\nThrow - Space\nEdit/Play - 0\nPowerup (only in editor) - P\nReset - R\n\nAll another instructions in the game.\n\nThanks for watching this project!