Jedi Platformer

Instructions: -------------------------------------------------------------------------------------------------------\nJedi Platformer 2: https://scratch.mit.edu/projects/219996985\n-------------------------------------------------------------------------------------------------------\n--Press space to swing the lightsaber\n--Use arrow keys or WASD

@Stage\n\nwhen flag clicked\nforever\n    play sound [Star Wars - Cantina Song2 v] until done\nend\n\nwhen flag clicked\nforever\n    if <([costume # v] of [ground v]) > [8]> then\n        set [slip v] to [.92]\n    else\n        set [slip v] to [.88]\n    end\nend\n\n@Player\n\nwhen I receive [start v]\ngo to [front v] layer\nswitch costume to (costume3 v)\ngo [backward v] (16) layers\nshow\nset [level v] to [1]\ngo to x: (-220) y: (-112)\nset size to (78) %\npoint in direction (90)\nset [slip v] to [.9]\nset [y v] to [0]\nset [x v] to [0]\nforever\n    change [y v] by (-1)\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        switch costume to (costume2 v)\n        change [x v] by (-1)\n    end\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        switch costume to (costume3 v)\n        change [x v] by (1)\n    end\n    set [x v] to ((x) * (slip))\n    change x by (x)\n    if <touching (ground v)?> then\n        change y by (1)\n        if <touching (ground v)?> then\n            change y by (1)\n            if <touching (ground v)?> then\n                change y by (1)\n                if <touching (ground v)?> then\n                    change y by (1)\n                    if <touching (ground v)?> then\n                        change y by (-4)\n                        change x by ((x) * (-1))\n                        if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                            set [y v] to [13]\n                            if <(x) > [0]> then\n                                set [x v] to [-10]\n                            else\n                                set [x v] to [10]\n                            end\n                        else\n                            set [x v] to [0]\n                        end\n                    end\n                end\n            end\n        end\n    end\n    change y by (y)\n    if <touching (ground v)?> then\n        change y by ((y) - ((y) * (2)))\n        set [y v] to [0]\n    end\n    change y by (-1)\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> and <touching (ground v)?>> then\n        set [y v] to [13]\n    end\n    change y by (1)\nend\n\nwhen flag clicked\nforever\n    if <(x position) > [235]> then\n        if <([costume # v] of [ground v]) < [17]> then\n            go to x: (-182) y: (-80)\n            broadcast (level complete v)\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (bounce v)?> then\n        set [y v] to [20]\n    end\nend\n\nwhen flag clicked\nforever\n    if <key (r v) pressed?> then\n        repeat (2)\n            change [ghost v] effect by (50)\n        end\n        switch costume to (costume3 v)\n        set size to (78) %\n        set [ghost v] effect to (0)\n        set [brightness v] effect to (0)\n        go to x: (-220) y: (-120)\n    end\nend\n\nwhen flag clicked\nforever\n    if <<<<<touching (sprite3 v)?> or <touching (spikes v)?>> or <(y position) < [-176]>> or <touching (sprite4 v)?>> or <touching (sprite5 v)?>> then\n        repeat (2)\n            change [ghost v] effect by (50)\n        end\n        switch costume to (costume3 v)\n        set size to (78) %\n        set [ghost v] effect to (0)\n        set [brightness v] effect to (0)\n        go to x: (-220) y: (-120)\n        broadcast (dead v)\n    end\nend\n\nwhen I receive [start v]\nforever\n    if <touching color (#00cc44)?> then\n        repeat (2)\n            change [ghost v] effect by (50)\n        end\n        switch costume to (costume3 v)\n        set size to (78) %\n        set [ghost v] effect to (0)\n        set [brightness v] effect to (0)\n        go to x: (-220) y: (-120)\n        broadcast (dead v)\n    end\nend\n\n@Ground\n\nwhen flag clicked\nswitch costume to (costume2 v)\ngo to x: (0) y: (-3.1)\n\nwhen I receive [level complete v]\nnext costume\n\n@Sprite3\n\nwhen flag clicked\nset size to (200) %\npoint in direction (90)\nforever\n    go to [front v] layer\n    hide\n    if <([costume # v] of [ground v]) = [2]> then\n        point in direction (90)\n        show\n        go to x: (13) y: (-137)\n    end\n    if <([costume # v] of [ground v]) = [4]> then\n        point in direction (0)\n        show\n        go to x: (26) y: (59)\n    end\n    if <([costume # v] of [ground v]) = [5]> then\n        point in direction (90)\n        show\n        go to x: (-60) y: (63)\n    end\n    if <([costume # v] of [ground v]) = [11]> then\n        point in direction (0)\n        show\n        go to x: (-118) y: (-188)\n    end\n    if <([costume # v] of [ground v]) = [12]> then\n        point in direction (90)\n        show\n        go to x: (140) y: (-158)\n    end\n    if <([costume # v] of [ground v]) = [14]> then\n        point in direction (90)\n        show\n        go to x: (140) y: (-162)\n    end\n    if <([costume # v] of [ground v]) = [16]> then\n        point in direction (90)\n        show\n        go to x: (140) y: (-164)\n    end\nend\n\n@Sprite4\n\nwhen flag clicked\nforever\n    hide\n    if <([costume # v] of [ground v]) = [3]> then\n        point in direction (90)\n        show\n        go to x: (184) y: (-70)\n    end\n    if <([costume # v] of [ground v]) = [4]> then\n        point in direction (0)\n        show\n        go to x: (-36) y: (-70)\n    end\n    if <([costume # v] of [ground v]) = [5]> then\n        point in direction (-90)\n        show\n        go to x: (62) y: (-50)\n    end\n    if <([costume # v] of [ground v]) = [9]> then\n        point in direction (90)\n        show\n        go to x: (101) y: (-39)\n    end\n    if <([costume # v] of [ground v]) = [11]> then\n        point in direction (0)\n        show\n        go to x: (142) y: (-157)\n    end\n    if <([costume # v] of [ground v]) = [12]> then\n        point in direction (90)\n        show\n        go to x: (20) y: (-158)\n    end\n    if <([costume # v] of [ground v]) = [14]> then\n        point in direction (90)\n        show\n        go to x: (20) y: (-162)\n    end\n    if <([costume # v] of [ground v]) = [16]> then\n        point in direction (90)\n        show\n        go to x: (20) y: (26)\n    end\nend\n\n@Sprite5\n\nwhen flag clicked\nset size to (200) %\nforever\n    hide\n    if <([costume # v] of [ground v]) = [3]> then\n        go to x: (8) y: (-32)\n        point in direction (90)\n        show\n    end\nend\n\nwhen flag clicked\nforever\n    repeat until <([costume # v] of [ground v]) = [4]>\n        glide (0.65) secs to x: (62) y: (-32)\n        glide (0.65) secs to x: (8) y: (-32)\n    end\n    hide\nend\n\n@Lightsaber\n\nwhen flag clicked\nswitch costume to (costume2 v)\nset size to (200) %\nforever\n    hide\n    if <key (space v) pressed?> then\n        show\n        if <([costume # v] of [player v]) = [2]> then\n            repeat (24)\n                turn right (15) degrees\n            end\n        else\n            repeat (24)\n                turn right (-15) degrees\n            end\n        end\n        hide\n        wait until <not <key (space v) pressed?>>\n    end\nend\n\nwhen flag clicked\nforever\n    if <key (space v) pressed?> then\n        play sound [lightsaber on v] until done\n        wait until <not <key (space v) pressed?>>\n    end\nend\n\nwhen flag clicked\nforever\n    if <([costume # v] of [player v]) = [2]> then\n        go to x: (([x position v] of [player v]) + (10)) y: (([y position v] of [player v]) + (12))\n    else\n        go to x: (([x position v] of [player v]) + (-10)) y: (([y position v] of [player v]) + (12))\n    end\nend\n\nwhen flag clicked\nset [brightness v] effect to (0)\nforever\n    set [brightness v] effect to (10)\nend\n\n@Sprite2\n\nwhen flag clicked\nhide\nforever\n    switch costume to (costume1 v)\n    if <([costume # v] of [ground v]) = [9]> then\n        show\n    else\n        hide\n    end\n    go to x: (174) y: (-135)\n    set size to (190) %\nend\n\nwhen I start as a clone\nforever\n    if <touching (lightsaber v)?> then\n        point in direction (90)\n        switch costume to (costume3 v)\n    end\nend\n\nwhen I start as a clone\nif <([costume # v] of [ground v]) = [9]> then\n    switch costume to (costume2 v)\n    point in direction (-90)\n    repeat until <<touching (_edge_ v)?> or <<touching (player v)?> or <<touching (ground v)?> or <touching (spikes v)?>>>>\n        move (8) steps\n    end\n    delete this clone\nelse\n    delete this clone\nend\n\nwhen flag clicked\nforever\n    if <<<touching color (#ff0000)?> or <touching color (#01db0f)?>> or <touching (lightsaber v)?>> then\n        forever\n            hide\n            stop [other scripts in sprite v]\n        end\n    end\nend\n\nwhen I start as a clone\nset size to (180) %\nforever\n    if <<touching color (#ff0000)?> or <touching color (#01db0f)?>> then\n        delete this clone\n    end\nend\n\nwhen flag clicked\nforever\n    if <([costume # v] of [ground v]) = [9]> then\n        create clone of (_myself_ v)\n        wait (1.5) seconds\n    else\n        delete this clone\n    end\nend\n\n@Bounce\n\nwhen flag clicked\nforever\n    hide\n    if <([costume # v] of [ground v]) = [14]> then\n        point in direction (90)\n        show\n        go to x: (-95) y: (-162)\n    end\nend\n\n@Spikes\n\nwhen flag clicked\nforever\n    hide\n    if <([costume # v] of [ground v]) = [2]> then\n        point in direction (90)\n        show\n        go to x: (138) y: (-78)\n        switch costume to (costume2 v)\n        set size to (110) %\n    end\n    if <([costume # v] of [ground v]) = [3]> then\n        point in direction (90)\n        show\n        go to x: (230) y: (129)\n        switch costume to (costume1 v)\n        set size to (140) %\n    end\n    if <([costume # v] of [ground v]) = [4]> then\n        switch costume to (costume2 v)\n        set size to (110) %\n        point in direction (90)\n        show\n        go to x: (90) y: (-162)\n    end\n    if <([costume # v] of [ground v]) = [5]> then\n        point in direction (90)\n        show\n        go to x: (-90) y: (-162)\n        switch costume to (costume2 v)\n        set size to (110) %\n    end\n    if <([costume # v] of [ground v]) = [6]> then\n        point in direction (90)\n        show\n        go to x: (-109) y: (-134)\n        switch costume to (costume1 v)\n        set size to (150) %\n    end\n    if <([costume # v] of [ground v]) = [9]> then\n        point in direction (0)\n        go to x: (66) y: (-70)\n        show\n        switch costume to (costume1 v)\n        set size to (140) %\n    end\n    if <([costume # v] of [ground v]) = [12]> then\n        point in direction (90)\n        show\n        go to x: (-144) y: (80)\n        switch costume to (costume1 v)\n        set size to (150) %\n    end\n    if <([costume # v] of [ground v]) = [13]> then\n        point in direction (90)\n        show\n        go to x: (140) y: (-141)\n        switch costume to (costume1 v)\n        set size to (200) %\n    end\n    if <([costume # v] of [ground v]) = [14]> then\n        point in direction (0)\n        go to x: (-61) y: (0)\n        show\n        switch costume to (costume2 v)\n        set size to (110) %\n    end\n    if <([costume # v] of [ground v]) = [16]> then\n        create clone of (_myself_ v)\n        point in direction (90)\n        go to x: (-61) y: (-166)\n        show\n        switch costume to (costume2 v)\n        set size to (140) %\n    end\nend\n\nwhen I start as a clone\ndelete this clone\n\n@Sprite7\n\nwhen I receive [start v]\nshow\nrepeat (50)\n    change [brightness v] effect by (2)\nend\nhide\n\nwhen flag clicked\nshow\nset [ghost v] effect to (-3)\ngo to [front v] layer\ngo [backward v] (1) layers\n\n@Sprite8\n\nwhen flag clicked\nset size to (300) %\nshow\ngo to [front v] layer\nset size to (0) %\nrepeat (15)\n    change size by (30)\nend\nrepeat (7)\n    change size by (-6)\nend\nforever\n    if <<touching (mouse-pointer v)?> and <mouse down?>> then\n        broadcast (start v)\n        repeat (50)\n            change [brightness v] effect by (2)\n        end\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (mouse-pointer v)?> then\n        repeat (4)\n            change size by (8)\n        end\n        wait until <not <touching (mouse-pointer v)?>>\n        repeat (4)\n            change size by (-8)\n        end\n    end\nend\n\nwhen flag clicked\nwait (0.2) seconds\nforever\n    go to x: ((mouse x) / (45)) y: (((mouse y) / (45)) - (100))\nend\n\n