Gravity (Pen Platformer)
@Stage\n\n@pen\n\nwhen flag clicked\nshow\nset [ghost v] effect to (100)\nset [level v] to [1]\nReset\nforever\n    erase all\n    if <(Level) = [1]> then\n        Render level 1\n    else\n        if <(Level) = [2]> then\n            Render level 2\n        else\n            if <(Level) = [3]> then\n                Render level 3\n            else\n                if <(Level) = [4]> then\n                    Render level 4\n                else\n                    if <(Level) = [5]> then\n                        Render level 5\n                    else\n                        if <(Level) = [6]> then\n                            Render level 6\n                        else\n                            if <(Level) = [7]> then\n                                Render level 7\n                            else\n                                if <(Level) = [8]> then\n                                    Render level 8\n                                else\n                                    if <(Level) = [9]> then\n                                        Render level 9\n                                    else\n                                        if <(Level) = [10]> then\n                                            Render level 10\n                                        else\n                                            if <(Level) = [11]> then\n                                                You win\n                                            end\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    if <not <(Level) > [10]>> then\n        go to x: (px) y: (py)\n        Player xy\n        if <(Dead?) = [no]> then\n            Render player\n        else\n            Reset\n        end\n    end\nend\n\ndefine Pen colour (a) (r) (g) (b)\nset pen color to (((((round (a)) * (16777216)) + ((round (r)) * (65536))) + ((round (g)) * (256))) + (round (b)))\n\ndefine Render player\ngo to x: (px) y: (py)\nPen colour (255) (200) (30) (30)\nset pen size to (25)\npen down\npen up\n\ndefine Player xy\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    change [pxv v] by (0.8)\nend\nif <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n    change [pxv v] by (-0.8)\nend\nset [pxv v] to ((pxv) * (0.9))\nchange x by (pxv)\nif <(gravity) = [up]> then\n    if <touching color (#000000)?> then\n        change y by (-1)\n        if <touching color (#000000)?> then\n            change y by (-1)\n            if <touching color (#000000)?> then\n                change y by (-1)\n                if <touching color (#000000)?> then\n                    change y by (-1)\n                    if <touching color (#000000)?> then\n                        change y by (-1)\n                        if <touching color (#000000)?> then\n                            change y by (5)\n                            change x by ((pxv) * (-1))\n                            if <(gravity) = [down]> then\n                                if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                                    if <(pxv) > [0]> then\n                                        set [pxv v] to [-6]\n                                    else\n                                        set [pxv v] to [6]\n                                    end\n                                    set [pyv v] to [8]\n                                else\n                                    set [pxv v] to [0]\n                                end\n                            else\n                                if <<key (down arrow v) pressed?> or <key (s v) pressed?>> then\n                                    if <(pxv) > [0]> then\n                                        set [pxv v] to [-6]\n                                    else\n                                        set [pxv v] to [6]\n                                    end\n                                    set [pyv v] to [-8]\n                                else\n                                    set [pxv v] to [0]\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nelse\n    if <touching color (#000000)?> then\n        change y by (1)\n        if <touching color (#000000)?> then\n            change y by (1)\n            if <touching color (#000000)?> then\n                change y by (1)\n                if <touching color (#000000)?> then\n                    change y by (1)\n                    if <touching color (#000000)?> then\n                        change y by (1)\n                        if <touching color (#000000)?> then\n                            change y by (-5)\n                            change x by ((pxv) * (-1))\n                            if <(gravity) = [down]> then\n                                if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                                    if <(pxv) > [0]> then\n                                        set [pxv v] to [-6]\n                                    else\n                                        set [pxv v] to [6]\n                                    end\n                                    set [pyv v] to [8]\n                                else\n                                    set [pxv v] to [0]\n                                end\n                            else\n                                if <<key (down arrow v) pressed?> or <key (s v) pressed?>> then\n                                    if <(pxv) > [0]> then\n                                        set [pxv v] to [-6]\n                                    else\n                                        set [pxv v] to [6]\n                                    end\n                                    set [pyv v] to [-8]\n                                else\n                                    set [pxv v] to [0]\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\nif <(gravity) = [down]> then\n    change [pyv v] by (-0.7)\nelse\n    change [pyv v] by (0.7)\nend\nchange y by (pyv)\nif <touching color (#000000)?> then\n    change y by ((pyv) * (-1))\n    set [pyv v] to [0]\nend\nif <(gravity) = [down]> then\n    if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n        change y by (-1)\n        if <touching color (#000000)?> then\n            set [pyv v] to [10]\n        end\n        change y by (1)\n    end\nelse\n    if <<key (down arrow v) pressed?> or <key (s v) pressed?>> then\n        change y by (1)\n        if <touching color (#000000)?> then\n            set [pyv v] to [-10]\n        end\n        change y by (-1)\n    end\nend\nif <<touching color (#ff0000)?> or <key (r v) pressed?>> then\n    set [dead? v] to [yes]\nend\nif <([abs v] of (x position) ) > [235]> then\n    if <(x position) > [0]> then\n        set [dead? v] to [yes]\n        change [level v] by (1)\n    end\nend\nif <(Level) = [5]> then\n    if <touching color (#00ff00)?> then\n        set [level 5 key v] to [yes]\n    end\nend\nif <(Level) = [7]> then\n    if <touching color (#00ff00)?> then\n        if <(py) > [0]> then\n            set [level 7 key2 v] to [yes]\n        else\n            set [level 7 key1 v] to [yes]\n        end\n    end\nend\nset [px v] to (x position)\nset [py v] to (y position)\ninsert (x position) at (1) of [trail x v] \ninsert (y position) at (1) of [trail y v] \nif <(length of [trail x v]) > [10]> then\n    delete (last) of [trail x v]\nend\nif <(length of [trail y v]) > [10]> then\n    delete (last) of [trail y v]\nend\n\ndefine Reset\nset [pxv v] to [0]\nset [pyv v] to [0]\nset [px v] to [-220]\nset [py v] to [-120]\nset [gravity v] to [down]\nset [dead? v] to [no]\nset [level 5 key v] to [no]\nset [level 7 key1 v] to [no]\nset [level 7 key2 v] to [no]\ndelete (all) of [rain x v]\ndelete (all) of [rain y v]\n\ndefine Render level 1\nPen colour (255) (0) (0) (0)\nset pen size to (50)\nLine (-240) (-160) (240) (-160)\nLine (-100) (-240) (-100) (-30)\nLine (-240) (160) (240) (160)\nPen colour (255) (255) (0) (0)\nLine (-100) (-160) (240) (-160)\nset pen size to (10)\nLine (70) (180) (70) (85)\nLine (140) (180) (140) (85)\n\nwhen flag clicked\nreset timer\nforever\n    reset timer\nend\n\nwhen flag clicked\nforever\n    wait until <key (space v) pressed?>\n    if <(gravity) = [down]> then\n        set [gravity v] to [up]\n    else\n        set [gravity v] to [down]\n    end\n    wait until <not <key (space v) pressed?>>\nend\n\ndefine Line (x1) (y1) (x2) (y2)\ngo to x: (x1) y: (y1)\npen down\ngo to x: (x2) y: (y2)\npen up\n\ndefine thumbnail\nerase all\nset pen size to (100)\nPen colour (255) (0) (0) (0)\nLine (-240) (170) (240) (170)\nset pen size to (50)\nLine (100) (180) (100) (-30)\nPen colour (100) (200) (30) (30)\nset pen size to (20)\ngo to x: (30) y: (30)\npen down\npen up\nPen colour (255) (200) (30) (30)\nset pen size to (20)\ngo to x: (35) y: (25)\npen down\npen up\nset pen size to (10)\nPen colour (255) (0) (0) (0)\ngo to x: (-150) y: (-70)\npen down\ngo to x: (-160) y: (-60)\ngo to x: (-170) y: (-60)\ngo to x: (-180) y: (-70)\ngo to x: (-180) y: (-100)\ngo to x: (-170) y: (-125)\ngo to x: (-150) y: (-125)\ngo to x: (-150) y: (-90)\ngo to x: (-155) y: (-90)\ngo to x: (-145) y: (-90)\npen up\ngo to x: (-120) y: (-125)\npen down\ngo to x: (-120) y: (-95)\ngo to x: (-120) y: (-105)\ngo to x: (-110) y: (-95)\ngo to x: (-100) y: (-95)\npen up\ngo to x: (-50) y: (-125)\npen down\ngo to x: (-50) y: (-95)\ngo to x: (-50) y: (-105)\ngo to x: (-60) y: (-95)\ngo to x: (-70) y: (-95)\ngo to x: (-80) y: (-105)\ngo to x: (-80) y: (-115)\ngo to x: (-70) y: (-125)\ngo to x: (-60) y: (-125)\ngo to x: (-50) y: (-115)\npen up\ngo to x: (-25) y: (-95)\npen down\ngo to x: (-15) y: (-125)\ngo to x: (-5) y: (-95)\npen up\ngo to x: (20) y: (-125)\npen down\ngo to x: (20) y: (-95)\npen up\ngo to x: (20) y: (-80)\npen down\npen up\ngo to x: (50) y: (-55)\npen down\ngo to x: (50) y: (-125)\ngo to x: (50) y: (-80)\ngo to x: (60) y: (-80)\ngo to x: (40) y: (-80)\npen up\ngo to x: (80) y: (-95)\npen down\ngo to x: (90) y: (-125)\ngo to x: (100) y: (-95)\ngo to x: (80) y: (-154)\npen up\n\nwhen [timer v] > (0.15)\n\nhide\nthumbnail\n\ndefine Render level 2\nPen colour (255) (0) (0) (0)\nset pen size to (50)\nLine (-240) (-160) (240) (-160)\nPen colour (255) (255) (0) (0)\nLine (-160) (-160) (240) (-160)\nLine (-240) (160) (240) (160)\n\ndefine You win\nPen colour (255) (0) (0) (0)\ngo to x: (-150) y: (40)\nset pen size to (10)\npen down\ngo to x: (-150) y: (100)\ngo to x: (-170) y: (120)\ngo to x: (-150) y: (100)\ngo to x: (-130) y: (120)\npen up\ngo to x: (-130) y: (40)\npen down\ngo to x: (-130) y: (80)\ngo to x: (-90) y: (80)\ngo to x: (-90) y: (40)\ngo to x: (-130) y: (40)\npen up\ngo to x: (-70) y: (80)\npen down\ngo to x: (-70) y: (40)\ngo to x: (-30) y: (40)\ngo to x: (-30) y: (80)\npen up\ngo to x: (30) y: (120)\npen down\ngo to x: (40) y: (40)\ngo to x: (50) y: (60)\ngo to x: (60) y: (40)\ngo to x: (70) y: (120)\npen up\ngo to x: (80) y: (40)\npen down\ngo to x: (80) y: (80)\npen up\ngo to x: (100) y: (40)\npen down\ngo to x: (100) y: (80)\ngo to x: (140) y: (80)\ngo to x: (140) y: (40)\npen up\ngo to x: (-80) y: (-80)\npoint in direction (135)\npen down\nrepeat (45)\n    turn left (2) degrees\n    move (4) steps\nend\npen up\ngo to x: (-25) y: (-20)\npen down\ngo to x: (-25) y: (-45)\npen up\ngo to x: (25) y: (-20)\npen down\ngo to x: (25) y: (-45)\npen up\n\ndefine Render level 10\nPen colour (255) (255) (0) (0)\nrepeat (40)\n    add (pick random (-200) to (150)) to [rain x v]\nend\nrepeat (40)\n    add (pick random (180) to (-180)) to [rain y v]\nend\nset [count v] to [0]\nrepeat (40)\n    change [count v] by (1)\n    go to x: (item (count) of [rain x v]) y: (item (count) of [rain y v])\n    set pen size to (5)\n    pen down\n    pen up\n    if <(item (count) of [rain y v]) < [-175]> then\n        replace item (count) of [rain x v] with (pick random (-200) to (150))\n        replace item (count) of [rain y v] with [180]\n    else\n        replace item (count) of [rain y v] with ((item (count) of [rain y v]) - (3))\n    end\nend\nset pen size to (50)\nLine (-240) (160) (240) (160)\nLine (240) (-180) (240) (-50)\nPen colour (255) (0) (0) (0)\nLine (-240) (-160) (240) (-160)\n\nwhen flag clicked\nforever\n    play sound [Warptech - Eternity \(feat. Ohmahi\) \[DJSaus Remix\] v] until done\nend\n\ndefine Render level 7\nPen colour (255) (0) (0) (0)\nset pen size to (50)\nLine (-240) (-160) (240) (-160)\nLine (-240) (160) (240) (160)\nPen colour (255) (255) (0) (0)\nset pen size to (50)\nif <(Level 7 key2) = [no]> then\n    Line (240) (-180) (240) (180)\n    Pen colour (255) (0) (255) (0)\n    set pen size to (10)\n    Line (0) (50) (0) (50)\nend\nset pen size to (10)\nPen colour (255) (255) (0) (0)\nLine (-150) (-180) (-150) (-100)\nLine (-100) (-180) (-100) (-100)\nLine (-50) (-180) (-50) (-100)\nLine (0) (-180) (0) (-100)\nLine (50) (-180) (50) (-100)\nLine (100) (-180) (100) (-100)\nPen colour (255) (0) (0) (0)\nset pen size to (100)\nif <(Level 7 key1) = [no]> then\n    Line (0) (50) (0) (50)\n    Pen colour (255) (255) (0) (0)\n    set pen size to (50)\n    Line (-240) (160) (240) (160)\n    Pen colour (255) (0) (255) (0)\n    set pen size to (10)\n    Line (140) (-120) (140) (-120)\nend\n\ndefine Draw rotating shape (x) (y) (size) (speed) (sides) (angle)\nset [i v] to (angle)\nrepeat ((sides) + (1))\n    change [i v] by ((360) / (sides))\n    go to x: ((([sin v] of (i) ) * (size)) + (x)) y: ((([cos v] of (i) ) * (size)) + (y))\n    pen down\nend\npen up\nchange [angle v] by (speed)\n\ndefine Render level 4\nPen colour (255) (0) (0) (0)\nset pen size to (50)\nLine (-240) (-160) (240) (-160)\nPen colour (255) (255) (0) (0)\nLine (-90) (-160) (240) (-160)\nset pen size to (30)\nPen colour (255) (0) (0) (0)\nLine (-160) (-180) (-160) (-20)\nset pen size to (50)\nLine (-240) (160) (240) (160)\nset pen size to (30)\nPen colour (255) (255) (0) (0)\nLine (-100) (180) (-100) (100)\nLine (-100) (-180) (-100) (25)\nLine (240) (180) (240) (50)\n\ndefine Render level 3\nPen colour (255) (0) (0) (0)\nset pen size to (50)\nLine (-240) (-160) (240) (-160)\nset pen size to (30)\nLine (-200) (180) (-200) (100)\nLine (-100) (180) (-100) (50)\nLine (0) (180) (0) (0)\nLine (200) (180) (200) (100)\nLine (100) (180) (100) (50)\nset pen size to (50)\nPen colour (255) (255) (0) (0)\nLine (-160) (-160) (240) (-160)\nLine (-240) (160) (240) (160)\nLine (240) (-180) (240) (0)\n\ndefine Render level 5\nPen colour (255) (0) (0) (0)\nset pen size to (50)\nLine (240) (-160) (-240) (-160)\nLine (240) (160) (-240) (160)\nset pen size to (30)\nLine (-50) (0) (50) (0)\nLine (-50) (0) (-50) (50)\nLine (50) (0) (50) (50)\nif <(Level 5 key) = [no]> then\n    Pen colour (255) (255) (0) (0)\n    Line (240) (180) (240) (-180)\n    set pen size to (10)\n    Pen colour (255) (0) (255) (0)\n    Line (0) (35) (0) (35)\nend\n\ndefine Render level 9\nPen colour (255) (0) (0) (0)\nset pen size to (50)\nLine (-240) (160) (240) (160)\nLine (-240) (-160) (240) (-160)\nset pen size to (10)\nPen colour (255) (255) (0) (0)\nLine (-150) (-180) (-150) (50)\nLine (-100) (180) (-100) (-50)\nLine (-50) (-180) (-50) (50)\nLine (0) (180) (0) (-50)\nLine (50) (-180) (50) (50)\nLine (100) (180) (100) (-50)\nLine (150) (-180) (150) (50)\nLine (200) (180) (200) (-50)\n\ndefine Trail\nif <not <(Level) > [10]>> then\n    set [counting v] to [10]\n    Pen colour (255) (255) (0) (0)\n    set pen shade to (100)\n    set pen size to (23)\n    repeat (10)\n        pen up\n        go to x: (item (counting) of [trail x v]) y: (item (counting) of [trail y v])\n        change [counting v] by (-1)\n        change pen shade by (5)\n        pen down\n    end\n    set pen shade to (50)\n    pen up\n    pen down\n    pen up\n    wait (0.01) seconds\nend\n\nwhen flag clicked\nforever\n    if <(Dead?) = [yes]> then\n        erase all\n        delete all of [trail x v]\n        delete all of [trail y v]\n    end\nend\n\nwhen flag clicked\nwait until <(Dead?) = [no]>\nset [dead? v] to [yes]\n\nwhen flag clicked\ndelete (all) of [trail x v]\ndelete (all) of [trail y v]\n\nwhen flag clicked\nshow\nforever\n    if <(Dead?) = [no]> then\nend\n\nTrail\n\ndefine Render level 8\nPen colour (255) (255) (0) (0)\nset pen size to (50)\nLine (-150) (-180) (-150) (0)\nPen colour (255) (0) (0) (0)\nLine (-240) (-160) (240) (-160)\nset pen size to (43)\nPen colour (255) (255) (0) (0)\nDraw rotating shape (60) (0) (120) (1) (1) (angle)\nDraw rotating shape (60) (0) (100) (1) (1) (angle)\nDraw rotating shape (60) (0) (-100) (2) (1) (angle)\nDraw rotating shape (60) (0) (-120) (2) (1) (angle)\nset pen size to (50)\nLine (-240) (160) (240) (160)\n\ndefine Render level 6\nset pen size to (50)\nPen colour (255) (0) (0) (0)\nLine (-240) (-160) (240) (-160)\nset pen size to (30)\nLine (75) (-120) (75) (-120)\nLine (-100) (120) (-100) (120)\nLine (200) (120) (200) (120)\nPen colour (255) (255) (0) (0)\nset pen size to (50)\nLine (-150) (-160) (240) (-160)\nLine (-240) (160) (240) (160)\nLine (240) (-50) (240) (-180)\n\n
scratch 3 broke\n\nno more lag but no more trail\n\narrow keys / wasd \nspace change grav