Platformer Engine #Games #Tutorials


@Stage\n\nwhen I receive [game start v]\nstop all sounds\nforever\n    play sound [y2mate v] until done\nend\n\n@blank\n\n@Player\n\ndefine Y collision\nif <<<touching (ground v)?> or <touching (platform v)?>> and <not <[0] < (Py)>>> then\n    repeat until <not <<touching (ground v)?> or <touching (platform v)?>>>\n        change y by (1)\n    end\nelse\n    if <<touching (ground v)?> or <touching (platform v)?>> then\n        change y by ((Py) * (-1))\n        set [py v] to [1]\n        repeat until <not <<touching (ground v)?> or <touching (platform v)?>>>\n            change y by (-1.2)\n            change y by (0.2)\n        end\n    end\nend\n\nwhen I start as a clone\nswitch costume to (5 v)\nrepeat (10)\n    change [ghost v] effect by (10)\n    change size by (-5)\nend\ndelete this clone\n\nwhen I receive [game start v]\nshow\nbroadcast (Reset v)\nset [px v] to [0]\nset [py v] to [0]\nforever\n    if <(Lose) = [0]> then\n        if <[-20] > (Py)> then\n            set [py v] to [-20]\n        else\n            change [py v] by (-0.4)\n            if <<touching (ground v)?> or <touching (platform v)?>> then\n                set [py v] to [0]\n            end\n        end\n        change y by (Py)\n        change y by (1)\n        if <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<((x position) + (10)) < (mouse x)> and <mouse down?>>> then\n            point in direction (90)\n            change [px v] by (1.3)\n        end\n        if <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<(mouse x) < ((-10) + (x position))> and <mouse down?>>> then\n            point in direction (-90)\n            change [px v] by (-1.3)\n        end\n        set [px v] to ((Px) * (0.8))\n        change x by (Px)\n        change y by (1)\n        if <<touching (ground v)?> or <touching (platform v)?>> then\n            change x by ((Px) * (-1))\n            if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<((y position) + (10)) < (mouse y)> and <mouse down?>>> then\n                change y by (1)\n                set [py v] to [6]\n                if <(Px) > [0]> then\n                    set [px v] to [-6]\n                else\n                    set [px v] to [6]\n                end\n            else\n                set [px v] to [0]\n            end\n        end\n        change y by (-1)\n        if <not <<touching (ground v)?> or <touching (platform v)?>>> then\n            change y by (-1)\n        end\n        if <not <<touching (ground v)?> or <touching (platform v)?>>> then\n            change y by (-1)\n        end\n        if <<<touching (ground v)?> or <touching (platform v)?>> and <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<((y position) + (10)) < (mouse y)> and <mouse down?>>>> then\n            set [py v] to [8]\n            change y by (Py)\n        end\n        change y by (1)\n        Y collision\n        change y by (-1)\n        change y by (-1)\n    end\nend\n\nwhen I receive [game start v]\nswitch costume to (1 v)\nforever\n    wait (5) seconds\n    repeat (4)\n        next costume\n        wait (0.05) seconds\n    end\n    switch costume to (4 v)\n    wait (0.05) seconds\n    switch costume to (3 v)\n    wait (0.05) seconds\n    switch costume to (2 v)\n    wait (0.05) seconds\n    switch costume to (1 v)\n    wait (0.05) seconds\nend\n\nwhen I receive [game start v]\nforever\n    create clone of (_myself_ v)\nend\n\nwhen I receive [game start v]\nforever\n    if <touching (platform v)?> then\n        change x by ((([abs v] of (Plat x) ) / (Plat x)) * (2))\n    end\nend\n\nwhen I receive [reset v]\ngo to x: (-225) y: (-50)\nset rotation style [left-right v]\nset [px v] to [0]\nset [py v] to [0]\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nset [lose v] to [0]\n\nwhen I receive [game start v]\nrepeat until <(EG) = [1]>\n    if <touching (spike v)?> then\n        set [lose v] to [1]\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n        broadcast (Reset v)\n    end\n    if <(y position) < [-60]> then\n        broadcast (Reset v)\n    end\n    if <key (r v) pressed?> then\n        broadcast (Reset v)\n    end\nend\nhide\n\nwhen flag clicked\nbroadcast (Game Start v)\n\n@Ground\n\nwhen I receive [game start v]\nshow\nswitch costume to (costume1 v)\nrepeat until <(costume [number v]) = [5]>\n    go to [front v] layer\n    if <([x position v] of [player v]) = [239]> then\n        next costume\n        broadcast (Reset v)\n    end\nend\nforever\n    if <(costume [number v]) = [5]> then\n        if <([x position v] of [player v]) = [239]> then\n            next costume\n            set [eg v] to [1]\n            hide\n        end\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nset [eg v] to [0]\n\n@Thumbnail\n\nwhen flag clicked\nhide\ngo to [front v] layer\ngo [backward v] (1) layers\n\nwhen flag clicked\nhide\nreset timer\nforever\n    set [timer v] to ((timer) + (0.1))\nend\n\nwhen [timer v] > (Timer)\ngo to [front v] layer\nshow\n\n@Spike\n\nwhen I receive [game start v]\nshow\nrepeat until <(EG) = [1]>\n    go to x: (0) y: (0)\n    switch costume to ([costume # v] of [ground v])\nend\nhide\n\nwhen flag clicked\nhide\n\n@Sprite1\n\nwhen I receive [game start v]\nforever\n    if <(EG) = [1]> then\n        go to [front v] layer\n        show\n    else\n        hide\n    end\nend\n\nwhen I receive [game start v]\nhide\n\n@notif\n\nwhen flag clicked\ngo to x: (0) y: (50)\nhide\nwait (pick random (8) to (15)) seconds\nshow\nrepeat until <(y position) < [6]>\n    change y by (((5) - (y position)) / (6))\nend\nwait (3.5) seconds\nrepeat until <(y position) > [49.5]>\n    change y by (((y position) + (5)) / (5))\nend\nhide\nforever\n    wait (pick random (14) to (26)) seconds\n    show\n    repeat until <(y position) < [6]>\n        change y by (((5) - (y position)) / (6))\n    end\n    wait (3.5) seconds\n    repeat until <(y position) > [49.5]>\n        change y by (((y position) + (5)) / (5))\n    end\n    hide\nend\n\nwhen I receive [alert v]\nstop [other scripts in sprite v]\nrepeat (5)\n    change [ghost v] effect by (20)\nend\nhide\n\nwhen I receive [tick v]\ngo to [front v] layer\n\n@Land\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nset [eg v] to [0]\n\nwhen I receive [game start v]\nshow\nrepeat until <(EG) = [1]>\n    go to x: (0) y: (0)\n    switch costume to ([costume # v] of [ground v])\nend\nhide\n\n