2D Platformer Engine
@Stage\n\nwhen I receive [level start v]\nforever\n    set volume to (50) %\n    play sound [yisland v] until done\nend\n\n@Blank\n\n@Player\n\nwhen I receive [level start v]\nset size to (200) %\nset rotation style [left-right v]\ngo to x: (0) y: (160)\npoint in direction (90)\ngo to [front v] layer\nshow\nset [scroll x v] to [-400]\nset [speed y v] to [0]\nset [falling? v] to [10]\nforever\n    switch costume to (hitbox v)\n    if <(speed y) < [4]> then\n        change [speed y v] by (-1)\n    else\n        change [speed y v] by (-2)\n    end\n    change y by (speed y)\n    check for floor  <(speed y) > [0]>\n    if <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>> then\n        if <<key (left arrow v) pressed?> and <key (right arrow v) pressed?>> then\n            set [frame v] to [0]\n        else\n            if <key (left arrow v) pressed?> then\n                point in direction (-90)\n                walk at speed (-5)\n            end\n            if <key (right arrow v) pressed?> then\n                point in direction (90)\n                walk at speed (5)\n            end\n        end\n    else\n        set [frame v] to [0]\n    end\n    if <<key (up arrow v) pressed?> or <key (space v) pressed?>> then\n        if <<(jump key) = [0]> and <(falling?) < [3]>> then\n            set [speed y v] to [24]\n            set [falling? v] to [6]\n            set [jump key v] to [1]\n        end\n    else\n        set [jump key v] to [0]\n    end\n    if <(y position) < [-179]> then\n        stop all sounds\n        go to x: (0) y: (100)\n        point in direction (90)\n        set [speed y v] to [0]\n        set [scroll x v] to [-400]\n    end\n    set [touching secret layer? v] to <touching (front layer v)?>\n    set player costume\nend\n\ndefine check for floor  <up?>\nchange [falling? v] by (1)\nrepeat until <not <touching (ground v)?>>\n    if <up?> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling? v] to [0]\n    end\n    set [speed y v] to [0]\nend\n\ndefine walk at speed (speed)\nchange x by (speed)\nset [slope v] to [0]\nrepeat until <<(slope) = [8]> or <not <touching (ground v)?>>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <(slope) = [8]> then\n    change x by ((speed) * (-1))\n    change y by ((slope) * (-1))\nend\nchange [frame v] by (0.5)\nchange [scroll x v] by (x position)\nset x to (0)\n\ndefine set player costume\nif <(falling?) < [6]> then\n    if <(frame) = [0]> then\n        switch costume to (stand v)\n    else\n        switch costume to (join [walk] ([floor v] of ((1) + ((frame) mod (6))) ))\n    end\nelse\n    if <(speed y) > [0]> then\n        switch costume to (jump v)\n    else\n        switch costume to (fall v)\n    end\nend\n\nwhen flag clicked\nbroadcast (level start v)\n\n@Ground\n\nwhen I receive [level start v]\nhide\nswitch costume to (part0 v)\ncreate clone of (_myself_ v)\nnext costume\nrepeat until <(costume [name v]) = [part0]>\n    create clone of (_myself_ v)\n    next costume\nend\n\nwhen I start as a clone\nforever\n    go to x: (((scroll x) * (-1)) + (((letter (5) of (costume [name v])) - (1)) * (960))) y: (180)\n    if <(x position) = (((scroll x) * (-1)) + (((letter (5) of (costume [name v])) - (1)) * (960)))> then\n        show\n    else\n        hide\n    end\nend\n\n@Front Layer\n\nwhen I receive [level start v]\nhide\nswitch costume to (part0 v)\ncreate clone of (_myself_ v)\nnext costume\nrepeat until <(costume [name v]) = [part0]>\n    create clone of (_myself_ v)\n    next costume\nend\n\nwhen I start as a clone\nforever\n    go to x: (((scroll x) * (-1)) + (((letter (5) of (costume [name v])) - (1)) * (960))) y: (180)\n    if <(x position) = (((scroll x) * (-1)) + (((letter (5) of (costume [name v])) - (1)) * (960)))> then\n        show\n    else\n        hide\n    end\nend\n\nwhen I start as a clone\nforever\n    if <([touching secret layer? v] of [player v]) = [true]> then\n        go to [front v] layer\n        set [ghost v] effect to (0)\n        repeat (20)\n            change [ghost v] effect by (5)\n        end\n        wait until <not <([touching secret layer? v] of [player v]) = [true]>>\n    end\n    if <not <([touching secret layer? v] of [player v]) = [true]>> then\n        set [ghost v] effect to (100)\n        repeat (20)\n            change [ghost v] effect by (-5)\n        end\n        go to [front v] layer\n        wait until <([touching secret layer? v] of [player v]) = [true]>\n    end\nend\n\n@Back Layer\n\nwhen I receive [level start v]\nhide\nswitch costume to (part0 v)\ncreate clone of (_myself_ v)\nnext costume\nrepeat until <(costume [name v]) = [part0]>\n    create clone of (_myself_ v)\n    next costume\nend\n\nwhen I start as a clone\nforever\n    go to x: (((scroll x) * (-1)) + (((letter (5) of (costume [name v])) - (1)) * (960))) y: (180)\n    if <(x position) = (((scroll x) * (-1)) + (((letter (5) of (costume [name v])) - (1)) * (960)))> then\n        go to [back v] layer\n        show\n    else\n        hide\n    end\nend\n\n@Objects\n\nwhen I receive [level start v]\n\nhide\nswitch costume to (part0 v)\ncreate clone of (_myself_ v)\nnext costume\n\nrepeat until <(costume [name v]) = [part0]>\n    create clone of (_myself_ v)\n    next costume\nend\n\nwhen I start as a clone\nforever\n    go to x: ((4) * (16)) y: (0)\n    show\nend\n\nif <(x position) = (((scroll x) * (-1)) + (((letter (5) of (costume [name v])) - (1)) * (960)))> then\n    show\nelse\n    hide\nend\n\n
Here's a new platformer engine I've been working on,\nFeel free to remix the project and add more stuff.\nArrow keys to move, space/up to jump, yada yada.\n\nThis engine uses large 480x360 images for all the non-moving grass blocks and mushrooms, while all my other engines so far instead have a seperate clone/stamped sprite for each block in the level, which sometimes makes Scratch lag and limits the amount of stuff you can put in the level.\n\nThis still uses the old cloning method for item boxes and objects that change when the player interacts with them.\nIt also introduces a background layer for you to decorate the level with flowers and other stuff, but don't want the player to collide with.