[ The Elemental Mage ] - A Platformer
@Stage\n\nwhen flag clicked\nforever\n    play sound [magic mojo2 v] until done\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [5]> then\n        change volume by (-2)\n    else\n        change volume by (2)\n    end\nend\n\n@Player\n\nwhen I receive [start v]\nset [player health v] to [15]\nshow\nforever\n    if <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n        replace item (2) of [variables v] with [-1]\n        repeat until <not <<key (a v) pressed?> or <key (left arrow v) pressed?>>>\n            if <(Using spell?) = [1]> then\n                Set attack direction\n            else\n                point in direction (-90)\n            end\n            if <(item (2) of [variables v]) > [-30]> then\n                replace item (2) of [variables v] with ((item (2) of [variables v]) - (2))\n            end\n        end\n    end\n    if <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n        replace item (2) of [variables v] with [1]\n        repeat until <not <<key (d v) pressed?> or <key (right arrow v) pressed?>>>\n            if <(Using spell?) = [1]> then\n                Set attack direction\n            else\n                point in direction (90)\n            end\n            if <(item (2) of [variables v]) < [30]> then\n                replace item (2) of [variables v] with ((item (2) of [variables v]) + (2))\n            end\n        end\n    end\nend\n\nwhen flag clicked\nset [spell power v] to [1]\nset [using spell? v] to [0]\nset [current spell v] to [Fire]\nhide\ngo to [front v] layer\nswitch costume to (standing v)\nset rotation style [left-right v]\ndelete all of [variables v]\nadd [0] to [variables v]\nadd [0] to [variables v]\nadd [0] to [variables v]\nadd (costume [name v]) to [variables v]\nadd [0] to [variables v]\nadd [0] to [variables v]\nbroadcast (START v)\n\nwhen I receive [start v]\nforever\n    if <<(item (2) of [variables v]) > [0]> or <(item (2) of [variables v]) < [0]>> then\n        replace item (1) of [variables v] with [1]\n        repeat until <not <<(item (2) of [variables v]) > [0]> or <(item (2) of [variables v]) < [0]>>>\n            if <(Using spell?) = [1]> then\n                switch costume to (spell v)\n            else\n                switch costume to (join [Run] (item (1) of [variables v]))\n            end\n            replace item (3) of [variables v] with ((item (3) of [variables v]) + (([abs v] of (item (2) of [variables v]) ) / (30)))\n            if <(item (3) of [variables v]) > [3]> then\n                replace item (3) of [variables v] with ((item (3) of [variables v]) - (3))\n                replace item (1) of [variables v] with ((item (1) of [variables v]) + (1))\n            end\n            if <(item (1) of [variables v]) > [7]> then\n                replace item (1) of [variables v] with [1]\n            end\n        end\n    else\n        if <(Using spell?) = [1]> then\n            switch costume to (spell v)\n        else\n            switch costume to (standing v)\n        end\n        replace item (1) of [variables v] with [0]\n        replace item (3) of [variables v] with [0]\n    end\nend\n\nwhen I receive [start v]\nforever\n    if <<mouse down?> and <not <<(mouse x) > [200]> and <(mouse y) > [144]>>>> then\n        set [using spell? v] to [1]\n        start sound (Current spell)\n        switch costume to (spell v)\n        broadcast (Spell v)\n        Set attack direction\n        wait (0.4) seconds\n        set [using spell? v] to [0]\n        wait until <not <mouse down?>>\n    end\nend\n\nwhen I receive [start v]\nforever\n    if <(item (2) of [variables v]) > [30]> then\n        replace item (2) of [variables v] with ((item (2) of [variables v]) - (1))\n    end\n    if <(item (2) of [variables v]) < [-30]> then\n        replace item (2) of [variables v] with ((item (2) of [variables v]) + (1))\n    end\n    if <(item (5) of [variables v]) > [125]> then\n        replace item (5) of [variables v] with ((item (5) of [variables v]) - (1))\n    end\n    if <(item (5) of [variables v]) < [-100]> then\n        replace item (5) of [variables v] with ((item (5) of [variables v]) + (1))\n    end\n    change x by ((item (2) of [variables v]) / (10))\n    Check hitbox [x]\n    change y by ((item (5) of [variables v]) / (10))\n    Check hitbox [y]\n    change y by (-4)\n    if <<touching (world v)?> and <not <<<key (a v) pressed?> or <key (d v) pressed?>> or <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>>>>> then\n        if <<(item (2) of [variables v]) > [0]> or <(item (2) of [variables v]) < [0]>> then\n            replace item (2) of [variables v] with ((item (2) of [variables v]) / (1.25))\n        end\n    end\n    if <<(item (2) of [variables v]) < [2]> and <(item (2) of [variables v]) > [-2]>> then\n        replace item (2) of [variables v] with [0]\n    end\n    change y by (4)\nend\n\ndefine Set attack direction\nif <(mouse x) < (x position)> then\n    point in direction (-90)\nelse\n    point in direction (90)\nend\n\ndefine Get out of world (lrud)\nif <(lrud) = [L]> then\n    replace item (3) of [variables v] with [0]\n    replace item (2) of [variables v] with ((item (2) of [variables v]) / (1.2))\n    repeat until <not <touching (world v)?>>\n        change x by (1)\n    end\nend\nif <(lrud) = [R]> then\n    replace item (3) of [variables v] with [0]\n    replace item (2) of [variables v] with ((item (2) of [variables v]) / (1.2))\n    repeat until <not <touching (world v)?>>\n        change x by (-1)\n    end\nend\nif <(lrud) = [U]> then\n    replace item (5) of [variables v] with [0]\n    repeat until <not <touching (world v)?>>\n        change y by (-1)\n    end\nend\nif <(lrud) = [D]> then\n    replace item (5) of [variables v] with ((item (5) of [variables v]) / (1.05))\n    if <touching (world v)?> then\n        replace item (6) of [variables v] with [1]\n        if <<<key (w v) pressed?> or <<key (up arrow v) pressed?> or <key (space v) pressed?>>> and <(Jumping) = [0]>> then\n            start sound [Beep v]\n            replace item (5) of [variables v] with [70]\n            set [jumping v] to [1]\n        end\n        repeat until <not <touching (world v)?>>\n            change y by (1)\n        end\n    end\nend\nchange y by (-1)\nSlide\nchange y by (1)\n\ndefine Check hitbox (x/y)\nreplace item (4) of [variables v] with (costume [name v])\nswitch costume to (hitbox v)\nif <(x/y) = [x]> then\n    if <touching (world v)?> then\n        change y by (1)\n        if <touching (world v)?> then\n            change y by (1)\n            if <touching (world v)?> then\n                change y by (1)\n                if <touching (world v)?> then\n                    change y by (-3)\n                    if <(item (2) of [variables v]) > [0]> then\n                        Get out of world [R]\n                    end\n                    if <(item (2) of [variables v]) < [0]> then\n                        Get out of world [L]\n                    end\n                end\n                replace item (2) of [variables v] with ((item (2) of [variables v]) / (1.05))\n            end\n            replace item (2) of [variables v] with ((item (2) of [variables v]) / (1.05))\n        end\n        replace item (2) of [variables v] with ((item (2) of [variables v]) / (1.05))\n    end\nend\nif <(x/y) = [y]> then\n    replace item (6) of [variables v] with [0]\n    if <touching (world v)?> then\n        set [jumping v] to [0]\n        replace item (6) of [variables v] with [1]\n        if <(item (5) of [variables v]) > [0]> then\n            Get out of world [U]\n        end\n        if <(item (5) of [variables v]) < [0]> then\n            Get out of world [D]\n        end\n    else\n        replace item (5) of [variables v] with ((item (5) of [variables v]) - (5))\n    end\nend\nswitch costume to (item (4) of [variables v])\nif <(Jumping) = [1]> then\n    switch costume to (jumped v)\nend\n\ndefine Slide\nchange y by (3)\nif <touching (world v)?> then\n    change y by (-3)\n    stop [this script v]\nend\nchange y by (-3)\nchange y by (-2)\nchange x by (-1)\nif <not <touching (world v)?>> then\n    replace item (2) of [variables v] with ((item (2) of [variables v]) - (10))\n    replace item (6) of [variables v] with [0]\n    set [jumping v] to [1]\n    stop [this script v]\nend\nchange x by (2)\nif <not <touching (world v)?>> then\n    replace item (2) of [variables v] with ((item (2) of [variables v]) + (10))\n    replace item (6) of [variables v] with [0]\n    set [jumping v] to [1]\n    stop [this script v]\nend\nchange y by (2)\nchange x by (-1)\n\nchange [spell power v] by (1)\n\nwhen I receive [next level v]\nstop [other scripts in sprite v]\nreplace item (2) of [variables v] with [0]\nreplace item (5) of [variables v] with [0]\ngo to x: (item (((2) * (Level)) - (1)) of [spawn points v]) y: (item ((2) * (Level)) of [spawn points v])\nbroadcast (START v)\n\nadd (x position) to [spawn points v]\nadd ((y position) + (2)) to [spawn points v]\n\nchange [level v] by (1)\nbroadcast (Next level v)\n\nchange [level v] by (-1)\nbroadcast (Next level v)\n\nwhen I receive [start v]\nforever\n    if <key (1 v) pressed?> then\n        start sound [Button Click v]\n        set [current spell v] to [Fire]\n        broadcast (Show v)\n        wait until <not <key (1 v) pressed?>>\n    end\n    if <key (2 v) pressed?> then\n        start sound [Button Click v]\n        set [current spell v] to [Ice]\n        broadcast (Show v)\n        wait until <not <key (2 v) pressed?>>\n    end\n    if <key (3 v) pressed?> then\n        start sound [Button Click v]\n        set [current spell v] to [Water]\n        broadcast (Show v)\n        wait until <not <key (3 v) pressed?>>\n    end\nend\n\n@World\n\nwhen flag clicked\nset [clone v] to [0]\nset [level v] to [1]\nbroadcast (Next level v)\n\nwhen I receive [next level v]\nif <(clone) = [0]> then\n    go to x: (0) y: (0)\n    set [ghost v] effect to (0)\n    go to [front v] layer\n    set [clone v] to [1]\n    if <(Level) = [1]> then\n        set [clone id v] to []\n        set [element phase v] to [Water]\n        switch costume to (water1 v)\n        create clone of (_myself_ v)\n    end\n    if <(Level) = [3]> then\n        set [clone id v] to []\n        set [element phase v] to [Water]\n        switch costume to (water3 v)\n        create clone of (_myself_ v)\n        set [element phase v] to [Lava]\n        switch costume to (lava3 v)\n        create clone of (_myself_ v)\n    end\n    if <(Level) = [4]> then\n        set [clone id v] to []\n        set [element phase v] to [Water]\n        switch costume to (water4 v)\n        create clone of (_myself_ v)\n        set [element phase v] to [Lava]\n        switch costume to (lava4 v)\n        create clone of (_myself_ v)\n    end\n    if <(Level) = [5]> then\n        set [clone id v] to [1]\n        set [element phase v] to [Water]\n        switch costume to (water51 v)\n        create clone of (_myself_ v)\n        set [clone id v] to [2]\n        set [element phase v] to [Ice]\n        switch costume to (ice52 v)\n        create clone of (_myself_ v)\n        set [clone id v] to []\n        set [element phase v] to [Lava]\n        switch costume to (lava5 v)\n        create clone of (_myself_ v)\n    end\n    set [clone v] to [0]\n    set [ghost v] effect to (100)\n    go to [back v] layer\n    switch costume to (join [Level] (Level))\nend\n\nwhen I start as a clone\nforever\n    check [3] [0]\n    check [-3] [0]\n    check [0] [3]\n    check [0] [-3]\nend\n\nwhen I receive [next level v]\ndelete this clone\n\ndefine check (y) (x)\ngo to x: ((0) + (x)) y: ((0) + (y))\nif <<touching (player v)?> and <[hazards v] contains (costume [name v])?>> then\n    broadcast (Next level v)\nend\nif <<touching (spells v)?> and <(Current spell) = [Fire]>> then\n    if <(Element phase) = [Water]> then\n        go to x: (0) y: (0)\n        repeat (5)\n            change [ghost v] effect by (20)\n        end\n        delete this clone\n    end\n    if <(Element phase) = [Ice]> then\n        set [element phase v] to [Water]\n    end\nend\nif <<touching (spells v)?> and <(Current spell) = [Ice]>> then\n    if <(Element phase) = [Water]> then\n        set [element phase v] to [Ice]\n    end\nend\nif <<touching (spells v)?> and <(Current spell) = [Water]>> then\n    if <(Element phase) = [Lava]> then\n        set [element phase v] to [Stone]\n    end\nend\ngo to x: (0) y: (0)\nswitch costume to (join (join (Element phase) (Level)) (Clone id))\nwait until <not <touching (spells v)?>>\n\n@Graphics\n\nwhen flag clicked\nforever\n    go to x: (0) y: (0)\n    go to [back v] layer\n    switch costume to (join [Level] (Level))\nend\n\n@Dead Floor\n\nwhen I receive [next level v]\nset size to (100) %\ngo to x: (0) y: (0)\nset [ghost v] effect to (99)\nforever\n    if <touching (player v)?> then\n        broadcast (Next level v)\n        wait (1) seconds\n    end\nend\n\n@Spells\n\nwhen flag clicked\nswitch costume to (sprite v)\nset size to (2) %\ngo to x: (0) y: (180)\n\ndefine Generate with (power)\nif <(Current spell) = [Fire]> then\n    set [splash amount v] to [8]\n    switch costume to (fire v)\n    Set speed for projectile ((13) + ((power) / (3))) [13] [1]\n    create clone of (_myself_ v)\n    if <(Spell power) > [2]> then\n        Set speed for projectile ((14) + ((power) / (3))) [14] [1]\n        create clone of (_myself_ v)\n        if <(Spell power) > [4]> then\n            Set speed for projectile ((15) + ((power) / (3))) [15] [1]\n            create clone of (_myself_ v)\n        end\n    end\nend\nif <(Current spell) = [Ice]> then\n    set [splash amount v] to [5]\n    Set speeds ((16) + ((3) * (power))) [0]\n    set [ghost v] effect to (10)\n    set size to ((50) + ((20) * (power))) %\n    switch costume to (ice v)\n    create clone of (_myself_ v)\nend\nif <(Current spell) = [Water]> then\n    set [splash amount v] to [3]\n    repeat (((3) * (power)) + (power))\n        set [ghost v] effect to (50)\n        set size to (100) %\n        set [random v] to (pick random (8.1) to (11.1))\n        Set speed for projectile ((Random) + ((power) / (5))) ((Random) + ((power) / (5))) [0]\n        Set speeds ((Random) + ((power) / (5))) (pick random (-2) to (6))\n        switch costume to (water v)\n        create clone of (_myself_ v)\n    end\nend\nset [ghost v] effect to (0)\nset size to (50) %\n\nwhen I start as a clone\nchange [x speed v] by ((item (2) of [variables v]) / (15))\nif <(item (5) of [variables v]) > [0]> then\n    change [y speed v] by ((item (5) of [variables v]) / (15))\nend\nforever\n    show\n    go to [front v] layer\n    change [y speed v] by (-1)\n    Move\n    if <<touching (world v)?> or <touching (_edge_ v)?>> then\n        if <(distance to [player v]) < [70]> then\n            change y by (-3)\n            set [clone blast x v] to (x position)\n            set [clone blast y v] to (y position)\n            point towards (player v)\n            move (1) steps\n            set [clone blast x v] to ((Clone blast x) - (x position))\n            set [clone blast y v] to ((Clone blast y) - (y position))\n            Knockback (item ((item # of (costume [name v]) in [spell power jump v]) + (1)) of [spell power jump v]) ([floor v] of (item (Spell power) of [spell power range v]) )\n        end\n        start sound (costume [name v])\n        switch costume to (join (costume [name v]) [ particle])\n        set size to (100) %\n        wait (0.025) seconds\n        delete this clone\n    end\nend\n\nwhen I receive [spell v]\nif <(costume [name v]) = [sprite]> then\n    set size to (50) %\n    go to (player v)\n    change y by (25)\n    if <(mouse x) > (x position)> then\n        change x by (5)\n    else\n        change x by (-5)\n    end\n    point towards (mouse-pointer v)\n    delete all of [positions v]\n    add (x position) to [positions v]\n    add (y position) to [positions v]\n    move (1) steps\n    replace item (1) of [positions v] with ((item (1) of [positions v]) - (x position))\n    replace item (2) of [positions v] with ((item (2) of [positions v]) - (y position))\n    move (-1) steps\n    set [x speed v] to (item (1) of [positions v])\n    set [y speed v] to (item (2) of [positions v])\n    Generate with (Spell power)\n    switch costume to (sprite v)\n    set size to (2) %\n    go to x: (0) y: (180)\nend\n\ndefine Set speeds (speed input) (y offset)\nset [x speed v] to ((X speed) * ((speed input) / (-1)))\nset [y speed v] to (((Y speed) * ((speed input) / (-0.8))) + (y offset))\n\ndefine Set speed for projectile (strength) (speedinput) (auto?)\npoint towards (mouse-pointer v)\ndelete all of [positions v]\nadd (x position) to [positions v]\nadd (y position) to [positions v]\nmove (1) steps\nreplace item (1) of [positions v] with ((item (1) of [positions v]) - (x position))\nreplace item (2) of [positions v] with ((item (2) of [positions v]) - (y position))\nmove (-1) steps\nset [x speed v] to (item (1) of [positions v])\nset [y speed v] to (item (2) of [positions v])\nif <(auto?) = [1]> then\n    Set speeds ((speedinput) + ((strength) / (5))) [0]\nend\n\ndefine Move\nrepeat (10)\n    change x by ((X speed) / (10))\n    change y by ((Y speed) / (10))\n    if <<touching (world v)?> or <touching (_edge_ v)?>> then\n        stop [this script v]\n    end\nend\n\ndefine Knockback (calculate power) (power range)\nif <(distance to [player v]) > [10]> then\n    replace item (2) of [variables v] with ((item (2) of [variables v]) + (((((calculate power) * (power range)) * (calculate power)) * (Clone blast x)) / ((distance to [player v]) / (10))))\n    replace item (5) of [variables v] with ((item (5) of [variables v]) + (((((calculate power) * (power range)) * (calculate power)) * (Clone blast y)) / ((distance to [player v]) / (10))))\nelse\n    replace item (2) of [variables v] with ((item (2) of [variables v]) + ((((calculate power) * (power range)) * (calculate power)) * (Clone blast x)))\n    replace item (5) of [variables v] with ((item (5) of [variables v]) + ((((calculate power) * (power range)) * (calculate power)) * (Clone blast y)))\nend\n\nwhen I receive [next level v]\ndelete this clone\n\n@Score\n\nwhen flag clicked\nswitch costume to (crystal v)\nshow\ngo to [front v] layer\nforever\n    change [color v] effect by (1)\nend\n\nwhen I receive [next level v]\ngo to x: (item (((3) * (Level)) - (2)) of [crystal spawns v]) y: (item (((3) * (Level)) - (1)) of [crystal spawns v])\npoint in direction (item ((3) * (Level)) of [crystal spawns v])\nwait (0.3) seconds\nforever\n    if <(Level) < [6]> then\n        show\n        if <touching (player v)?> then\n            start sound [ripple v]\n            change [level v] by (1)\n            change [spell power v] by (0.25)\n            broadcast (Next level v)\n            stop [this script v]\n        end\n    else\n        hide\n    end\nend\n\nadd (x position) to [crystal spawns v]\nadd (y position) to [crystal spawns v]\nadd (round (direction)) to [crystal spawns v]\n\n@Dangers\n\nwhen I start as a clone\nset rotation style [left-right v]\nclear graphic effects\nif <(danger type) = [Flying]> then\n    set [costume v] to [1]\n    forever\n        point towards (player v)\n        go to [front v] layer\n        change [costume v] by (1)\n        switch costume to (join (type2) (costume))\n        if <((costume) + (1)) > (amount of frames)> then\n            set [costume v] to [1]\n        end\n        if <(health) < [1]> then\n            set rotation style [all around v]\n            repeat (20)\n                change [brightness v] effect by (5)\n                change [ghost v] effect by (5)\n                turn right (15) degrees\n                move (4) steps\n                change x by (x speed)\n                change y by (y speed)\n            end\n            delete this clone\n        end\n    end\nend\n\nwhen I start as a clone\nforever\n    if <touching (spells v)?> then\n        set [damage hit by v] to (item ((item # of (Current spell) in [spell damage v]) + (1)) of [spell damage v])\n        if <(damage hit by) > [11]> then\n            start sound [hit3 v]\n        else\n            if <(damage hit by) > [4]> then\n                start sound [hit2 v]\n            else\n                start sound [hit1 v]\n            end\n        end\n        change [health v] by ((0) - (damage hit by))\n        set [damage hit by v] to (((damage hit by) * ((2) * (item ((item # of (Current spell) in [spell damage v]) + (1)) of [spell power jump v]))) / (round ((size) / (25))))\n        if <(x position) > ([x position v] of [player v])> then\n            change [x speed v] by (damage hit by)\n        else\n            change [x speed v] by ((0) - (damage hit by))\n        end\n        if <(y position) > ([y position v] of [player v])> then\n            change [y speed v] by (damage hit by)\n        else\n            change [y speed v] by ((0) - (damage hit by))\n        end\n        wait (0.1) seconds\n    end\nend\n\nwhen I start as a clone\nset [x speed v] to [0]\nset [y speed v] to [0]\nforever\n    if <(danger type) = [Flying]> then\n        if <not <(Boss Charge Count) = [3]>> then\n            move [x]\n            move [y]\n            Change position\n            if <(Hitting wall counter) > [10]> then\n                set [hitting wall counter v] to [0]\n                repeat (pick random (8) to (10))\n                    if <(x position) > ([x position v] of [player v])> then\n                        change [x speed v] by (0.5)\n                    else\n                        change [x speed v] by (-0.5)\n                    end\n                    if <(y position) > ([y position v] of [player v])> then\n                        change [y speed v] by (-0.5)\n                    else\n                        change [y speed v] by (0.5)\n                    end\n                    Change position\n                end\n            end\n            if <<([abs v] of (x speed) ) < [1]> and <([abs v] of (y speed) ) < [1]>> then\n                change [hitting wall counter v] by (0.25)\n            end\n        end\n    end\nend\n\ndefine move (x/y)\nif <(distance to [player v]) < [150]> then\n    move (-1) steps\n    if <touching (world v)?> then\n        move (1) steps\n    end\nend\nif <(x/y) = [x]> then\n    if <(([x position v] of [player v]) + (150)) < (x position)> then\n        change [x speed v] by (-0.1)\n        stop [this script v]\n    end\n    if <(([x position v] of [player v]) - (150)) > (x position)> then\n        change [x speed v] by (0.1)\n        stop [this script v]\n    end\n    set [x speed v] to ((x speed) / (1.1))\nend\nif <(x/y) = [y]> then\n    if <(([y position v] of [player v]) + (150)) < (y position)> then\n        change [y speed v] by (-0.1)\n        stop [this script v]\n    end\n    if <(([y position v] of [player v]) - (150)) > (y position)> then\n        change [y speed v] by (0.1)\n        stop [this script v]\n    end\n    set [y speed v] to ((y speed) / (1.1))\nend\n\nwhen I receive [next level v]\nwait (0.1) seconds\nshow\nset size to (70) %\nset [amount of frames v] to [6]\nset [danger type v] to [Flying]\nset [type2 v] to [bat]\nset [health v] to [15]\nif <(Level) = [2]> then\n    go to x: (200) y: (160)\n    create clone of (_myself_ v)\nend\nif <(Level) = [3]> then\n    go to x: (200) y: (160)\n    create clone of (_myself_ v)\n    go to x: (100) y: (100)\n    create clone of (_myself_ v)\nend\nif <(Level) = [4]> then\n    go to x: (-203) y: (140)\n    create clone of (_myself_ v)\n    go to x: (155) y: (-12)\n    create clone of (_myself_ v)\n    go to x: (-30) y: (-30)\n    create clone of (_myself_ v)\nend\nif <(Level) = [5]> then\n    go to x: (191) y: (138)\n    create clone of (_myself_ v)\n    go to x: (-25) y: (95)\n    create clone of (_myself_ v)\n    go to x: (87) y: (81)\n    set [amount of frames v] to [6]\n    set [danger type v] to [Flying]\n    set [type2 v] to [bat]\n    set [health v] to [150]\n    set size to (150) %\n    create clone of (_myself_ v)\nend\nhide\n\nwhen I receive [next level v]\ndelete this clone\n\nwhen I start as a clone\nset [boss charge count v] to [0]\nforever\n    if <(danger type) = [Flying]> then\n        wait (1.5) seconds\n        if <(size) < [100]> then\n            if <(health) > [0]> then\n                point towards (player v)\n                shoot with (direction) [5] [6]\n            end\n        end\n        if <(size) > [110]> then\n            if <(Boss Charge Count) = [3]> then\n                set [boss charge count v] to [0]\n                set [player old x v] to ([x position v] of [player v])\n                set [player old y v] to ([y position v] of [player v])\n                point towards (player v)\n                start sound [power v]\n                repeat (5)\n                    change [brightness v] effect by (20)\n                end\n                repeat (10)\n                    change [brightness v] effect by (-10)\n                end\n                wait (0.75) seconds\n                set [charging v] to [1]\n                Charge (x position) (y position) (Player old x) (Player old y)\n            else\n                change [boss charge count v] by (1)\n                shoot with ((direction) + (15)) [3] [8]\n                shoot with (direction) [3] [8]\n                shoot with ((direction) - (15)) [3] [8]\n            end\n        end\n        wait (0.25) seconds\n    end\nend\n\ndefine shoot with (direction) (damage) (speed)\nadd (x position) to [danger projectiles v]\nadd (y position) to [danger projectiles v]\nadd (direction) to [danger projectiles v]\nadd (damage) to [danger projectiles v]\nadd (speed) to [danger projectiles v]\nadd [bat] to [danger projectiles v]\n\ndefine Charge (old x) (old y) (px) (py)\nstart sound [Charge v]\nrepeat until <<(round (x position)) = (round (px))> and <(round (y position)) = (round (py))>>\n    change x by (((px) - (x position)) / (6))\n    change y by (((py) - (y position)) / (6))\nend\nset [charging v] to [0]\nrepeat until <<(round (x position)) = (round (old x))> and <(round (y position)) = (round (old y))>>\n    change x by (((old x) - (x position)) / (12))\n    change y by (((old y) - (y position)) / (12))\nend\n\nwhen I start as a clone\nforever\n    if <(Charging) = [1]> then\n        if <touching (player v)?> then\n            change [player health v] by (-10)\n            replace item (5) of [variables v] with [100]\n            if <(x position) > ([x position v] of [player v])> then\n                replace item (2) of [variables v] with [-45]\n            else\n                replace item (2) of [variables v] with [45]\n            end\n            wait until <not <touching (player v)?>>\n        end\n    end\nend\n\ndefine Change position\nchange x by (x speed)\nif <touching (world v)?> then\n    change x by ((x speed) / (-1))\n    set [x speed v] to ((x speed) / (3))\nend\nchange y by (y speed)\nif <touching (world v)?> then\n    change y by ((y speed) / (-1))\n    set [y speed v] to ((y speed) / (3))\nend\n\n@Projectiles\n\nwhen flag clicked\nhide\nforever\n    go to [front v] layer\n    if <(length of [danger projectiles v]) > [0]> then\n        set x to (item (1) of [danger projectiles v])\n        delete (1) of [danger projectiles v]\n        set y to (item (1) of [danger projectiles v])\n        delete (1) of [danger projectiles v]\n        point in direction (item (1) of [danger projectiles v])\n        delete (1) of [danger projectiles v]\n        set [projectile damage v] to (item (1) of [danger projectiles v])\n        delete (1) of [danger projectiles v]\n        set [projectile speed v] to (item (1) of [danger projectiles v])\n        delete (1) of [danger projectiles v]\n        switch costume to (item (1) of [danger projectiles v])\n        delete (1) of [danger projectiles v]\n        show\n        create clone of (_myself_ v)\n        hide\n    end\nend\n\nwhen I start as a clone\nforever\n    move (Projectile speed) steps\n    if <touching (player v)?> then\n        start sound [hit v]\n        change [player health v] by ((0) - (projectile damage))\n        if <(x position) > ([x position v] of [player v])> then\n            replace item (2) of [variables v] with ((item (2) of [variables v]) - ((2) * (projectile damage)))\n        else\n            replace item (2) of [variables v] with ((item (2) of [variables v]) + ((2) * (projectile damage)))\n        end\n        if <(y position) > ([y position v] of [player v])> then\n            replace item (5) of [variables v] with ((item (5) of [variables v]) - ((2) * (projectile damage)))\n        else\n            replace item (5) of [variables v] with ((item (5) of [variables v]) + ((2) * (projectile damage)))\n        end\n        delete this clone\n    end\n    if <<<touching (_edge_ v)?> or <touching (world v)?>> or <<touching (spells v)?> and <(Current spell) = [Water]>>> then\n        delete this clone\n    end\nend\n\n@Reset\n\nwhen flag clicked\ngo to x: (219) y: (161)\ngo to [front v] layer\nforever\n    if <(Level) < [6]> then\n        show\n        if <touching (mouse-pointer v)?> then\n            set size to (110) %\n            next costume\n            if <mouse down?> then\n                start sound [Reset v]\n                broadcast (Next level v)\n                wait until <not <mouse down?>>\n            end\n        else\n            set size to (100) %\n            switch costume to (reset1 v)\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Player Health) < [1]> then\n        broadcast (Next level v)\n        wait (1) seconds\n    end\nend\n\n@Timer\n\nwhen flag clicked\nerase all\nreset timer\nhide\nwait (1) seconds\nwait until <(Level) = [6]>\nset [your time v] to ([floor v] of (timer) )\nif <(your time) < (☁ Best time)> then\n    set [☁ best time v] to (your time)\nend\nGenerate (join ([floor v] of ((your time) / (60)) ) (join [ : ] (round ((((your time) / (60)) - ([floor v] of ((your time) / (60)) )) * (60))))) at [0] and [34]\nGenerate (join ([floor v] of ((☁ Best time) / (60)) ) (join [ : ] (round ((((☁ Best time) / (60)) - ([floor v] of ((☁ Best time) / (60)) )) * (60))))) at [2] and [3]\n\ndefine Generate (text) at (x) and (y)\nshow\ngo to x: (x) y: (y)\nset [i v] to [0]\nrepeat (length of (text))\n    change [i v] by (1)\n    switch costume to (letter (i) of (text))\n    stamp\n    change x by (item (costume [number v]) of [space v])\nend\nhide\n\nset [☁ best time v] to [600]\n\n@Selected spell\n\nwhen flag clicked\nshow\nchange [ghost v] effect by (100)\nforever\n    go to [front v] layer\n    set size to (1000) %\n    go to x: ([x position v] of [player v]) y: (([y position v] of [player v]) + (80))\n    set size to (100) %\n    switch costume to (Current spell)\n    if <(show timer) > [0]> then\n        change [ghost v] effect by (-20)\n        change [show timer v] by (-1)\n    else\n        change [ghost v] effect by (10)\n    end\nend\n\nwhen I receive [show v]\nset [show timer v] to [100]\n\nhide\n\n@Thumbnail\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\nset volume to (0) %\nforever\n    go to [front v] layer\n    play sound [magic mojo1 v] until done\n    if <(Level) = [5]> then\n        change volume by (2)\n    else\n        change volume by (-2)\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [5]> then\n        change volume by (2)\n    else\n        change volume by (-2)\n    end\nend\n\n@L F reminder\n\nwhen flag clicked\ngo to x: (-236) y: (176)\nhide\nwait (5) seconds\nPop up\nforever\n    wait (45) seconds\n    Pop up\nend\n\ndefine Pop up\nstart sound [bubble v]\nshow\nset size to (15) %\nrepeat until <(size) > [99]>\n    change size by (([abs v] of ((size) - (100)) ) / (15))\nend\nwait (2) seconds\nrepeat until <(size) > [110]>\n    change size by (([abs v] of (((size) - (15)) - (100)) ) / (10))\nend\nrepeat until <(size) < [16]>\n    change size by ((((size) - (15)) - (100)) / (10))\nend\nhide\n\n
Update: Minor graphic improvements and boss charge attack smoothing.\n\nWelcome to the elemental mage!\n\n WASD / Arrows keys to move.\n Click to cast spells and press 1, 2 and 3 to change it.\n 1 = Fire   2 = Ice   3 = Water\n\nI wanted to make a platformer but with different features that no other scratch game has. You can use spells to move in very unique ways.\n\nCREDITS\n All scripts, sound effects and art by me.\n Music from 'The Wizard and the Magic Mojos'.\n\nWant more adventure? Try playing Marooned Survival!\nhttps://scratch.mit.edu/projects/620633300/