Gravity Switch - Scrolling platformer                                                          games


@Stage\n\nwhen I receive [green flag v]\nhide variable [mouse v]\n\nwhen I receive [green flag v]\nrepeat until <(LEVEL) = [6]>\n    play sound [Pushing onwards v] until done\nend\nrepeat until <(LEVEL) = [7]>\n    play sound [positive force v] until done\nend\nrepeat until \n    play sound [Potential For Anything v] until done\nend\n\nwhen I receive [dadawfefs v]\nstop all sounds\n\n@Player\n\nwhen flag clicked\nbroadcast (Green Flag v)\nbroadcast (Play Game v)\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\n\nwhen I receive [play game v]\nshow\nset [level v] to [1]\nforever\n    broadcast (Reset v) and wait\n    broadcast (Setup v) and wait\n    Game On\n    repeat until <(EXIT) > []>\n        Tick\n        broadcast (Tick v) and wait\n    end\n    if <(EXIT) = [win]> then\n        Game - Win\n    else\n        Game - Die\n    end\nend\n\ndefine Game On\nset [sx v] to [0]\nset [sy v] to [0]\nif <not <(LEVEL) = [6]>> then\n    set [x v] to [0]\n    set [y v] to [0]\n    set [scroll y v] to [0]\nelse\n    set [x v] to (checkpoint x)\n    set [y v] to (checkpoint y)\n    set [scroll y v] to (checkpoint scroll y)\nend\nset [scroll x v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nset size to (100) %\nset rotation style [left-right v]\n\ndefine Tick\nswitch costume to (hitbox v)\nif <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n    set [idle? v] to [0]\n    point in direction (-90)\n    change [sx v] by (-2)\n    if <(CLIMBING) = [0]> then\n        change [frame v] by (0.5)\n    end\nelse\n    if <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n        set [idle? v] to [0]\n        point in direction (90)\n        change [sx v] by (2)\n        if <(CLIMBING) = [0]> then\n            change [frame v] by (0.5)\n        end\n    else\n        set [idle? v] to [1]\n        change [frame v] by (0.5)\n    end\nend\nset [sx v] to ((sx) * (0.8))\nif <([abs v] of (sx) ) > [0.9]> then\n    Change Player x by (round (sx))\nend\nif <(gravity) = [1]> then\n    change [sy v] by (-2)\nelse\n    if <(gravity) = [2]> then\n        change [sy v] by (2)\n    end\nend\nChange player y by (sy)\nTest - Die\nif <not <(LEVEL) = [6]>> then\n    change [scroll x v] by (round (((x) - (SCROLL X)) / (10)))\n    if <(SCROLL X) < [-400]> then\n        set [scroll x v] to [-400]\n    end\n    change [scroll y v] by (round (((y) - (SCROLL Y)) / (10)))\n    if <(SCROLL Y) < [0]> then\n        set [scroll y v] to [0]\n    end\nelse\n    set [scroll x v] to [0]\n    change [scroll y v] by (1)\nend\nPosition\nif <not <(LEVEL) = [6]>> then\n    if <<(y) < [-180]> or <(y position) > [180]>> then\n        set [exit v] to [die]\n    end\nelse\n    if <<(y position) < [-170]> or <(y position) > [180]>> then\n        set [exit v] to [die]\n    end\nend\nSet costume\n\ndefine Change player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nPosition\nrepeat until <not <touching (platforms 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) - (SCROLL Y))\n\ndefine Change Player x by (sx)\nchange [x v] by (sx)\nPosition\nif <touching (platforms v)?> then\n    repeat (12)\n        change [y v] by (1)\n        Position\n        if <not <touching (platforms v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    repeat until <not <touching (platforms 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\nset [exit v] to []\nstart sound [hurt v]\nrepeat (2)\n    hide\n    wait (0.1) seconds\n    show\n    wait (0.1) seconds\nend\nhide\nwait (0.5) seconds\nshow\n\ndefine Test - Die\nif <<touching (danger v)?> or <touching (toxic stuff v)?>> then\n    set [exit v] to [die]\nend\n\ndefine Game - Win\nhide\nwait (2) seconds\nchange [level v] by (1)\nshow\nclear graphic effects\n\nwhen I receive [green flag v]\nforever\n    if <<<<key (a v) pressed?> or <key (d v) pressed?>> or <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>>> and <<(in air) = [0]> or <(sy) = [0]>>> then\n        start sound [Foot step 2 v]\n        wait (0.3) seconds\n    end\nend\n\ndefine Set costume\nif <(gravity) = [1]> then\n    if <(idle?) = [1]> then\n        switch costume to ([floor v] of ((2) + ((frame) mod (5))) )\n    else\n        switch costume to ([floor v] of ((7) + ((frame) mod (5))) )\n    end\nelse\n    if <(idle?) = [1]> then\n        switch costume to ([floor v] of ((13) + ((frame) mod (5))) )\n    else\n        switch costume to ([floor v] of ((18) + ((frame) mod (5))) )\n    end\nend\n\nwhen [0 v] key pressed\nif <not <(LEVEL) = [11]>> then\n    wait until <not <key (0 v) pressed?>>\n    change [level v] by (1)\n    set [x v] to [0]\n    set [y v] to [0]\n    set [scroll x v] to [0]\n    set [scroll y v] to [0]\n    broadcast (Reset v) and wait\n    broadcast (Setup v) and wait\nend\n\nwhen flag clicked\nset [checkpoint scroll y v] to [0]\nset [checkpoint x v] to [0]\nset [checkpoint y v] to [0]\nset [level v] to [1]\nwait until <(LEVEL) = [6]>\nbroadcast (dadawfefs v)\nwait until <(LEVEL) = [7]>\nbroadcast (dadawfefs v)\n\nwhen [m v] key pressed\n\nshow variable [mouse v]\nset [mouse v] to (join ((mouse x) + (SCROLL X)) (join [, ] ((mouse y) + (SCROLL Y))))\n\nwhen I receive [setup v]\nset [gravity v] to [1]\n\nwhen [space v] key pressed\nwait until <not <key (space v) pressed?>>\nif <<(in air) = [0]> or <(sy) = [0]>> then\n    if <(gravity) = [1]> then\n        start sound [jump v]\n        set [gravity v] to [2]\n        stop [this script v]\n    end\n    if <(gravity) = [2]> then\n        start sound [jump2 v]\n        set [gravity v] to [1]\n        stop [this script v]\n    end\nend\n\nwhen I receive [switch v]\nset [sy v] to [0]\nif <(gravity) = [1]> then\n    set [gravity v] to [2]\n    stop [this script v]\nend\nif <(gravity) = [2]> then\n    set [gravity v] to [1]\n    stop [this script v]\nend\n\nwhen I receive [checkpoint! v]\nset [checkpoint x v] to (x)\nset [checkpoint y v] to (y)\nset [checkpoint scroll y v] to (SCROLL Y)\n\n@Platforms\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (1-1 v)\n    Clone at x [0] y [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (2-1 v)\n        Clone at x [0] y [0]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (3-1 v)\n            Clone at x [0] y [0]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (4-1 v)\n                Clone at x [0] y [0]\n            else\n                if <(LEVEL) = [5]> then\n                    switch costume to (5-1 v)\n                    Clone at x [0] y [0]\n                else\n                    if <(LEVEL) = [6]> then\n                        switch costume to (6-1 v)\n                        Clone at x [0] y [0]\n                        Clone at x [0] y [360]\n                        switch costume to (6-2 v)\n                        Clone at x [0] y [360]\n                        switch costume to (6-3 v)\n                        Clone at x [0] y [400]\n                        switch costume to (6-4 v)\n                    else\n                        if <(LEVEL) = [7]> then\n                            switch costume to (7-1 v)\n                            Clone at x [0] y [0]\n                        else\n                            if <(LEVEL) = [8]> then\n                                switch costume to (8-1 v)\n                                Clone at x [0] y [0]\n                            else\n                                if <(LEVEL) = [9]> then\n                                    switch costume to (9-1 v)\n                                    Clone at x [0] y [0]\n                                else\n                                    if <(LEVEL) = [10]> then\n                                        switch costume to (10-1 v)\n                                        Clone at x [0] y [0]\n                                    else\n                                        if <(LEVEL) = [11]> then\n                                            switch costume to (11-1 v)\n                                            Clone at x [0] y [0]\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\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)\n\n@Switchers\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <touching (player v)?> then\n    start sound [save v]\n    broadcast (Switch v)\n    delete this clone\nend\n\nwhen I receive [setup v]\nhide\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [3]> then\n    Clone at x [129] y [-66]\n    set [x v] to [9999999999]\nelse\n    if <(LEVEL) = [4]> then\n        Clone at x [134] y [-120]\n        Clone at x [274] y [101]\n        set [x v] to [9999999999]\n    else\n        if <(LEVEL) = [6]> then\n            Clone at x [45] y [532]\n            Clone at x [-16] y [796]\n            Clone at x [-220] y [1043]\n            set [x v] to [9999999999]\n        else\n            if <(LEVEL) = [7]> then\n                Clone at x [-219] y [-99]\n                Clone at x [218] y [91]\n                Clone at x [129] y [124]\n                set [x v] to [9999999999]\n            else\n                if <(LEVEL) = [8]> then\n                    Clone at x [62] y [83]\n                    Clone at x [209] y [83]\n                    Clone at x [209] y [-173]\n                    Clone at x [62] y [-173]\n                    set [x v] to [9999999999]\n                else\n                    if <(LEVEL) = [10]> then\n                        Clone at x [-134] y [-142]\n                        set [x v] to [9999999999]\n                    else\n                        if <(LEVEL) = [11]> then\n                            Clone at x [-178] y [-29]\n                            Clone at x [170] y [-29]\n                            set [x v] to [9999999999]\n                        else\n                            set [x v] to [9999999999]\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\n    change [frame v] by (0.5)\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen I receive [tick v]\nswitch costume to (round (frame))\n\n@Exit\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <touching (player v)?> then\n    set [exit v] to [win]\n    broadcast (win v)\nend\n\nwhen I receive [setup v]\nset size to (100) %\nswitch costume to (open v)\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    Clone at x [-83] y [248]\nelse\n    if <(LEVEL) = [2]> then\n        Clone at x [14] y [240]\n    else\n        if <(LEVEL) = [3]> then\n            Clone at x [227] y [73]\n        else\n            if <(LEVEL) = [4]> then\n                Clone at x [427] y [21]\n            else\n                if <(LEVEL) = [5]> then\n                    Clone at x [358] y [-18]\n                else\n                    if <(LEVEL) = [6]> then\n                        Clone at x [-134] y [1154]\n                    else\n                        if <(LEVEL) = [7]> then\n                            Clone at x [84] y [86]\n                        else\n                            if <(LEVEL) = [8]> then\n                                Clone at x [-37] y [-144]\n                            else\n                                if <(LEVEL) = [9]> then\n                                    Clone at x [187] y [207]\n                                else\n                                    if <(LEVEL) = [10]> then\n                                        Clone at x [234] y [71]\n                                    else\n                                        set [x v] to [9999999]\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen I receive [end v]\nstop [other scripts in sprite v]\nhide\n\nwhen I receive [win v]\nstart sound [blip2 v]\nrepeat (10)\n    change size by (2)\nend\nrepeat (15)\n    change size by (-8)\nend\nhide\n\n@Overlay\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (1-1 v)\n    Clone at x [0] y [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (2-1 v)\n        Clone at x [0] y [0]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (3-1 v)\n            Clone at x [0] y [0]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (4-1 v)\n                Clone at x [0] y [0]\n            else\n                if <(LEVEL) = [5]> then\n                    switch costume to (5-1 v)\n                    Clone at x [0] y [0]\n                else\n                    if <(LEVEL) = [11]> then\n                        switch costume to (11-1 v)\n                        Clone at x [0] y [0]\n                    else\n                        set [x v] to [99999999]\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\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)\n\n@Danger\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nclear graphic effects\ngo to [back v] layer\nhide\nif <(LEVEL) = [2]> then\n    switch costume to (1 v)\n    Clone at x [-166] y [135]\n    Clone at x [-166] y [51]\nelse\n    if <(LEVEL) = [5]> then\n        switch costume to (1 v)\n        Clone at x [181] y [110]\n        Clone at x [224] y [164]\n        Clone at x [85] y [199]\n    else\n        if <(LEVEL) = [6]> then\n            switch costume to (1 v)\n            Clone at x [-176] y [86]\n            Clone at x [178] y [96]\n            switch costume to (2 v)\n            Clone at x [-145] y [373]\n            Clone at x [-236] y [473]\n            switch costume to (1 v)\n            Clone at x [-26] y [400]\n            Clone at x [56] y [473]\n            Clone at x [164] y [400]\n            switch costume to (2 v)\n            Clone at x [38] y [626]\n            switch costume to (1 v)\n            Clone at x [-52] y [916]\n            switch costume to (2 v)\n            Clone at x [-183] y [958]\n            Clone at x [-54] y [958]\n            Clone at x [-125] y [1080]\n        else\n            if <(LEVEL) = [7]> then\n                switch costume to (1 v)\n                Clone at x [-96] y [24]\n                Clone at x [91] y [-19]\n                Clone at x [131] y [24]\n            else\n                if <(LEVEL) = [8]> then\n                    switch costume to (2 v)\n                    Clone at x [68] y [-6]\n                    Clone at x [208] y [-6]\n                    Clone at x [208] y [-100]\n                    Clone at x [68] y [-100]\n                else\n                    if <(LEVEL) = [9]> then\n                        switch costume to (2 v)\n                        Clone at x [-9] y [-180]\n                    else\n                        if <(LEVEL) = [10]> then\n                            switch costume to (2 v)\n                            Clone at x [0] y [-154]\n                        else\n                            set [x v] to [99999999999]\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\nif <<<(x) = (x position)> and <(y) = (y position)>> and <<(costume [number v]) = [1]> or <(costume [number v]) = [2]>>> then\n    turn right (10) degrees\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nforever\n    if <<<(x) = (x position)> and <(y) = (y position)>> and <<(costume [number v]) = [1]> or <(costume [number v]) = [2]>>> then\n        clear graphic effects\n        turn right (10) degrees\n    end\nend\n\nwhen I receive [end v]\nstop [other scripts in sprite v]\nhide\n\n@Tower Checkpoints\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nposition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <touching (player v)?> then\n    start sound [save v]\n    broadcast (Checkpoint! v)\n    delete this clone\nend\n\nwhen I receive [setup v]\nhide\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [6]> then\n    Clone at x [-77] y [399]\n    Clone at x [-124] y [771]\n    set [x v] to [9999999999]\nelse\n    set [x v] to [9999999999]\nend\n\ndefine position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x (x) y (y)\nset [x v] to (x)\nset [y v] to (y)\ncreate clone of (_myself_ v)\n\n@Name\n\nwhen I receive [tick v]\nswitch costume to (LEVEL)\n\n@Thumbnail\n\nwhen flag clicked\nhide\n\n