Platformer with time jumps engine


@Stage\n\n@Player\n\ndefine Touch Ground <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 (direction) (speed)\npoint in direction (direction)\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 ((0) - (speed))\n    change y by ((0) - (slope))\n    if <<<key (w v) pressed?> or <key (up arrow v) pressed?>> and <([abs v] of (speed) ) > [3]>> then\n        if <(wall jump) = [0]> then\n            set [speed x v] to ((-1.2) * (speed))\n            set [speed y v] to [11]\n            set [falling? v] to [6]\n            set [wall jump v] to [15]\n        end\n    else\n        set [speed x v] to [0]\n    end\nend\nif <(speed) < [0]> then\n    change [frame v] by ((speed) / (-8))\nelse\n    change [frame v] by ((speed) / (8))\nend\n\ndefine Set Costume\nif <(falling?) < [6]> then\n    if <(frame) = [0]> then\n        switch costume to (stand_1 v)\n    else\n        switch costume to ([floor v] of ((4) + ((frame) mod (8))) )\n    end\nelse\n    if <(speed y) > [0]> then\n        switch costume to (jump_1 v)\n    else\n        switch costume to (fall_1 v)\n    end\nend\n\nwhen I receive [new level v]\nset [clone? v] to [0]\ndelete all of [framex v]\ndelete all of [framey v]\nset size to (25) %\nset rotation style [left-right v]\ngo to x: (0) y: (100)\nshow\nset [speed y v] to [0]\nset [falling? v] to [10]\nforever\n    switch costume to (hitbox v)\n    if <<(speed y) < [4]> or <<key (w v) pressed?> or <key (up arrow v) pressed?>>> 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    Touch Ground <(speed y) > [0]>\n    if <key (space v) pressed?> then\n        if <(teleporttimer) < [0]> then\n            start sound [Boom Cloud v]\n            set x to (item (30) of [framex v])\n            set y to (item (30) of [framey v])\n        end\n        set [teleporttimer v] to [30]\n    else\n        change [teleporttimer v] by (-1)\n    end\n    if <(wall jump) > [0]> then\n        change [wall jump v] by (-1)\n    else\n        set [speed x v] to ((speed x) * (0.7))\n        if <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n            change [speed x v] by (-1.5)\n        end\n        if <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n            change [speed x v] by (1.5)\n        end\n    end\n    if <(speed x) < [-0.5]> then\n        Walk (-90) (speed x)\n    else\n        if <(speed x) > [0.5]> then\n            Walk (90) (speed x)\n        else\n            set [frame v] to [0]\n        end\n    end\n    if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n        if <<(jump key) = [0]> and <(falling?) < [3]>> then\n            set [jump key v] to [1]\n            set [speed y v] to [14]\n            set [falling? v] to [6]\n        end\n    else\n        set [jump key v] to [0]\n    end\n    if <(y position) < [-180]> then\n        go to x: (0) y: (100)\n        set [speed y v] to [0]\n    end\n    Set Costume\n    create clone of (_myself_ v)\n    insert (round (x position)) at (1) of [framex v] \n    insert (round (y position)) at (1) of [framey v] \n    delete (31) of [framex v]\n    delete (31) of [framey v]\nend\n\nwhen flag clicked\nbroadcast (new level v)\n\nwhen [r v] key pressed\nbroadcast (new level v)\n\nwhen I start as a clone\nset [clone? v] to [1]\nrepeat (30)\n    set [ghost v] effect to (100)\nend\nset [ghost v] effect to (70)\nwait (0.2) seconds\ndelete this clone\n\nwhen I receive [noclones v]\nif <(clone?) = [1]> then\n    hide\nend\n\nwhen flag clicked\nforever\n    if <(teleporttimer) > [0]> then\n        broadcast (noclones v)\n    end\nend\n\n@Ground\n\nwhen I receive [flick v]\nnext costume\n\nwhen I receive [next v]\nchange [level v] by (1)\n\nwhen I receive [new level v]\nif <(level) < [3]> then\n    switch costume to ((level) * (2))\nelse\n    switch costume to (lvl3 v)\nend\n\nwhen flag clicked\nset [level v] to [1]\n\n@lever\n\nwhen I receive [new level v]\nif <(level) < [3]> then\n    switch costume to (((level) * (2)) - (1))\nelse\n    switch costume to (lvl3 v)\nend\nif <(level) = [2]> then\n    wait until <touching (player v)?>\n    broadcast (flick v)\n    next costume\n    play sound [Crank v] until done\n    repeat until <<([y position v] of [player v]) < [-50]> and <touching color (#e5971b)?>>\n        wait until <touching (player v)?>\n    end\n    broadcast (flick v)\n    next costume\n    play sound [Crank v] until done\nelse\n    wait until <touching (player v)?>\n    broadcast (flick v)\n    next costume\n    play sound [Crank v] until done\nend\n\n@exit\n\nwhen flag clicked\ngo to x: (200) y: (-130)\nwait until <touching (player v)?>\nbroadcast (next v) and wait\nnext costume\nbroadcast (new level v)\ngo to x: (-210) y: (145)\nwait until <touching (player v)?>\nbroadcast (next v) and wait\nnext costume\nbroadcast (new level v)\ngo to x: (-210) y: (-150)\nwait until <touching (player v)?>\nbroadcast (next v) and wait\nnext costume\nbroadcast (new level v)\n\n@Thumbnail\n\nwhen flag clicked\ngo to [front v] layer\nset [ghost v] effect to (100)\n\n