Grapple Hook Platformer (Test)
@Stage\n\n@Character\n\nwhen flag clicked\ngo to x: (0) y: (30)\nset [y speed v] to [0]\nset [x speed v] to [0]\nforever\n    if <(Grappled) = [N]> then\n        if <<key (w v) pressed?> and <touching (ground v)?>> then\n            change y by (5)\n            set [y speed v] to [5]\n        end\n        if <key (d v) pressed?> then\n            if <not <(X speed) > [5.1]>> then\n                change [x speed v] by (1)\n            end\n        else\n            if <key (a v) pressed?> then\n                if <not <(X speed) < [-5.1]>> then\n                    change [x speed v] by (-1)\n                end\n            else\n                if <touching (ground v)?> then\n                    if <(X speed) < [0]> then\n                        change [x speed v] by (0.5)\n                    end\n                    if <(X speed) > [0]> then\n                        change [x speed v] by (-0.5)\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nset [grappled v] to [N]\nforever\n    if <(Grappled) = [N]> then\n        change x by (X speed)\n        change y by (Y speed)\n        if <touching (ground v)?> then\n            if <not <key (up arrow v) pressed?>> then\n                set [grounded v] to [1]\n                Grounded\n            end\n        else\n            set [grounded v] to [0]\n            change [y speed v] by (-0.5)\n        end\n    end\nend\n\ndefine Grounded\nrepeat until <not <touching (ground v)?>>\n    change y by (1)\nend\nchange y by (-1)\nset [y speed v] to [0]\n\nwhen flag clicked\nset [grapple swing speed v] to [0]\nforever\n    if <(Grappled) = [y]> then\n        if <key (w v) pressed?> then\n            change [grapple disance v] by (-1)\n        end\n        if <key (s v) pressed?> then\n            change [grapple disance v] by (1)\n        end\n        if <touching (ground v)?> then\n            if <not <key (w v) pressed?>> then\n                set [grounded v] to [1]\n                Grounded\n            end\n            change x by (X speed)\n            change y by (Y speed)\n            if <key (d v) pressed?> then\n                if <not <(X speed) > [5.1]>> then\n                    change [x speed v] by (1)\n                end\n            else\n                if <key (a v) pressed?> then\n                    if <not <(X speed) < [-5.1]>> then\n                        change [x speed v] by (-1)\n                    end\n                else\n                    if <(X speed) < [0]> then\n                        change [x speed v] by (0.5)\n                    end\n                    if <(X speed) > [0]> then\n                        change [x speed v] by (-0.5)\n                    end\n                end\n            end\n            if <(Grapple Disance) < (distance to [hook v])> then\n                if <(X speed) < [0]> then\n                if <(X speed) > [0]> then\n                point towards (hook v)\n                turn right (180) degrees\n                set [grapple direction v] to (direction)\n                set [grapple swing speed v] to ((X speed) * (-0.75))\n                go to (hook v)\n                point in direction (Grapple Direction)\n                move (Grapple Disance) steps\n            end\n        else\n            set [grounded v] to [0]\n            if <key (d v) pressed?> then\n                change [grapple swing speed v] by (-0.1)\n            else\n                if <key (a v) pressed?> then\n                    change [grapple swing speed v] by (0.1)\n                end\n            end\n            if <touching (hook left v)?> then\n                change [grapple swing speed v] by (-0.5)\n            end\n            if <touching (hook right v)?> then\n                change [grapple swing speed v] by (0.5)\n            end\n            if <(Grapple Swing Speed) < [-7]> then\n                change [grapple swing speed v] by (0.15)\n            end\n            if <(Grapple Swing Speed) > [7]> then\n                change [grapple swing speed v] by (-0.15)\n            end\n            if <<touching (hook left v)?> and <touching (hook right v)?>> then\n                if <(Grapple Swing Speed) < [0]> then\n                    change [grapple swing speed v] by (0.05)\n                end\n                if <(Grapple Swing Speed) > [0]> then\n                    change [grapple swing speed v] by (-0.05)\n                end\n            end\n            change [grapple direction v] by (Grapple Swing Speed)\n            go to (hook v)\n            point in direction (Grapple Direction)\n            move (Grapple Disance) steps\n            if <touching (ground v)?> then\n                set [x speed v] to [0]\n            end\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    set y to (round (y position))\n    set x to (round (x position))\nend\n\nwhen flag clicked\nset [xpos v] to [280]\nset [ypos v] to [0]\nforever\n    if <(y position) > [50]> then\n        change [ypos v] by ((y position) - (50))\n        set y to (50)\n    end\n    if <<[-50] > (y position)> and <not <(YPos) = [0]>>> then\n        change [ypos v] by ((y position) - (-50))\n        set y to (-50)\n    end\n    if <(YPos) < [0]> then\n        set [ypos v] to [0]\n    end\n    if <(x position) > [50]> then\n        change [xpos v] by ((x position) - (50))\n        set x to (50)\n    end\n    if <[-50] > (x position)> then\n        change [xpos v] by ((x position) + (50))\n        set x to (-50)\n    end\n    if <touching (_edge_ v)?> then\n        go to x: (0) y: (30)\n        set [xpos v] to [280]\n        set [ypos v] to [0]\n        set [grappled v] to [n]\n        wait (0.01) seconds\n        set [x speed v] to [0]\n        set [y speed v] to [0]\n    end\nend\n\nwhen I receive [hitbox v]\ngo to (hitbox v)\n\nwhen flag clicked\nhide variable [xpos v]\nhide variable [ypos v]\nwait until <key (r v) pressed?>\nbroadcast (Debug v)\nforever\n    if <key (r v) pressed?> then\n        set [y speed v] to [5]\n    end\nend\n\n@Hook\n\nwhen flag clicked\nforever\n    go to (character v)\n    point towards (mouse-pointer v)\n    if <key (space v) pressed?> then\n        point towards (mouse-pointer v)\n        repeat until <<touching (ungrappleable ground v)?> or <<touching (ground v)?> or <(distance to [character v]) > (Grapple Range)>>>\n            move (15) steps\n        end\n        if <touching (ungrappleable ground v)?> then\n            create clone of (particle v)\n        end\n        if <<not <touching (ungrappleable ground v)?>> and <touching (ground v)?>> then\n            set [grapple disance v] to (distance to [character v])\n            point towards (character v)\n            set [grapple swing speed v] to [0]\n            if <([y position v] of [character v]) > ((y position) - ((Grapple Disance) / (3)))> then\n                change [grapple swing speed v] by ((X speed) * (-0.2))\n                change [grapple swing speed v] by ((Y speed) * (0.6))\n            else\n                if <([y position v] of [character v]) > ((y position) - ((Grapple Disance) / (1.5)))> then\n                    change [grapple swing speed v] by ((X speed) * (-0.6))\n                    change [grapple swing speed v] by ((Y speed) * (0.2))\n                else\n                    change [grapple swing speed v] by ((X speed) * (-0.8))\n                end\n            end\n            set [grapple direction v] to (direction)\n            turn right (180) degrees\n            set [grappled v] to [y]\n            set [own xpos v] to ((Xpos) + (x position))\n            set [own y pos v] to ((YPos) + (y position))\n            repeat until <not <<key (space v) pressed?> or <(Grappled) = [n]>>>\n                go to x: ((Own Xpos) - (Xpos)) y: ((Own Y POS) - (YPos))\n            end\n            repeat until <<key (space v) pressed?> or <(Grappled) = [n]>>\n                go to x: ((Own Xpos) - (Xpos)) y: ((Own Y POS) - (YPos))\n            end\n        end\n        set [x speed v] to (Frame DifferenceX)\n        set [y speed v] to (Frame Difference Y)\n        if <key (w v) pressed?> then\n            change [y speed v] by (3)\n        end\n        broadcast (HitBox v)\n        set [grappled v] to [n]\n        repeat until <touching (character v)?>\n            point towards (character v)\n            move (10) steps\n            turn right (180) degrees\n        end\n        repeat until <not <key (space v) pressed?>>\n            go to (character v)\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <(distance to [character v]) > (Grapple Range)> then\n        set [grapple disance v] to (Grapple Range)\n    end\n    if <[25] > (distance to [character v])> then\n        set [grapple disance v] to [25]\n    end\nend\n\n@Hook Left\n\nwhen flag clicked\nshow\nset [ghost v] effect to (100)\nforever\n    go to [back v] layer\n    go to (hook v)\n    point in direction (90)\n    if <touching (character v)?> then\n        switch costume to (costume2 v)\n    else\n        switch costume to (costume1 v)\n    end\nend\n\nwhen I receive [debug v]\nset [ghost v] effect to (75)\n\n@Hook Right\n\nwhen flag clicked\nchange [ghost v] effect by (50)\nset [ghost v] effect to (100)\nforever\n    go to [back v] layer\n    go to (hook v)\n    point in direction (90)\n    if <touching (character v)?> then\n        switch costume to (costume2 v)\n    else\n        switch costume to (costume1 v)\n    end\nend\n\nwhen I receive [debug v]\nset [ghost v] effect to (75)\nshow variable [xpos v]\nshow variable [ypos v]\n\n@Meep\n\ngo to x: ((Own Xpos) - (Xpos)) y: (0)\n\nset [xpos v] to [0]\n\nwhen flag clicked\ngo to (character v)\nforever\n    block name\n    go to (character v)\n    set [ghost v] effect to (75)\n    set [own xpos v] to (Xpos)\nend\n\ndefine block name\nset [frame differencex v] to [0]\nset [frame difference y v] to [0]\nif <([x position v] of [character v]) > (x position)> then\n    repeat until <(x position) = (round ([x position v] of [character v]))>\n        change [frame differencex v] by (1)\n        change x by (1)\n        if <touching (_edge_ v)?> then\n            go to (character v)\n        end\n    end\nelse\n    if <(x position) > ([x position v] of [character v])> then\n        repeat until <(x position) = (round ([x position v] of [character v]))>\n            change [frame differencex v] by (-1)\n            change x by (-1)\n            if <touching (_edge_ v)?> then\n                go to (character v)\n            end\n        end\n    end\nend\nchange [frame differencex v] by ((Xpos) - (Own Xpos))\nif <([y position v] of [character v]) > (y position)> then\n    repeat until <(y position) = (round ([y position v] of [character v]))>\n        change [frame difference y v] by (1)\n        change y by (1)\n        if <touching (_edge_ v)?> then\n            go to (character v)\n        end\n    end\nelse\n    if <(y position) > ([y position v] of [character v])> then\n        repeat until <(y position) = (round ([y position v] of [character v]))>\n            change [frame difference y v] by (-1)\n            change y by (-1)\n            if <touching (_edge_ v)?> then\n                go to (character v)\n            end\n        end\n    end\nend\n\n@Ground\n\nwhen flag clicked\nhide\nset [clones v] to [0]\nrepeat (12)\n    change [clones v] by (1)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nshow\nswitch costume to (Clones)\nset [own xpos v] to (((round ((Clones) / (2))) * (480)) - (480))\nif <((costume [number v]) / (2)) = (round ((costume [number v]) / (2)))> then\ngo to [front v] layer\nforever\n    if <((costume [number v]) / (2)) = (round ((costume [number v]) / (2)))> then\n        go to x: ((Own Xpos) - (Xpos)) y: ((370) - (YPos))\n    else\n        go to x: ((Own Xpos) - (Xpos)) y: ((0) - (YPos))\n    end\n    if <not <touching (ground checker v)?>> then\n        set [ghost v] effect to (100)\n    else\n        set [ghost v] effect to (100)\n    end\nend\n\nhide\nshow\n\n@Ungrappleable Ground\n\nwhen flag clicked\nhide\nset [clones v] to [0]\nrepeat (12)\n    change [clones v] by (1)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nshow\nswitch costume to (Clones)\nset [own xpos v] to (((round ((Clones) / (2))) * (480)) - (480))\nif <((costume [number v]) / (2)) = (round ((costume [number v]) / (2)))> then\ngo to [front v] layer\nforever\n    if <((costume [number v]) / (2)) = (round ((costume [number v]) / (2)))> then\n        go to x: ((Own Xpos) - (Xpos)) y: ((370) - (YPos))\n    else\n        go to x: ((Own Xpos) - (Xpos)) y: ((0) - (YPos))\n    end\n    if <not <touching (ground checker v)?>> then\n        set [ghost v] effect to (100)\n    else\n        set [ghost v] effect to (0)\n        set [ghost v] effect to (100)\n    end\nend\n\nhide\nshow\n\n@Pen Drawer\n\nwhen flag clicked\ngo to (character v)\nset [ghost v] effect to (100)\nforever\n    block name\nend\n\ndefine block name\nerase all\nset pen color to (#ce815b)\nset pen size to (2)\npen down\ngo to (hook v)\nglide (0) secs to (character v)\npen up\n\n@Ground Checker\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\n\n@Hitbox\n\nwhen flag clicked\ngo to (character v)\nset [ghost v] effect to (100)\nforever\nend\n\nwhen flag clicked\ngo to (character v)\nset [ghost v] effect to (100)\nforever\n    go to (character v)\n    block name\n    switch costume to (all v)\nend\n\ndefine block name\nswitch costume to (right v)\nif <<(Grapple Swing Speed) < [-7]> or <(Grapple Swing Speed) > [7]>> then\n    switch costume to (right2 v)\nelse\n    set size to (100) %\nend\nif <touching (ground v)?> then\n    repeat until <not <touching (ground v)?>>\n        change x by (-1)\n        if <touching (_edge_ v)?> then\n            go to (character v)\n        end\n    end\n    broadcast (HitBox v)\n    set [grapple swing speed v] to [1]\n    set [x speed v] to [0]\nend\nset size to (100) %\nswitch costume to (up v)\nif <touching (ground v)?> then\n    repeat until <not <touching (ground v)?>>\n        change y by (-1)\n        if <touching (_edge_ v)?> then\n            go to (character v)\n        end\n    end\n    broadcast (HitBox v)\n    set [grapple swing speed v] to [0]\n    set [y speed v] to [0]\nend\nswitch costume to (left v)\nif <<(Grapple Swing Speed) < [-7]> or <(Grapple Swing Speed) > [7]>> then\n    switch costume to (left2 v)\nelse\n    set size to (100) %\nend\nif <touching (ground v)?> then\n    repeat until <not <touching (ground v)?>>\n        change x by (1)\n        if <touching (_edge_ v)?> then\n            go to (character v)\n        end\n    end\n    broadcast (HitBox v)\n    set [grapple swing speed v] to [-1]\n    set [x speed v] to [0]\nend\n\nwhen I receive [debug v]\nset [ghost v] effect to (50)\n\n@Shown Detail\n\nwhen flag clicked\nhide\nset [clones v] to [0]\nrepeat (12)\n    change [clones v] by (1)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nshow\nswitch costume to (Clones)\nset [own xpos v] to (((round ((Clones) / (2))) * (480)) - (480))\nif <((costume [number v]) / (2)) = (round ((costume [number v]) / (2)))> then\ngo to [front v] layer\nforever\n    if <((costume [number v]) / (2)) = (round ((costume [number v]) / (2)))> then\n        go to x: ((Own Xpos) - (Xpos)) y: ((370) - (YPos))\n    else\n        go to x: ((Own Xpos) - (Xpos)) y: ((0) - (YPos))\n    end\n    if <not <touching (ground checker v)?>> then\n        set [ghost v] effect to (100)\n    else\n        set [ghost v] effect to (0)\n    end\nend\n\nhide\nshow\n\n@Particle\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nshow\nturn right (pick random (1) to (359)) degrees\ngo to (hook v)\ngo to [front v] layer\nset size to (50) %\nset [ghost v] effect to (50)\nrepeat (5)\n    change size by (15)\n    change [ghost v] effect by (5)\nend\ndelete this clone\n\n
WASD to move\nSpace to grapple\n\nMainly a Physics test for an Idea I had