Gandalf | Platformer
@Stage\n\nwhen I receive [tick v]\ndelete all of [items v]\nadd (join (join [Mouse: \(] ((*SCROLL X) + (mouse x))) (join [, ] (join (mouse y) [\)]))) to [items v]\nadd (join (join [Player: \(] ([x v] of [platformer script v])) (join [, ] (join ([y v] of [platformer script v]) [\)]))) to [items v]\nif <<([start run? v] of [platformer script v]) = [1]> and <(End) = [0]>> then\n    change [timer v] by (0.03)\nend\n\nwhen I receive [stop music v]\nstop [other scripts in sprite v]\n\nwhen flag clicked\nset [timer v] to [0]\nforever\n    play sound [\[Minecraft\] C418 - Boss \(boss v] until done\nend\n\n@Blank\n\nbroadcast (Reset Data v)\n\n@Level\n\nwhen I receive [tick v]\nPosition ((x) - (*SCROLL X))\n\nwhen I receive [set up v]\nshow\nset [x v] to [-480]\nswitch costume to (1 v)\nClone\n\ndefine Position (x)\nset [costume v] to (costume [number v])\nswitch costume to (1 v)\nset size to ((1) / ()) %\ngo to x: (x) y: (0)\nswitch costume to (costume)\nset size to (100) %\nif <([abs v] of (x position) ) > [480]> then\n    hide\nelse\n    show\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\ndefine Clone\nrepeat (2)\n    Clone at x: [480] y: [0]\nend\n\n@Platformer Script\n\nwhen flag clicked\nhide\ngo to [front v] layer\nbroadcast (Play Game v) and wait\n\nwhen I receive [play game v]\nset [level v] to [1]\nGame On\nbroadcast (Reset v) and wait\nbroadcast (Set up v) and wait\nbroadcast (Setup 2 v)\nforever\n    Game On\n    broadcast (Reset v) and wait\n    broadcast (Set up v) and wait\n    broadcast (Setup 2 v)\n    repeat until <(EXIT) > []>\n        Tick\n        broadcast (Tick v) and wait\n    end\n    set [start run? v] to [0]\n    if <(EXIT) = [Win]> then\n        broadcast (Win Screen v)\n    else\n        Game - Die\n    end\nend\n\ndefine Game On\nset [*scroll x v] to [0]\nset [x v] to [-150]\nset [y v] to [-76]\nset [sx v] to [0]\nset [sy v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nset [health v] to [20]\nset [player knockback v] to [0]\nset [invisibility v] to [0]\nset [start run? v] to [0]\nPosition\npoint in direction (90)\nset volume to (100) %\nset size to (40) %\nclear graphic effects\nshow\n\ndefine Tick\nswitch costume to (1 v)\nset rotation style [don't rotate v]\nif <(Player Knockback) = [0]> then\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        point in direction (90)\n        change [sx v] by (2)\n        set [start run? v] to [1]\n    end\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        point in direction (-90)\n        change [sx v] by (-2)\n        set [start run? v] to [1]\n    end\n    set [sx v] to ((sx) * (0.8))\nend\nif <([abs v] of (sx) ) > [0.9]> then\n    Change Player x by (round (sx))\nend\nif <(Player Knockback) = [0]> then\n    if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n        set [start run? v] to [1]\n        if <(in air) < [4]> then\n            set [sy v] to [16]\n        end\n    end\nend\nif <(sy) > [-20]> then\n    change [sy v] by (-2)\nend\nChange player y by (sy)\nPosition\nif <(*SCROLL X) < [480]> then\n    set [*scroll x v] to (x)\nend\nif <(*SCROLL X) < [0]> then\n    set [*scroll x v] to [0]\nend\nif <(*SCROLL X) > [480]> then\n    set [*scroll x v] to [480]\nend\nif <(*SCROLL X) = [480]> then\n    if <(x) < [240]> then\n        set [x v] to [240]\n    end\nend\nif <(x) < [-240]> then\n    set [x v] to [-240]\nend\nif <(x) > [720]> then\n    set [x v] to [720]\nend\nset rotation style [left-right v]\nPosition\nif <(End) = [0]> then\n    if <<<(y) < [-180]> or <(Health) < [1]>> and <(Start Run?) = [1]>> then\n        set [exit v] to [Die]\n    end\n    if <(Invisibility) = [0]> then\n        if <<touching (enderdragon v)?> and <(Player Knockback) = [0]>> then\n            set [player knockback v] to [1]\n            if <(Invisibility) = [0]> then\n                set [invisibility v] to [1]\n                set [sy v] to [10]\n                set [sx v] to ((Hit) / (-15))\n            end\n        end\n        if <touching (fireball v)?> then\n            set [invisibility v] to [40]\n            broadcast (Hurt v)\n            start sound [Hurt v]\n            change [health v] by (-2)\n        end\n    end\n    if <(Player Knockback) = [1]> then\n        if <(in air) = [0]> then\n            set [player knockback v] to [0]\n        end\n    end\n    if <(Invisibility) > [0]> then\n        set [ghost v] effect to (20)\n        if <(Invisibility) = [2]> then\n            broadcast (Hurt v)\n            start sound [Hurt v]\n            change [health v] by (-4)\n        end\n        change [invisibility v] by (1)\n        if <(Invisibility) > [50]> then\n            set [invisibility v] to [0]\n        end\n    else\n        set [ghost v] effect to (0)\n    end\nelse\n    set [player knockback v] to [0]\n    set [invisibility v] to [0]\nend\nif <<(Player Knockback) = [0]> and <not <touching (fireball v)?>>> then\n    switch costume to (2 v)\nelse\n    switch costume to (3 v)\nend\nif <(End) = [1]> then\n\ndefine Change player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nPosition\nrepeat until <not <touching (level v)?>>\n    if <(sy) > [0]> then\n        change [y v] by (-1)\n    else\n        change [y v] by (1)\n        set [in air v] to [0]\n    end\n    Position\n    set [sy v] to [0]\nend\n\ndefine Position\ngo to x: ((x) - (*SCROLL X)) y: (y)\n\ndefine Change Player x by (sx)\nchange [x v] by (sx)\nPosition\nif <touching (level v)?> then\n    repeat (12)\n        change [y v] by (1)\n        Position\n        if <not <touching (level v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    repeat until <not <touching (level v)?>>\n        if <(sx) > [0]> then\n            change [x v] by (-1)\n        else\n            change [x v] by (1)\n        end\n        Position\n    end\nend\n\ndefine Game - Die\nbroadcast (Dead v)\nset [exit v] to []\nrepeat (5)\n    hide\n    wait (0.1) seconds\n    show\n    wait (0.1) seconds\nend\nhide\nwait (0.5) seconds\n\ndefine Game Win\nrepeat (50)\n    point towards (exit v)\n    turn right (65) degrees\n    move ((distance to [exit v]) / (2)) steps\n    change size by (-1)\n    change [ghost v] effect by (2)\nend\nhide\nchange [level v] by (1)\nwait (1) seconds\n\nwhen I receive [win screen v]\nstop [other scripts in sprite v]\n\n@Background\n\nwhen I receive [grenn flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((x) - (*SCROLL X))\n\nwhen I receive [set up v]\nshow\nset [x v] to [-480]\nset [y v] to [0]\nswitch costume to (1 v)\nClone\n\ndefine Position (x)\nset [costume v] to (costume [number v])\nswitch costume to (1 v)\nset size to ((1) / ()) %\ngo to x: (x) y: (0)\nswitch costume to (costume)\nset size to (100) %\nset [brightness v] effect to (-12)\nif <([abs v] of (x position) ) > [480]> then\n    hide\nelse\n    show\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\ndefine Clone\nrepeat (2)\n    Clone at x: [480] y: [0]\nend\n\n@Sword\n\nwhen I receive [tick v]\nif <([direction v] of [platformer script v]) = [90]> then\n    go to x: (([x position v] of [platformer script v]) + (44)) y: (([y position v] of [platformer script v]) + ((7) + ((Direction) / (-3))))\n    point in direction ((Direction) + (90))\n    switch costume to (1 v)\nelse\n    go to x: (([x position v] of [platformer script v]) + (-44)) y: (([y position v] of [platformer script v]) + ((7) + ((Direction) / (-3))))\n    point in direction ((90) - (Direction))\n    switch costume to (2 v)\nend\nif <([invisibility v] of [platformer script v]) > [0]> then\n    set [ghost v] effect to (20)\nelse\n    set [ghost v] effect to (0)\nend\nif <<(-Love Project) = [1]> and <(-Favorite Project) = [1]>> then\n    switch costume to ((costume [number v]) + (2))\nend\n\nwhen I receive [set up v]\nshow\n\nwhen flag clicked\nshow\nset size to (30) %\nset [direction v] to [0]\nforever\n    if <<key (space v) pressed?> or <<key (x v) pressed?> or <key (m v) pressed?>>> then\n        set [attack v] to [1]\n        repeat (5)\n            change [direction v] by (12)\n        end\n        repeat (2)\n            change [direction v] by (-24)\n        end\n        set [attack v] to [0]\n        set [direction v] to [0]\n        wait (0.4) seconds\n        wait until <not <<key (space v) pressed?> or <<key (x v) pressed?> or <key (m v) pressed?>>>>\n    end\nend\n\nwhen I receive [dead v]\nrepeat (5)\n    hide\n    wait (0.1) seconds\n    show\n    wait (0.1) seconds\nend\nhide\nwait (0.5) seconds\n\n@Hitbox\n\nwhen I receive [tick v]\nset size to (25) %\nif <([direction v] of [platformer script v]) = [90]> then\n    go to x: (([x position v] of [platformer script v]) + (44)) y: (([y position v] of [platformer script v]) + (3))\nelse\n    go to x: (([x position v] of [platformer script v]) + (-44)) y: (([y position v] of [platformer script v]) + (3))\nend\nif <([attack v] of [sword v]) = [0]> then\n    hide\nelse\n    show\nend\nset [ghost v] effect to (100)\n\n@Health\n\nwhen I receive [tick v]\nswitch costume to ((([health v] of [platformer script v]) / (2)) + (1))\n\nwhen I receive [hurt v]\nset [brightness v] effect to (100)\nwait (0.1) seconds\nset [brightness v] effect to (0)\n\nwhen I receive [dead v]\nif <([health v] of [platformer script v]) > [0]> then\n    start sound [hurt v]\nend\nset [brightness v] effect to (100)\nwait (0.1) seconds\nswitch costume to (health0 v)\nset [brightness v] effect to (0)\n\nwhen I receive [win screen v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\n@Thumbnail\n\nwhen flag clicked\nset [ghost v] effect to (100)\nforever\n    go to [front v] layer\nend\n\n@Win Screen\n\nwhen flag clicked\nhide\n\nwhen I receive [win screen v]\nshow\nswitch costume to (2 v)\nset [ghost v] effect to (100)\ngo to [front v] layer\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\n\nwhen I receive [win screen v]\nplay sound [Win v] until done\n\n@Text\n\ndefine Write Text (text) Type (type)\nif <(type) = [0]> then\n    go to x: (-165) y: (156)\n    set [i v] to [1]\nelse\n    go to x: (185) y: (156)\n    set [i v] to (length of (text))\nend\nrepeat (length of (text))\n    switch costume to (letter (i) of (text))\n    if <(type) = [0]> then\n        change [i v] by (1)\n        create clone of (_myself_ v)\n        change x by (14)\n    else\n        change [i v] by (-1)\n        create clone of (_myself_ v)\n        change x by (-14)\n    end\nend\nif <(type) = [1]> then\n    change x by (-60)\n    switch costume to (enderdragon v)\n    create clone of (_myself_ v)\n    go to x: (215) y: (156)\n    switch costume to (hp v)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nshow\n\nwhen I receive [delete text v]\ndelete this clone\n\nwhen I receive [tick v]\nset size to (70) %\nbroadcast (Delete Text v)\nif <(Timer) = [0]> then\n    Write Text [0] Type [0]\nelse\n    Write Text (join ([floor v] of (Timer) ) (join [.] (letter ((length of ([floor v] of (Timer) )) + (2)) of (Timer)))) Type [0]\nend\ngo to x: (-200) y: (156)\nswitch costume to (time v)\n\nwhen I receive [enderdragon dead v]\nset [actual time v] to (join ([floor v] of (Timer) ) (join [.] (letter ((length of ([floor v] of (Timer) )) + (2)) of (Timer))))\n\n@Enderdragon\n\nwhen I receive [tick v]\nset size to (70) %\nif <(*SCROLL X) = [480]> then\n    if <(*Enderdragon Health) = [0]> then\n        change y by (0.3)\n        change [tick v] by (1)\n        if <(Tick) > [250]> then\n            change [ghost v] effect by (10)\n        end\n    else\n        if <(Perch) = [0]> then\n            Move 1\n        else\n            Move 2\n        end\n        if <<(-Invisibility) = [0]> and <touching (hitbox v)?>> then\n            set [-invisibility v] to [1]\n            change [*enderdragon health v] by (-10)\n            start sound (pick random (1) to (3))\n        end\n        if <(-Invisibility) > [0]> then\n            change [-invisibility v] by (1)\n            if <(-Invisibility) = [20]> then\n                set [-invisibility v] to [0]\n            end\n        end\n        Animate\n        if <((Sound) mod (35)) = [0]> then\n            start sound [Ender dragon sounds \(My most viewed video\)2 v]\n        end\n        change [sound v] by (1)\n        if <((Sound) mod (200)) = [199]> then\n            start sound (pick random (6) to (8))\n        end\n    end\nend\n\nwhen I receive [setup 2 v]\nhide\nwait until <(*SCROLL X) = [480]>\nstart sound [Ender dragon sounds \(My most viewed video\)5 v]\nshow\nReset\nwait until <(*Enderdragon Health) = [0]>\nbroadcast (Enderdragon Dead v)\nstart sound [Ender dragon sounds \(My most viewed video\)3 v]\ncreate clone of (effects v)\nset [tick v] to [0]\nset [end v] to [1]\nwait (10) seconds\nbroadcast (Win Screen v)\n\nwhen flag clicked\nset [end v] to [0]\nset [*enderdragon health v] to [200]\nReset\n\ndefine Reset\ngo to x: (416) y: (130)\nset rotation style [left-right v]\nset [tick v] to [0]\nset [tick 2 v] to [0]\nset [perch v] to [0]\nset [-invisibility v] to [0]\nset [sound v] to [0]\n\nwhen I receive [reset v]\nhide\n\ndefine Animate\nif <(-Invisibility) > [0]> then\n    if <(*Enderdragon Health) = [0]> then\n        switch costume to ((([floor v] of ((timer) * (20)) ) mod (15)) + (1))\n    else\n        switch costume to ((([floor v] of ((timer) * (20)) ) mod (15)) + (16))\n    end\nelse\n    switch costume to ((([floor v] of ((timer) * (20)) ) mod (15)) + (1))\nend\n\ndefine Move 1\nif <(x position) > [150]> then\n    set [direction v] to [1]\nend\nif <(x position) < [-150]> then\n    set [direction v] to [0]\nend\nif <(Direction) = [1]> then\n    change x by (-4)\n    point in direction (90)\nelse\n    change x by (4)\n    point in direction (-90)\nend\nif <(*Enderdragon Health) < [101]> then\n    if <(Tick) > [75]> then\n        create clone of (fireball v)\n        set [tick v] to [0]\n    end\nelse\n    if <(Tick) > [120]> then\n        create clone of (fireball v)\n        set [tick v] to [0]\n    end\nend\nchange [tick v] by (1)\nchange [tick 2 v] by (1)\nif <(Tick 2) > [399]> then\n    set [tick v] to [1]\n    set [perch v] to [1]\n    set [x movement v] to ((x position) / (-30))\nend\n\ndefine Move 2\nif <(Tick) < [30]> then\n    change x by (X Movement)\n    change y by ((130) / (-30))\n    if <(x position) < [0]> then\n        point in direction (-90)\n    else\n        point in direction (90)\n    end\nelse\n    if <(Tick) = [250]> then\n        if <([x position v] of [platformer script v]) > (x position)> then\n            set [direction v] to [1]\n        else\n            set [direction v] to [0]\n        end\n    end\n    if <(Tick) > [250]> then\n        if <(Direction) = [1]> then\n            change x by (5)\n            point in direction (90)\n        else\n            change x by (-5)\n            point in direction (-90)\n        end\n        change y by ((130) / (30))\n        if <(Tick) = [280]> then\n            set [tick v] to [1]\n            set [tick 2 v] to [0]\n            set [perch v] to [0]\n        end\n    else\n        point towards (platformer script v)\n        turn right (180) degrees\n        set [hit v] to (direction)\n    end\nend\nchange [tick v] by (1)\n\n@Fireball\n\nwhen I start as a clone\nshow\ngo to (enderdragon v)\npoint towards (platformer script v)\nstart sound [2 v]\nset [fireball v] to [0]\n\nwhen I receive [tick v]\nif <(Fireball) = [0]> then\n    switch costume to (1 v)\n    change x by (([sin v] of (direction) ) * (10))\n    change y by (([cos v] of (direction) ) * (10))\n    if <touching (level v)?> then\n        set [fireball v] to [1]\n        start sound [1 v]\n    end\nelse\n    point in direction (90)\n    switch costume to (2 v)\n    change [fireball v] by (1)\n    if <(Fireball) > [65]> then\n        change [ghost v] effect by (10)\n    end\n    if <(Fireball) > [75]> then\n        delete this clone\n    end\nend\n\nwhen I receive [reset v]\ndelete this clone\n\n@Effects\n\nwhen flag clicked\nhide\n\nwhen I receive [tick v]\nif <(Tick) < [21]> then\n    change [ghost v] effect by (-5)\nend\ngo to (enderdragon v)\ngo to [back v] layer\nturn right (1) degrees\nchange [tick v] by (1)\nif <(Tick) > [250]> then\n    change [ghost v] effect by (10)\nend\n\nwhen I start as a clone\nset [tick v] to [0]\nset [ghost v] effect to (100)\nshow\n\n@Text 2\n\ndefine Write Text (text) Type (type)\nset [i v] to (length of (text))\nif <(type) = [1]> then\n    go to x: (((170) + ((length of (text)) * (20))) / (2)) y: (-145)\nend\nif <(type) = [2]> then\n    go to x: (((120) + ((length of (text)) * (20))) / (2)) y: (-110)\nend\nif <(type) = [3]> then\n    go to x: (((120) + ((length of (text)) * (20))) / (2)) y: (-75)\nend\nrepeat (length of (text))\n    switch costume to (letter (i) of (text))\n    change [i v] by (-1)\n    create clone of (_myself_ v)\n    change x by (-20)\nend\nif <(type) = [1]> then\n    change x by (-85)\nend\nif <(type) = [2]> then\n    change x by (-60)\nend\nif <(type) = [3]> then\n    change x by (-60)\nend\nswitch costume to ((type) + (11))\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nshow\nset [ghost v] effect to (100)\ngo to [front v] layer\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\n\nwhen I receive [win screen v]\nWrite Text (Actual Time) Type [3]\nWrite Text (☁ Complete) Type [2]\nWrite Text (☁ World Record) Type [1]\n\nwhen flag clicked\nhide\n\nwhen I receive [enderdragon dead v]\nchange [☁ complete v] by (1)\nwait (0.1) seconds\nif <(Actual Time) < (☁ World Record)> then\n    set [☁ world record v] to (Actual Time)\nend\n\nset [☁ complete v] to [0]\nset [☁ world record v] to [1000]\n\nwhen flag clicked\n\nif <(First) = [1]> then\n    stop [this script v]\nend\nshow\ngo to x: (0) y: (0)\nif <<(-Love Project) = [1]> and <(-Favorite Project) = [1]>> then\n    switch costume to (instructions 2 v)\nelse\n    switch costume to (instructions v)\nend\nset [ghost v] effect to (100)\ngo to [front v] layer\nrepeat (10)\n    change [ghost v] effect by (-10)\n    go to [front v] layer\nend\nwait (2) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\nif <<(-Love Project) = [1]> and <(-Favorite Project) = [1]>> then\n    set [first v] to [1]\nend\n\nwhen I receive [reset data v]\nset [first v] to [0]\n\n@Love and Favorite\n\nwhen flag clicked\nhide\n\nif <<(-Love Project) = [1]> and <(-Favorite Project) = [1]>> then\n    stop [this script v]\nend\nset [-favorite project v] to [0]\nset [-love project v] to [0]\nset [-detector clone v] to [0]\ncreate clone of (_myself_ v)\nwait (0.2) seconds\nset [-detector clone v] to [1]\ncreate clone of (_myself_ v)\nwait until <<(-Love Project) = [1]> and <(-Favorite Project) = [1]>>\nshow\nstart sound [Collect v]\nswitch costume to (1 v)\ngo to x: (0) y: (30)\nset [ghost v] effect to (100)\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nwait (2) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\nwhen I start as a clone\nif <(-Detector Clone) = [0]> then\n    go to x: (-15) y: (0)\n    switch costume to (love v)\n    forever\n        if <touching (mouse-pointer v)?> then\n            set [-love project v] to [1]\n        end\n    end\nend\nif <(-Detector Clone) = [1]> then\n    go to x: (0) y: (0)\n    switch costume to (fave v)\n    forever\n        if <touching (mouse-pointer v)?> then\n            set [-favorite project v] to [1]\n        end\n    end\nend\n\nwhen I receive [reset data v]\nset [-love project v] to [0]\nset [-favorite project v] to [0]\n\n
Check Out This!: https://scratch.mit.edu/projects/415117430/\nInstructions In Game.\nClick The Green Flag To Start.\nEnjoy!!!\nThe Boss Fight May Be Laggy.\n\nThanks For All The Support!\n\nThis Is My Most Viewed, Loved, and Faved Project In Only 3 Days! Hooray!