Platformer engine
@Stage\n\nwhen flag clicked\nswitch backdrop to (1 v)\n\nwhen I receive [instructions v]\nswitch backdrop to (2 v)\n\n@block\n\nwhen flag clicked\nset [block : v] to [0]\nhide\nset drag mode [not draggable v]\n\nwhen I receive [start v]\nforever\n    point in direction (90)\n    if <not <(block :) = [0]>> then\n        point in direction (90)\n        if <(mouse y) > ((y position) + (5))> then\n            change y by (10)\n        end\n        if <(mouse y) < ((y position) - (5))> then\n            change y by (-10)\n        end\n    end\nend\n\nwhen I receive [start v]\nforever\n    if <not <(block :) = [0]>> then\n        show\n        set [ghost v] effect to (60)\n        if <mouse down?> then\n            if <<(block :) = [1]> or <(block :) > [1]>> then\n                if <not <<<touching (background v)?> or <touching (spikes v)?>> or <touching (pinguin v)?>>> then\n                    set [brightness v] effect to (10)\n                    create clone of (_myself_ v)\n                    change [block : v] by (-1)\n                    wait until <not <mouse down?>>\n                    set [brightness v] effect to (0)\n                end\n            end\n        end\n    else\n        hide\n    end\nend\n\nwhen I receive [menu v]\nerase all\nset [block : v] to [0]\nset [ghost v] effect to (100)\n\nwhen I receive [reset block v]\nset [brightness v] effect to (0)\nforever\n    if <(level) = [1]> then\n        set [block : v] to [0]\n        stop [this script v]\n    end\n    if <(level) = [2]> then\n        set [block : v] to [0]\n        stop [this script v]\n    end\n    if <(level) = [3]> then\n        set [block : v] to [0]\n        stop [this script v]\n    end\n    if <(level) = [4]> then\n        set [block : v] to [0]\n        stop [this script v]\n    end\n    if <(level) = [5]> then\n        set [block : v] to [1]\n        repeat (10)\n            repeat (10)\n                change [brightness v] effect by (5)\n            end\n            repeat (10)\n                change [brightness v] effect by (-5)\n            end\n        end\n        stop [this script v]\n    end\n    if <(level) = [6]> then\n        set [block : v] to [3]\n        stop [this script v]\n    end\n    if <(level) = [7]> then\n        set [block : v] to [0]\n        stop [this script v]\n    end\nend\n\nwhen I receive [reset block v]\nset x to (-6)\nset y to (0)\nset size to (13) %\nforever\n    if <not <(block :) = [0]>> then\n        show\n        wait (0.25) seconds\n        repeat until <(block :) = [0]>\n            if <(mouse x) > ((x position) + (10))> then\n                change x by (20)\n            end\n            if <(mouse x) < ((x position) - (10))> then\n                change x by (-20)\n            end\n        end\n        stop [this script v]\n    else\n        hide\n    end\nend\n\nwhen I receive [reset block v]\nset [brightness v] effect to (0)\nif <(level) = [8]> then\n    set [block : v] to [5]\n    stop [this script v]\nend\nif <(level) = [9]> then\n    set [block : v] to [2]\n    stop [this script v]\nend\nif <(level) = [10]> then\n    set [block : v] to [1]\n    stop [this script v]\nend\nif <(level) = [11]> then\n    set [block : v] to [1]\n    stop [this script v]\nend\nif <(level) = [12]> then\n    set [block : v] to [0]\n    stop [this script v]\nend\n\nwhen I receive [reset block v]\nset [brightness v] effect to (0)\nif <(level) = [13]> then\n    set [block : v] to [0]\n    stop [this script v]\nend\nif <(level) = [14]> then\n    set [block : v] to [3]\n    stop [this script v]\nend\nif <(level) = [15]> then\n    set [block : v] to [5]\n    stop [this script v]\nend\nif <(level) = [16]> then\n    set [block : v] to [3]\n    stop [this script v]\nend\nif <(level) = [17]> then\n    set [block : v] to [0]\n    stop [this script v]\nend\n\nwhen I receive [reset block v]\nset [brightness v] effect to (0)\nif <(level) = [18]> then\n    set [block : v] to [1]\n    stop [this script v]\nend\nif <(level) = [19]> then\n    set [block : v] to [3]\n    stop [this script v]\nend\nif <(level) = [20]> then\n    set [block : v] to [1]\n    stop [this script v]\nend\nif <(level) = [21]> then\n    set [block : v] to [0]\n    stop [this script v]\nend\nif <(level) = [22]> then\n    set [block : v] to [0]\n    stop [this script v]\nend\n\nwhen I receive [reset block v]\ndelete this clone\n\nwhen I start as a clone\nset [ghost v] effect to (0)\nshow\n\n@background\n\nwhen flag clicked\nset volume to (50) %\ngo to [back v] layer\nset [block : v] to [0]\nset [level v] to [0]\nset [ghost v] effect to (100)\nswitch costume to (0 v)\ngo to x: (0) y: (0)\nforever\n    go to [back v] layer\n    go [forward v] (10) layers\nend\n\nwhen I receive [global start v]\nset [level v] to [1]\nswitch costume to (1 v)\ngo to x: (0) y: (0)\nforever\n    if <([x position v] of [pinguin v]) > [239]> then\n        change [level v] by (1)\n        start sound [Coin v]\n        switch costume to ((level) + (1))\n        broadcast (next level v)\n        broadcast (instructions2 v)\n        broadcast (reset block v)\n        wait until <not <([x position v] of [pinguin v]) > [239]>>\n        wait until <([x position v] of [pinguin v]) > [239]>\n    end\nend\n\nwhen I receive [start v]\nswitch costume to (level)\nrepeat (20)\n    change [ghost v] effect by (-5)\nend\n\n@thumbnail\n\nwhen flag clicked\ngo to [front v] layer\ngo to x: (0) y: (0)\nset [ghost v] effect to (0)\nwait (2.5) seconds\nbroadcast (menu v)\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nbroadcast (thumbnail v)\n\nwhen I receive [thumbnail v]\nforever\n    go to x: (0) y: (0)\n    go to [front v] layer\n    set [ghost v] effect to (100)\n    show\nend\n\n@snow\n\nwhen flag clicked\nset [ghost v] effect to (100)\nset size to (0) %\ngo to x: (-300) y: (250)\nforever\n    create clone of (_myself_ v)\n    wait (pick random (0.005) to (0.01)) seconds\nend\n\nwhen I start as a clone\nset size to (pick random (60) to (80)) %\ngo to x: (pick random (-250) to (250)) y: (220)\nrepeat (4)\n    change [ghost v] effect by (-20)\nend\nrepeat (2)\n    change y by (-5)\n    change x by (wind)\nend\nrepeat until <<<touching (background v)?> or <<touching (hibox v)?> or <<touching (spikes v)?> or <touching (move_spikes v)?>>>> or <touching (igloo v)?>>\n    change y by (-5)\n    change x by (wind)\nend\nrepeat (10)\n    if <not <touching color (#ffffff)?>> then\n        change y by (-2)\n        change x by ((wind) / (2.5))\n    end\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nwhen flag clicked\nforever\n    set [wind v] to (pick random (-1) to (1))\n    wait (5) seconds\nend\n\nwhen flag clicked\nset [block : v] to [0]\nset [ghost v] effect to (100)\n\n@block number\n\nwhen flag clicked\nset [block : v] to [0]\nset [ghost v] effect to (100)\n\nwhen I receive [global start v]\ngo to x: (-210) y: (150)\nset size to (20) %\nset [ghost v] effect to (100)\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nforever\n    if <(level) = [22]> then\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n    else\n        set [ghost v] effect to (0)\n    end\nend\n\n@number\n\nwhen flag clicked\nset [block : v] to [0]\nset [ghost v] effect to (100)\nforever\n    switch costume to ((block :) + (1))\n    if <(block :) = [0]> then\n        go to x: (-210) y: (153)\n        set size to (25) %\n    else\n        set size to (18) %\n        go to x: (-190) y: (160)\n    end\nend\n\nwhen I receive [global start v]\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\ngo to [front v] layer\nforever\n    if <(level) = [22]> then\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n    else\n        set [ghost v] effect to (0)\n    end\nend\n\n@spikes\n\nwhen flag clicked\nset [block : v] to [0]\n\nwhen flag clicked\nhide\nset size to (100) %\ngo to x: (0) y: (0)\nforever\n    go to [back v] layer\nend\n\nwhen I receive [next level v]\nhide\nswitch costume to (level)\nshow\n\n@move_spikes\n\nwhen flag clicked\nhide\nset size to (100) %\ngo to x: (0) y: (0)\nforever\n    go to [back v] layer\nend\n\nwhen I receive [next level v]\nhide\nswitch costume to (level)\nshow\ngo to x: (0) y: (0)\nrepeat until <not <(costume [name v]) = (level)>>\n    if <<<<(level) = [13]> or <(level) = [14]>> or <(level) = [16]>> or <(level) = [20]>> then\n        repeat (30)\n            if <(costume [name v]) = (level)> then\n                change x by (1)\n            end\n        end\n        repeat (30)\n            if <(costume [name v]) = (level)> then\n                change x by (-1)\n            end\n        end\n    end\n    if <(level) = [12]> then\n        repeat (15)\n            if <(costume [name v]) = (level)> then\n                change y by (-3)\n            end\n        end\n        repeat (30)\n            if <(costume [name v]) = (level)> then\n                change y by (1.5)\n            end\n        end\n    end\n    if <(level) = [15]> then\n        repeat (30)\n            if <(costume [name v]) = (level)> then\n                change y by (-2)\n            end\n        end\n        repeat (30)\n            if <(costume [name v]) = (level)> then\n                change y by (2)\n            end\n        end\n    end\n    if <(level) = [17]> then\n        repeat (30)\n            if <(costume [name v]) = (level)> then\n                change x by (3)\n            end\n        end\n        repeat (15)\n            if <(costume [name v]) = (level)> then\n                change y by (-3)\n            end\n        end\n        repeat (30)\n            if <(costume [name v]) = (level)> then\n                change x by (-3)\n            end\n        end\n        repeat (15)\n            if <(costume [name v]) = (level)> then\n                change y by (3)\n            end\n        end\n    end\n    if <(level) = [18]> then\n        repeat (15)\n            if <(costume [name v]) = (level)> then\n                change x by (-2)\n            end\n        end\n        repeat (15)\n            if <(costume [name v]) = (level)> then\n                change x by (2)\n            end\n        end\n    end\nend\nhide\n\n@level\n\nwhen flag clicked\nset [block : v] to [0]\nset [ghost v] effect to (100)\n\nwhen I receive [global start v]\nswitch costume to (1 v)\nset [ghost v] effect to (100)\ngo to [back v] layer\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nforever\n    go to x: (200) y: (145)\n    set size to (50) %\n    switch costume to (level)\n    if <(level) > [20]> then\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n    end\nend\n\n@igloo\n\nwhen flag clicked\nset [level v] to [0]\nswitch costume to (igloo v)\nset [ghost v] effect to (100)\nhide\ngo to [back v] layer\nforever\n    go to [back v] layer\n    go [forward v] (5) layers\n    go to x: (0) y: (0)\nend\n\nwhen flag clicked\nset [block : v] to [0]\nset [ghost v] effect to (100)\n\nwhen flag clicked\nset [ghost v] effect to (100)\nwait until <(level) = [22]>\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nwait until <([x position v] of [pinguin v]) > [100]>\nbroadcast (win !!! v)\n\n@sound volume\n\nwhen flag clicked\nset [ghost v] effect to (100)\ngo to x: (-195) y: (140)\nset size to (20) %\nset volume to (0) %\nforever\n    play sound [DEAF KEV - Invincible \[NCS Release\] \[Mpgun v] until done\nend\n\nwhen I receive [menu v]\ngo to x: (-195) y: (140)\nset size to (20) %\nwait (0.3) seconds\nrepeat (25)\n    change [ghost v] effect by (-4)\nend\nswitch costume to (oui v)\nforever\n    go to x: (-195) y: (140)\n    set size to (20) %\n    if <touching (mouse-pointer v)?> then\n        change size by (5)\n        if <mouse down?> then\n            next costume\n            wait until <not <mouse down?>>\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <(costume [name v]) = [non]> then\n        repeat until <(volume) < [2]>\n            change volume by (-1)\n        end\n        wait until <(costume [name v]) = [oui]>\n    end\nend\n\nwhen flag clicked\nswitch costume to (oui v)\nforever\n    if <(costume [name v]) = [oui]> then\n        repeat until <(volume) > [25]>\n            change volume by (1)\n        end\n        wait until <(costume [name v]) = [non]>\n    end\nend\n\nwhen I receive [global start v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\nwhen I receive [instructions v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\n@button play\n\nwhen flag clicked\nset size to (100) %\nset [ghost v] effect to (100)\ngo to x: (0) y: (0)\n\nwhen I receive [menu v]\nset [ghost v] effect to (100)\ngo to x: (0) y: (0)\nwait (0.2) seconds\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nforever\n    go to x: (0) y: (0)\n    change size by (((100) - (size)) / (2))\n    if <touching (mouse-pointer v)?> then\n        change size by (((120) - (size)) / (2))\n        if <mouse down?> then\n            change size by (((90) - (size)) / (2))\n            wait until <not <mouse down?>>\n            set [ghost v] effect to (100)\n            broadcast (start v)\n            broadcast (instructions v)\n            broadcast (reset v)\n            stop [other scripts in sprite v]\n            stop [this script v]\n        end\n    end\nend\n\nwhen I receive [menu v]\nset [ghost v] effect to (100)\ngo to x: (0) y: (0)\nwait (0.2) seconds\nforever\n    repeat (10)\n        change [brightness v] effect by (0.25)\n    end\n    repeat (10)\n        change [brightness v] effect by (-0.25)\n    end\nend\n\n@instructions\n\nwhen flag clicked\nset [press ? v] to [no]\nset [instructions v] to [pas encore]\nset [ghost v] effect to (100)\nforever\n    set size to (60) %\n    go to x: (0) y: (50)\nend\n\nwhen I receive [start v]\nwait (0.5) seconds\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nforever\n    switch costume to (1 v)\n    set [instructions v] to [rien]\n    wait (0.75) seconds\n    set [instructions v] to [droite]\n    switch costume to (2 v)\n    wait (1.5) seconds\n    switch costume to (3 v)\n    set [instructions v] to [rien]\n    wait (0.75) seconds\n    set [instructions v] to [gauche]\n    switch costume to (4 v)\n    wait (1.5) seconds\n    switch costume to (5 v)\n    set [instructions v] to [rien]\n    wait (0.75) seconds\n    set [instructions v] to [haut]\n    switch costume to (6 v)\n    wait (1.5) seconds\nend\n\nwhen I receive [start v]\nwait (0.5) seconds\nforever\n    if <key (any v) pressed?> then\n        stop [other scripts in sprite v]\n        set [instructions v] to []\n        set [level v] to [1]\n        broadcast (global start v)\n        broadcast (instructions2 v)\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n        stop [this script v]\n    end\nend\n\n@Writting instructions\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\nswitch costume to (0 v)\nset size to (70) %\nforever\n    set size to (70) %\n    if <(level) = [21]> then\n        set [ghost v] effect to (100)\n        wait (0.25) seconds\n        go to x: (0) y: (150)\n        set size to (70) %\n        switch costume to (22 v)\n        repeat (10)\n            change [ghost v] effect by (-10)\n        end\n        wait (8) seconds\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n        stop [this script v]\n    end\nend\n\nwhen I receive [instructions v]\ngo to x: (0) y: (0)\nwait until <(level) = [0]>\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nswitch costume to (0 v)\ngo to [front v] layer\n\nwhen I receive [instructions2 v]\nset [ghost v] effect to (100)\nwait (0.25) seconds\nwait until <(level) < [6]>\ngo to [front v] layer\ngo to x: (0) y: (150)\nset size to (70) %\nswitch costume to ((level) + (1))\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nwait (8) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nstop [this script v]\n\nwhen flag clicked\nforever\n    if <(level) = [22]> then\n        wait (0.25) seconds\n        set [ghost v] effect to (100)\n        go to x: (0) y: (150)\n        set size to (70) %\n        switch costume to (23 v)\n        repeat (10)\n            change [ghost v] effect by (-10)\n        end\n        wait (8) seconds\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n        stop [this script v]\n    end\nend\n\nwhen I receive [win !!! v]\nset [ghost v] effect to (100)\nstop [other scripts in sprite v]\ngo to x: (0) y: (30)\nset size to (70) %\nswitch costume to (24 v)\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\n\n\n@Pinguin\n\ndefine platform physics (jump height) (gravity) (friction) (movement speed) (slope)\nswitch costume to (hitbox v)\nchange y by (y vel)\nif <<<touching (background v)?> or <<touching (block v)?> and <touching color (#ffffff)?>>> or <<touching (move_spikes v)?> or <touching (spikes v)?>>> then\n    if <<<touching (move_spikes v)?> and <touching color (#c2e2f2)?>> or <touching (spikes v)?>> then\n        set [touched spike ? v] to [1]\n        start sound [hit v]\n    end\n    repeat ([abs v] of (y vel) )\n        if <<<touching (background v)?> or <<touching (block v)?> and <touching color (#ffffff)?>>> or <<touching (move_spikes v)?> or <touching (spikes v)?>>> then\n            change y by ((-1) * (([abs v] of (y vel) ) / (y vel)))\n        end\n    end\n    if <<<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <(instructions) = [haut]>> and <not <(y vel) > [0]>>> then\n        set [y vel v] to (jump height)\n        start sound [pop v]\n    else\n        set [y vel v] to [0]\n    end\nelse\n    change [y vel v] by (gravity)\nend\nif <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <(instructions) = [droite]>> then\n    change [x vel v] by (movement speed)\nend\nif <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <(instructions) = [gauche]>> then\n    change [x vel v] by ((-1) * (movement speed))\nend\nset [slope v] to [0]\nchange x by (x vel)\nrepeat until <<(slope) = ((0) - (slope))> or <not <<<touching (background v)?> or <<touching (block v)?> and <touching color (#ffffff)?>>> or <<touching (move_spikes v)?> or <touching (spikes v)?>>>>>\n    change y by (1)\n    change [slope v] by (-1)\nend\nif <<<touching (background v)?> or <<touching (block v)?> and <touching color (#ffffff)?>>> or <<touching (move_spikes v)?> or <touching (spikes v)?>>> then\n    change y by (slope)\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <(instructions) = [haut]>> then\n        if <(x vel) > [0]> then\n            set [x vel v] to [-10]\n        else\n            set [x vel v] to [10]\n        end\n        set [y vel v] to [0]\n    else\n        set [old y v] to (y position)\n        repeat ([abs v] of (x vel) )\n            if <<<touching (background v)?> or <<touching (block v)?> and <touching color (#ffffff)?>>> or <<touching (move_spikes v)?> or <touching (spikes v)?>>> then\n                change y by (1)\n            end\n        end\n        if <<<touching (background v)?> or <<touching (block v)?> and <touching color (#ffffff)?>>> or <<touching (move_spikes v)?> or <touching (spikes v)?>>> then\n            set y to (old y)\n            repeat ([ceiling v] of ([abs v] of (x vel) ) )\n                if <<<touching (background v)?> or <<touching (block v)?> and <touching color (#ffffff)?>>> or <<touching (move_spikes v)?> or <touching (spikes v)?>>> then\n                    change x by ((-1) * (([abs v] of (x vel) ) / (x vel)))\n                end\n            end\n            set [x vel v] to [0]\n        end\n    end\nend\nset [x vel v] to ((x vel) * (friction))\nswitch costume to (walk)\n\nwhen I receive [reset v]\ngo to [back v] layer\ngo [forward v] (2) layers\ngo to x: (-200) y: (10)\nset [walk v] to [1]\nset [touched spike ? v] to [0]\nset [y vel v] to [0]\nset [x vel v] to [0]\nswitch costume to (1 v)\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nforever\n    if <(level) = [22]> then\n        platform physics (4) (-1) (0.8) (1.4) [8]\n    else\n        platform physics (12) (-1) (0.8) (1.2) [8]\n    end\nend\n\nwhen flag clicked\nset [walk v] to [1]\nswitch costume to (1 v)\nset [ghost v] effect to (100)\nforever\n    go to [back v] layer\nend\n\nwhen I receive [reset v]\nforever\n    if <(level) > [21]> then\n        if <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <(instructions) = [droite]>> then\n            set [walk v] to [9]\n            wait (0.05) seconds\n            repeat until <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <(instructions) = [gauche]>>\n                set [walk v] to [10]\n            end\n        end\n        if <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <(instructions) = [gauche]>> then\n            set [walk v] to [11]\n            repeat (3)\n                wait (0.05) seconds\n                change [walk v] by (1)\n            end\n            wait (0.05) seconds\n            set [walk v] to [11]\n        end\n    else\n        if <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <(instructions) = [droite]>> then\n            set [walk v] to [1]\n            repeat (3)\n                wait (0.05) seconds\n                change [walk v] by (1)\n            end\n            wait (0.05) seconds\n            set [walk v] to [1]\n        end\n        if <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <(instructions) = [gauche]>> then\n            set [walk v] to [11]\n            repeat (3)\n                wait (0.05) seconds\n                change [walk v] by (1)\n            end\n            wait (0.05) seconds\n            set [walk v] to [11]\n        end\n    end\nend\n\nwhen I receive [reset v]\nwait until <(touched spike ?) = [1]>\nstop [other scripts in sprite v]\nif <(walk) < [11]> then\n    switch costume to (6 v)\n    repeat (2)\n        next costume\n    end\nelse\n    switch costume to (16 v)\n    repeat (2)\n        next costume\n    end\nend\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nbroadcast (reset v)\nbroadcast (reset block v)\n\nwhen I receive [next level v]\ngo to x: (-230) y: (10)\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\n\nwhen I receive [win !!! v]\nstop [other scripts in sprite v]\n\ngo [forward v] (2) layers\n\n
This is a much older project, i recommend you see my newer stuff.\n\nAlso it is very unlikely there will ever be a sequel. \n\n\n