Scrolling Platformer Base
@Stage\n\nforever\n    if <(level) = [1]> then\n        repeat until <(level) = [2]>\n            play sound [ v] until done\n        end\n    end\n    if <(level) = [2]> then\n        repeat until <(level) = [3]>\n            play sound [ v] until done\n        end\n    end\n    if <(level) = [3]> then\n        repeat until <(level) = [4]>\n            play sound [ v] until done\n        end\n    end\nend\n\nwhen flag clicked\n\nforever\n    play sound [ v] until done\nend\n\n@Player\n\nwhen flag clicked\nset [speed v] to [12]\nset [jump height v] to [12]\nforever\n    set [color water v] to <touching color (#00ffff)?>\n    set [color bounce v] to <touching color (#cc98fe)?>\n    set [color hurt v] to <touching color (#ff0000)?>\n    set [color win v] to <touching color (#ffff00)?>\nend\n\nwhen flag clicked\nforever\n    if <(color water) = [false]> then\n        wait until <(color water) = [true]>\n        play sound [splash v] until done\n    end\nend\n\nwhen flag clicked\nforever\n    if <(color water) = [true]> then\n        play sound [water v] until done\n    end\nend\n\nwhen flag clicked\nforever\n    if <(color bounce) = [false]> then\n        wait until <(color bounce) = [true]>\n        play sound [boing v] until done\n    end\nend\n\ndefine walk\nif <(x) < [0]> then\n    change [frame v] by ((x) / (-8))\nelse\n    change [frame v] by ((x) / (8))\nend\n\ndefine touch ground\nchange [falling? v] by (1)\nrepeat until <not <touching color (#000000)?>>\n    if <(y) > [0]> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling? v] to [0]\n    end\n    set [y v] to [0]\nend\n\ndefine set costume\nif <(falling?) < [3]> then\n    if <(frame) = [0]> then\n        switch costume to (stand v)\n    else\n        switch costume to (([floor v] of ((3) + ((frame) mod (3))) ) - (1))\n    end\nelse\n    if <(y) > [0]> then\n        if <(color water) = [true]> then\n            switch costume to (swim v)\n        else\n            switch costume to (jump v)\n        end\n    else\n        switch costume to (fall v)\n    end\nend\n\nwhen [r v] key pressed\npoint in direction (90)\ngo to x: (-35) y: (0)\nswitch costume to (stand v)\ngo to [front v] layer\nshow\nset [y v] to [0]\nset [game playing? v] to [true]\n\nwhen flag clicked\npoint in direction (90)\nswitch backdrop to (1 v)\nswitch costume to (stand v)\ngo to [front v] layer\nshow\nset [y v] to [0]\nset [game playing? v] to [true]\ngo to x: (-35) y: (0)\nforever\n    if <(game playing?) = [true]> then\n        switch costume to (hitbox v)\n        change y by (y)\n        touch ground\n        set [x v] to ((x) * (0.7))\n        if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n            change [x v] by ((speed) * (-0.05))\n        end\n        if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n            change [x v] by ((speed) * (0.05))\n        end\n        if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n            point in direction (-90)\n            walk\n        else\n            if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n                point in direction (90)\n                walk\n            else\n                set [frame v] to [0]\n            end\n        end\n        if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> and <(falling?) < [3]>> then\n            set [y v] to (jump height)\n        end\n        if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <(y) < [4]>> then\n            change [y v] by (-1)\n        else\n            change [y v] by (-2)\n        end\n        set costume\n        if <(costume [number v]) = [1]> then\n            go to x: (-35) y: (0)\n            switch costume to (stand v)\n        end\n        if <(color win) = [true]> then\n            set [game playing? v] to [false]\n            switch costume to (win v)\n            play sound [win v] until done\n            next backdrop\n            broadcast (next level v)\n            switch costume to (stand v)\n            set [y v] to [0]\n            set [game playing? v] to [true]\n        end\n        if <<(color hurt) = [true]> or <<(y position) < [-150]> and <(color water) = [false]>>> then\n            set [game playing? v] to [false]\n            switch costume to (hurt v)\n            play sound [hurt v] until done\n            broadcast (hurt v)\n            set [y v] to [0]\n            set [game playing? v] to [true]\n            switch costume to (stand v)\n            set y to (0)\n        end\n        if <(color water) = [true]> then\n            if <not <<key (down arrow v) pressed?> or <key (s v) pressed?>>> then\n                set [y v] to ((y) * (0.5))\n            end\n        end\n        if <(color bounce) = [true]> then\n            if <<key (down arrow v) pressed?> or <key (s v) pressed?>> then\n                set [y v] to [8]\n            else\n                set [y v] to [18]\n            end\n        end\n        if <(y position) > [259]> then\n            hide\n            wait until <(y position) < [259]>\n            show\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n        if <(color water) = [true]> then\n            set [y v] to (jump height)\n            start sound [swim v]\n            switch costume to (swim v)\n            wait until <not <<key (up arrow v) pressed?> or <key (w v) pressed?>>>\n        else\n            start sound [jump v]\n            wait until <not <<key (up arrow v) pressed?> or <key (w v) pressed?>>>\n        end\n    end\n    if <<key (down arrow v) pressed?> or <key (s v) pressed?>> then\n        repeat until <not <<key (down arrow v) pressed?> or <key (s v) pressed?>>>\n            switch costume to (duck v)\n        end\n    end\nend\n\n@Level\n\nwhen flag clicked\nset [level v] to [1]\nnext level\nforever\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        repeat until <not <<key (right arrow v) pressed?> or <key (d v) pressed?>>>\n            if <([game playing? v] of [player v]) = [true]> then\n                change x by ((speed) * (-1))\n                wait (0.01) seconds\n            end\n        end\n    end\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        repeat until <not <<key (left arrow v) pressed?> or <key (a v) pressed?>>>\n            if <([game playing? v] of [player v]) = [true]> then\n                change x by (speed)\n                wait (0.01) seconds\n            end\n        end\n    end\nend\n\nwhen I receive [hurt v]\ngo to x: (740) y: (420)\n\nwhen [r v] key pressed\ngo to x: (740) y: (420)\n\nwhen I receive [next level v]\nchange [level v] by (1)\nnext level\ngo to x: (740) y: (420)\n\ndefine next level\nswitch costume to (none v)\nset size to (400) %\nswitch costume to (level)\ngo to x: (740) y: (420)\n\n
This is not supposed to be a game! This is a base used for remixing and making your own scrolling platformer. Change the character, levels and background to make your own game.\n\nRed is lava, blue is water, purple is bouncy, and yellow is the end of the level. Press R to restart. If you have any questions about making a platformer with this base, ask in the comments and I'll help!