Ninja scrolling Platformer

Instructions: mit Leertaste rollen mit w a und d steuern und arrow keys.

@Stage\n\nwhen I receive [start 2 v]\nforever\n    play sound [ruri v] until done\nend\n\n@groundVisible\n\ndefine list\ndelete all of [~level v]\nadd [0,0] to [~level v]\nadd [0,1] to [~level v]\nadd [0,2] to [~level v]\nadd [1,0] to [~level v]\nadd [1,1] to [~level v]\nadd [1,2] to [~level v]\nadd [2,0] to [~level v]\nadd [2,1] to [~level v]\nadd [2,2] to [~level v]\nadd [3,0] to [~level v]\nadd [3,1] to [~level v]\nadd [3,2] to [~level v]\nadd [4,0] to [~level v]\nadd [4,1] to [~level v]\nadd [4,2] to [~level v]\nadd [5,0] to [~level v]\nadd [5,1] to [~level v]\nadd [5,2] to [~level v]\n\ndefine tileController // xPos: (x) yPos: (y)\ngo to x: (x) y: (y)\nswitch costume to (0,0 v)\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    if <<<(~tileColumn) > [0]> and <(~tileRow) > [0]>> and <<(~tileColumn) < ((.totalLevelWidth) + (1))> and <(~tileRow) < ((.totalLevelHeight) + (1))>>> then\n        show\n        switch costume to (item ((((~tileColumn) * (.totalLevelHeight)) - (.totalLevelHeight)) + (~tileRow)) of [~level v])\n    else\n        hide\n    end\nelse\n    hide\nend\nif <(x) > [480]> then\n    change [~tilecolumn v] by (-2)\nend\nif <(x) < [-480]> then\n    change [~tilecolumn v] by (2)\nend\nif <(y) > [360]> then\n    change [~tilerow v] by (-2)\nend\nif <(y) < [-360]> then\n    change [~tilerow v] by (2)\nend\n\nwhen I start as a clone\ngo to [front v] layer\nforever\n    tileController // xPos: (((~tileColumn) * (480)) - (.scrollX)) yPos: (((~tileRow) * (360)) - (.scrollY))\nend\n\nwhen I receive [start 2 v]\nlist\nset [.totallevelwidth v] to [6]\nset [.totallevelheight v] to [3]\nset [~tilecolumn v] to [1]\nset [~tilerow v] to [1]\ncreate clone of (_myself_ v)\nset [~tilecolumn v] to [1]\nset [~tilerow v] to [2]\ncreate clone of (_myself_ v)\nset [~tilecolumn v] to [2]\nset [~tilerow v] to [1]\ncreate clone of (_myself_ v)\nset [~tilecolumn v] to [2]\nset [~tilerow v] to [2]\ncreate clone of (_myself_ v)\n\n@ground\n\ndefine list\ndelete all of [~level v]\nadd [0,0] to [~level v]\nadd [0,1] to [~level v]\nadd [0,2] to [~level v]\nadd [1,0] to [~level v]\nadd [1,1] to [~level v]\nadd [1,2] to [~level v]\nadd [2,0] to [~level v]\nadd [2,1] to [~level v]\nadd [2,2] to [~level v]\nadd [3,0] to [~level v]\nadd [3,1] to [~level v]\nadd [3,2] to [~level v]\nadd [4,0] to [~level v]\nadd [4,1] to [~level v]\nadd [4,2] to [~level v]\nadd [5,0] to [~level v]\nadd [5,1] to [~level v]\nadd [5,2] to [~level v]\n\nwhen I start as a clone\nforever\n    tileController // xPos: (((~tileColumn) * (480)) - (.scrollX)) yPos: (((~tileRow) * (360)) - (.scrollY))\nend\n\ndefine tileController // xPos: (x) yPos: (y)\ngo to x: (x) y: (y)\nswitch costume to (0,0 v)\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    if <<<(~tileColumn) > [0]> and <(~tileRow) > [0]>> and <<(~tileColumn) < ((.totalLevelWidth) + (1))> and <(~tileRow) < ((.totalLevelHeight) + (1))>>> then\n        show\n        switch costume to (item ((((~tileColumn) * (.totalLevelHeight)) - (.totalLevelHeight)) + (~tileRow)) of [~level v])\n    else\n        hide\n    end\nelse\n    hide\nend\nif <(x) > [480]> then\n    change [~tilecolumn v] by (-2)\nend\nif <(x) < [-480]> then\n    change [~tilecolumn v] by (2)\nend\nif <(y) > [360]> then\n    change [~tilerow v] by (-2)\nend\nif <(y) < [-360]> then\n    change [~tilerow v] by (2)\nend\n\nwhen I receive [start 2 v]\nlist\nset [ghost v] effect to (100)\nset [.totallevelwidth v] to [6]\nset [.totallevelheight v] to [3]\nset [~tilecolumn v] to [1]\nset [~tilerow v] to [1]\ncreate clone of (_myself_ v)\nset [~tilecolumn v] to [1]\nset [~tilerow v] to [2]\ncreate clone of (_myself_ v)\nset [~tilecolumn v] to [2]\nset [~tilerow v] to [1]\ncreate clone of (_myself_ v)\nset [~tilecolumn v] to [2]\nset [~tilerow v] to [2]\ncreate clone of (_myself_ v)\n\n@player\n\nwhen I receive [reset v]\nshow\ngo to x: (0) y: (0)\nset [~xspeed v] to [0]\nset [~yspeed v] to [0]\nset [~slope v] to [0]\nset [~lockmovement v] to [n/a]\nset [.falldamage v] to [0]\nset [.scrollx v] to [0]\n\nwhen I receive [start v]\nbroadcast (reset v) and wait\nbroadcast (startTimer v)\nforever\n    platformer // moveSpeed: [1.24] jumpHeight: [27] gravity: [-2.45] friction: [0.87] wallJumpXForce: [22] wallJumpYForce: [30] fallMax: [-50] slideSpeed: [-1.7]\n    camera\nend\n\ndefine platformer // moveSpeed: (movespeed) jumpHeight: (jumpheight) gravity: (gravity) friction: (friction) wallJumpXForce: (walljumpxforce) wallJumpYForce: (walljumpyforce) fallMax: (fallmax) slideSpeed: (slidespeed)\nset [player: ~oldx v] to (x position)\nset [player: ~oldy v] to (y position)\nif <(.respawning) = [n]> then\n    set rotation style [don't rotate v]\n    switch costume to (hitbox v)\n    if <<<key (d v) pressed?> or <key (right arrow v) pressed?>> and <not <(~lockMovement) = [r]>>> then\n        change [~xspeed v] by (movespeed)\n    end\n    if <<<key (a v) pressed?> or <key (left arrow v) pressed?>> and <not <(~lockMovement) = [l]>>> then\n        change [~xspeed v] by ((movespeed) * (-1))\n    end\n    set [~xspeed v] to ((~xSpeed) * (friction))\n    change [~yspeed v] by (gravity)\n    change y by (~ySpeed)\n    change [.falldamage v] by <<touching (ground v)?> and <<(~ySpeed) < ((fallmax) - (1))> and <(.touchingWall?) = [n]>>>\n    if <(~ySpeed) < [0]> then\n        repeat until <not <touching (ground v)?>>\n            change y by (1)\n            set [~yspeed v] to [0]\n            set [~canjump? v] to [1]\n        end\n    else\n        repeat until <not <touching (ground v)?>>\n            change y by (-1)\n            set [~yspeed v] to [0]\n            set [~canjump? v] to [0]\n        end\n    end\n    change x by (~xSpeed)\n    set [~slope v] to [0]\n    if <<<key (w v) pressed?> or <key (up arrow v) pressed?>> and <(~canJump?) = [1]>> then\n        set [~yspeed v] to (jumpheight)\n        set [~canjump? v] to [0]\n    end\n    repeat until <<(~slope) = [8]> or <not <touching (ground v)?>>>\n        change [~slope v] by (1)\n        change y by (1)\n    end\n    if <(~slope) = [8]> then\n        change x by ((0) - (~xSpeed))\n        change y by ((0) - (~slope))\n        if <<<<key (a v) pressed?> or <key (d v) pressed?>> or <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>>> and <(~ySpeed) < [0]>> then\n            set [~yspeed v] to (slidespeed)\n            set [.state v] to [slide]\n            if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n                broadcast (wallJump v)\n                set [~yspeed v] to (walljumpyforce)\n                if <(~xSpeed) > [0]> then\n                    set [~xspeed v] to ((walljumpxforce) * (-1))\n                    set [~lockmovement v] to [r]\n                else\n                    set [~xspeed v] to (walljumpxforce)\n                    set [~lockmovement v] to [l]\n                end\n            end\n        end\n    end\n    if <(~ySpeed) < (fallmax)> then\n        set [~yspeed v] to (fallmax)\n    end\n    if <<key (space v) pressed?> and <(~rollDelay) = [100]>> then\n        repeat (5)\n            change [~xspeed v] by ((direction) / (15))\n        end\n        set [~rolldelay v] to [0]\n    end\n    if <(~rollDelay) < [100]> then\n        change [~rolldelay v] by (4)\n    end\nend\nif <(.state) = [roll]> then\n\nwhen I receive [walljump v]\nwait until <([abs v] of (~xSpeed) ) < [2]>\nset [~lockmovement v] to [n/a]\n\nwhen I receive [start v]\nforever\n    animationController\nend\n\ndefine animationController\nif <(.state) = [slide]> then\n    set [.state v] to [slide]\nelse\n    if <(~rollDelay) < [42]> then\n        set [.state v] to [roll]\n    else\n        if <(~ySpeed) < [-5]> then\n            set [.state v] to [fall]\n        else\n            if <(~ySpeed) > [0]> then\n                set [.state v] to [jump]\n            else\n                if <([abs v] of (~xSpeed) ) > [0.5]> then\n                    set [.state v] to [walk]\n                else\n                    set [.state v] to [idle]\n                end\n            end\n        end\n    end\nend\nif <(.state) = [slide]> then\n    costume // startCostume: [16] totalCostumes: [1] speed: [0]\nelse\n    if <(.state) = [fall]> then\n        costume // startCostume: [14] totalCostumes: [2] speed: [0.3]\n    else\n        if <(.state) = [jump]> then\n            costume // startCostume: [13] totalCostumes: [1] speed: [0]\n        else\n            if <(.state) = [roll]> then\n                turn right ((~xSpeed) * (3)) degrees\n                if <(~xSpeed) > [0]> then\n                    costume // startCostume: [17] totalCostumes: [1] speed: [0]\n                else\n                    costume // startCostume: [18] totalCostumes: [1] speed: [0]\n                end\n            else\n                if <(.state) = [walk]> then\n                    costume // startCostume: [5] totalCostumes: [8] speed: (([abs v] of (~xSpeed) ) / (12))\n                else\n                    costume // startCostume: [2] totalCostumes: [3] speed: [0.1]\n                end\n            end\n        end\n    end\nend\nif <(.state) = [roll]> then\n    set rotation style [all around v]\nelse\n    set rotation style [left-right v]\n    set [.state v] to [n/a]\nend\n\ndefine costume // startCostume: (startcostume) totalCostumes: (totalcostumes) speed: (speed)\nswitch costume to (idle v)\nswitch costume to ([floor v] of ((startcostume) + ((.costume) mod (totalcostumes))) )\nchange [.costume v] by (speed)\nif <(.costume) > [10000]> then\n    set [.costume v] to [0]\nend\n\ndefine camera\nchange [player: ~playerx v] by ((x position) - (player: ~oldX))\nchange [player: ~playery v] by ((y position) - (player: ~oldY))\nchange [.scrollx v] by (round (((player: ~playerX) - (.scrollX)) / (5)))\nchange [.scrolly v] by (round (((player: ~playerY) - (.scrollY)) / (2)))\nif <(.scrollX) < [485]> then\n    set [.scrollx v] to [485]\nend\nif <(.scrollX) > [2650]> then\n    set [.scrollx v] to [2650]\nend\nif <(.scrollY) < [360]> then\n    set [.scrolly v] to [360]\nend\ngo to x: ((player: ~playerX) + ((0) - (.scrollX))) y: ((player: ~playerY) + ((0) - (.scrollY)))\ngo [forward v] (25) layers\n\nwhen I receive [level1 v]\nset [.playerspawnx v] to [400]\nset [.playerspawny v] to [1120]\nbroadcast (respawnPlayer v)\n\nwhen I receive [start v]\nforever\n    if <touching (damageobjects v)?> then\n        broadcast (respawnPlayer v)\n    end\n    if <(player: ~playerY) < [235]> then\n        broadcast (respawnPlayer v)\n    end\n    if <(.fallDamage) > [0]> then\n        broadcast (respawnPlayer v)\n    end\nend\n\nwhen I receive [respawnplayer v]\nset [.respawning v] to [y]\nbroadcast (reset v)\nset [ghost v] effect to (100)\nset [player: ~playerx v] to (.playerSpawnX)\nset [player: ~playery v] to (.playerSpawnY)\nwait (1) seconds\nset [.effecttype v] to [respawn]\ncreate clone of (effects v)\nwait (0.3) seconds\nset [.respawning v] to [n]\nclear graphic effects\nrepeat (5)\n    repeat (5)\n        change [brightness v] effect by (10)\n    end\n    clear graphic effects\nend\nclear graphic effects\n\nwhen I receive [start v]\nforever\n    if <<<<key (a v) pressed?> or <key (d v) pressed?>> or <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>>> and <<(.touchingGround) = [y]> and <(.respawning) = [n]>>> then\n        set [.effecttype v] to [dust]\n        create clone of (effects v)\n        wait (0.2) seconds\n    end\nend\n\nwhen I receive [start v]\nforever\n    if <<<key (w v) pressed?> or <key (up arrow v) pressed?>> and <(.state) = [slide]>> then\nend\n\nwhen I receive [start v]\nforever\n    if <touching (endpoint v)?> then\n        set [.stoptimer v] to [y]\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [start 2 v]\nshow\nbroadcast (level1 v)\nbroadcast (start v)\n\n@effects\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nhide\nwait (0) seconds\nset [~cloneid v] to (.effectType)\nset [~effectx v] to ([player: ~playerx v] of [player v])\nset [~effecty v] to ([player: ~playery v] of [player v])\nclear graphic effects\ngo to [front v] layer\nshow\nset size to (100) %\nset rotation style [all around v]\nif <(~cloneID) = [jump]> then\n    set [ghost v] effect to (20)\n    switch costume to (jump v)\n    change [~effecty v] by (-15)\n    point in direction (round (([~xspeed v] of [player v]) * (3)))\n    repeat (20)\n        change [~effectx v] by (([cos v] of ((90) - (direction)) ) * (-3))\n        change [~effecty v] by (([sin v] of ((90) - (direction)) ) * (-3))\n        change [ghost v] effect by (5)\n        change size by (-1)\n    end\n    delete this clone\nelse\n    if <(~cloneID) = [contact]> then\n        set [ghost v] effect to (50)\n        switch costume to (contact v)\n        change [~effecty v] by (-40)\n        repeat (25)\n            change [ghost v] effect by (4)\n            change size by (-5)\n        end\n        delete this clone\n    else\n        if <(~cloneID) = [dust]> then\n            change [~effecty v] by (-25)\n            switch costume to (dust v)\n            set size to (pick random (80) to (150)) %\n            point in direction (pick random (1) to (360))\n            repeat (20)\n                change [ghost v] effect by (4)\n                change size by (-5)\n                change [~effecty v] by (0.3)\n            end\n            delete this clone\n        else\n            if <(~cloneID) = [respawn]> then\n                switch costume to (repsawn1 v)\n                set [brightness v] effect to (80)\n                set [color v] effect to (13)\n                repeat (10)\n                    change [brightness v] effect by (-10)\n                    next costume\n                end\n                set [brightness v] effect to (0)\n                repeat (10)\n                    change size by (3)\n                    change [ghost v] effect by (10)\n                end\n                delete this clone\n            end\n        end\n    end\nend\n\nwhen I start as a clone\nforever\n    go to x: ((~effectX) - (.scrollX)) y: ((~effectY) - (.scrollY))\n    go to [front v] layer\nend\n\nwhen I receive [start 2 v]\nforever\n    set [ghost v] effect to (100)\n    show\n    switch costume to (sensor v)\n    go to (player v)\n    set size to (100) %\n    point in direction (90)\n    if <touching (ground v)?> then\n        set [.touchingground v] to [y]\n    else\n        set [.touchingground v] to [n]\n    end\nend\n\n@Figur1\n\nwhen flag clicked\nhide\n\n@Figur2\n\nwhen flag clicked\nset size to (100) %\nset [em ja v] to [0]\nswitch costume to (kostüm6 v)\ngo to [back v] layer\nclear graphic effects\nshow\nwait (2) seconds\nhide\nclone [2]\nwait (0) seconds\nclone [1]\nwait (2.3) seconds\nclone [name]\nwait (2) seconds\nclone [10]\nwait (.1) seconds\nclone [12]\nwait (.1) seconds\nclone [10]\nwait (.1) seconds\nclone [12]\nset [em ja v] to [1]\nshow\nbroadcast (start 2 v)\nhide\n\ndefine beat\nset size to (200) %\nset [i1 v] to [0]\nrepeat (30)\n    set [i1 v] to (((i1) * (0.8)) + (((100) - (size)) / (4)))\n    point in direction ((90) + ((i1) / (5)))\n    change size by (i1)\nend\n\ndefine clone (id)\nset [meine variable v] to (id)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nif <(meine Variable) = [1]> then\n    go to [front v] layer\n    switch costume to (kostüm1 v)\n    show\n    go to x: (0) y: (0)\n    clear graphic effects\n    beat\n    wait (1.5) seconds\n    repeat (10)\n        change x by (((300) - (x position)) / (5))\n    end\n    delete this clone\nend\n\nwhen I start as a clone\nif <(meine Variable) = [2]> then\n    go [forward v] (1) layers\n    point in direction (90)\n    switch costume to (kostüm2 v)\n    show\n    go to x: (0) y: (0)\n    clear graphic effects\n    beat\n    repeat until <[0] < (em ja)>\n        set y to ((([sin v] of ((timer) * (-100)) ) * (29)) + (0))\n        set [ghost v] effect to ((([sin v] of ((timer) * (-100)) ) * (29)) + (0))\n    end\n    wait until <[0] < (em ja)>\n    delete this clone\nend\n\nwhen I start as a clone\nif <(meine Variable) = [name]> then\n    go [forward v] (2) layers\n    set size to (60) %\n    switch costume to (kostüm3 v)\n    show\n    go to x: (11) y: (-173)\n    clear graphic effects\n    repeat (10)\n        change y by (((0) - (y position)) / (5))\n    end\n    broadcast (Nachricht1 v)\n    repeat (30)\n        set [i1 v] to (((i1) * (0.8)) + (((100) - (size)) / (4)))\n        change size by (i1)\n    end\n    repeat (30)\n        set [i1 v] to (((i1) * (0.8)) + (((60) - (size)) / (4)))\n        point in direction ((90) + ((i1) / (5)))\n        change size by (i1)\n    end\n    repeat (20)\n        change y by (((-173) - (y position)) / (5))\n    end\n    delete this clone\nend\n\nwhen I start as a clone\nif <(meine Variable) = [10]> then\n    go to [front v] layer\n    show\n    switch costume to (kostüm4 v)\n    go to x: (0) y: (0)\n    set [color v] effect to (0)\n    set size to (0) %\n    repeat until <(round (size)) = (round (600))>\n        switch costume to (blank v)\n        change size by (((600) - (size)) / (5))\n        switch costume to (kostüm4 v)\n    end\n    delete this clone\nend\n\nwhen I start as a clone\nif <(meine Variable) = [12]> then\n    show\n    go to [front v] layer\n    switch costume to (kostüm5 v)\n    go to x: (0) y: (0)\n    set [color v] effect to (0)\n    set size to (0) %\n    repeat until <(round (size)) = (round (600))>\n        switch costume to (blank v)\n        change size by (((600) - (size)) / (5))\n        switch costume to (kostüm5 v)\n    end\n    delete this clone\nend\n\nwhen flag clicked\nplay sound [Music by unknown artist v] until done\n\n