Platformer Test
@Stage\n\n@Player\n\nwhen [space v] key pressed\nset [mouse v] to (((mouse) + (1)) mod (2))\n\nwhen flag clicked\ngo to x: (0) y: (0)\nsetVariables\nswitch costume to (player v)\n\ndefine None\nif <[1] = (letter (x) of (item (((length of [collisiondata v]) - ([floor v] of ((yPos) / (blockSize)) )) + (1)) of [collisiondata v]))> then\n    set [ypos v] to (([ceiling v] of ((yPos) / (blockSize)) ) * (blockSize))\n    set [yvel v] to [0]\nend\nif <[1] = (letter (x) of (item (((length of [collisiondata v]) - ([ceiling v] of ((yPos) / (blockSize)) )) + (1)) of [collisiondata v]))> then\n    set [ypos v] to (([floor v] of ((yPos) / (blockSize)) ) * (blockSize))\n    set [yvel v] to [0]\nend\nif <(height) = [2]> then\n    if <[1] = (letter (x) of (item ((length of [collisiondata v]) - ([ceiling v] of ((yPos) / (blockSize)) )) of [collisiondata v]))> then\n        set [ypos v] to (([floor v] of ((yPos) / (blockSize)) ) * (blockSize))\n        set [yvel v] to [0]\n    end\nend\n\ndefine None\nchange [scrollx v] by (x)\nchange [scrolly v] by (y)\nif <(scrollX) < (((((length of (item (1) of [leveldata v])) / (2)) - (xSize)) * (blockSize)) * (-1))> then\n    set [scrollx v] to (((((length of (item (1) of [leveldata v])) / (2)) - (xSize)) * (blockSize)) * (-1))\nend\nif <(scrollX) > [0]> then\n    set [scrollx v] to [0]\nend\nif <(scrollY) < ((((length of [leveldata v]) - (ySize)) * (blockSize)) * (-1))> then\n    set [scrolly v] to ((((length of [leveldata v]) - (ySize)) * (blockSize)) * (-1))\nend\nif <(scrollY) > [0]> then\n    set [scrolly v] to [0]\nend\n\ndefine setVariables\nset [mouse v] to [0]\nset [xvel v] to [0]\nset [yvel v] to [0]\nset [counter v] to [0]\ndelete (all) of [collisiondata v]\nrepeat (length of [leveldata v])\n    set [counter2 v] to [0]\n    change [counter v] by (1)\n    set [remainderyvel v] to []\n    repeat ((length of (item (1) of [leveldata v])) / (2))\n        change [counter2 v] by (1)\n        set [counter3 v] to [0]\n        repeat until <(join (letter (((counter2) * (2)) - (1)) of (item (counter) of [leveldata v])) (letter ((counter2) * (2)) of (item (counter) of [leveldata v]))) = (join (letter (1) of (item (counter3) of [tile-collisiontype v])) (letter (2) of (item (counter3) of [tile-collisiontype v])))>\n            change [counter3 v] by (1)\n        end\n        set [remainderyvel v] to (join (remainderYVel) (letter (3) of (item (counter3) of [tile-collisiontype v])))\n    end\n    add (remainderYVel) to [collisiondata v]\nend\nset [xpos v] to ((pick random (1) to (length of (item (1) of [collisiondata v]))) * (blockSize))\nset [ypos v] to ((pick random (1) to (length of [collisiondata v])) * (blockSize))\nrepeat until <<<[0] = (letter ((xPos) / (blockSize)) of (item ((length of [collisiondata v]) - ((yPos) / (blockSize))) of [collisiondata v]))> and <[0] = (letter ((xPos) / (blockSize)) of (item (((length of [collisiondata v]) - ((yPos) / (blockSize))) + (1)) of [collisiondata v]))>> and <[1] = (letter ((xPos) / (blockSize)) of (item (((length of [collisiondata v]) - ((yPos) / (blockSize))) + (2)) of [collisiondata v]))>>\n    set [xpos v] to ((pick random (1) to (length of (item (1) of [collisiondata v]))) * (blockSize))\n    set [ypos v] to ((pick random (1) to (length of [collisiondata v])) * (blockSize))\nend\nbroadcast (initEnd v)\n\ndefine None\nset [xvel v] to ((xVel) * (friction))\nchange [yvel v] by (gravity)\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    change [xvel v] by (speed)\nend\nif <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n    change [xvel v] by ((speed) * (-1))\nend\nif <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n    if <[1] = (letter ([ceiling v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - ([ceiling v] of ((yPos) / (blockSize)) )) + (2)) of [collisiondata v]))> then\n        set [yvel v] to (jumpvel)\n    end\n    if <[1] = (letter ([floor v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - ([ceiling v] of ((yPos) / (blockSize)) )) + (2)) of [collisiondata v]))> then\n        set [yvel v] to (jumpvel)\n    end\n    if <[2] = (letter ([ceiling v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - ([floor v] of ((yPos) / (blockSize)) )) + (1)) of [collisiondata v]))> then\n        if <not <(yVel) > [0]>> then\n            set [yvel v] to (jumpvel)\n        end\n    end\n    if <[3] = (letter ([floor v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - ([floor v] of ((yPos) / (blockSize)) )) + (1)) of [collisiondata v]))> then\n        if <not <(yVel) > [0]>> then\n            set [yvel v] to (jumpvel)\n        end\n    end\n    if <[2] = (letter ([floor v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - ([ceiling v] of ((yPos) / (blockSize)) )) + (2)) of [collisiondata v]))> then\n        if <not <(yVel) > [0]>> then\n            set [yvel v] to (jumpvel)\n        end\n    end\n    if <[3] = (letter ([ceiling v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - ([ceiling v] of ((yPos) / (blockSize)) )) + (2)) of [collisiondata v]))> then\n        if <not <(yVel) > [0]>> then\n            set [yvel v] to (jumpvel)\n        end\n    end\nend\nchange [xpos v] by (xVel)\nxCollision y: ([floor v] of ((yPos) / (blockSize)) )\nxCollision y: ([ceiling v] of ((yPos) / (blockSize)) )\nif <(height) = [2]> then\n    xCollision y: (([ceiling v] of ((yPos) / (blockSize)) ) + (1))\nend\nif <(yVel) < ((blockSize) * (-1))> then\n    set [remainderyvel v] to (yVel)\n    change [ypos v] by ((blockSize) * (-1))\n    yCollision x: ([floor v] of ((xPos) / (blockSize)) ) (height)\n    yCollision x: ([ceiling v] of ((xPos) / (blockSize)) ) (height)\n    change [remainderyvel v] by (blockSize)\n    repeat until <([abs v] of (remainderYVel) ) < (blockSize)>\n        change [ypos v] by ((blockSize) * (-1))\n        yCollision x: ([floor v] of ((xPos) / (blockSize)) ) (height)\n        yCollision x: ([ceiling v] of ((xPos) / (blockSize)) ) (height)\n        change [remainderyvel v] by (blockSize)\n    end\n    change [ypos v] by (remainderYVel)\n    yCollision x: ([floor v] of ((xPos) / (blockSize)) ) (height)\n    yCollision x: ([ceiling v] of ((xPos) / (blockSize)) ) (height)\n    change [remainderyvel v] by (blockSize)\nelse\n    change [ypos v] by (yVel)\n    yCollision x: ([floor v] of ((xPos) / (blockSize)) ) (height)\n    yCollision x: ([ceiling v] of ((xPos) / (blockSize)) ) (height)\nend\nslopeCollision\nif <(mouse) = [1]> then\n    scroll (round ((((x position) - (25)) + ((mouse x) * (0.5))) / (-10))) (round (((y position) + ((mouse y) * (0.5))) / (-5)))\nelse\n    scroll (round (((x position) - (25)) / (-10))) (round ((y position) / (-5)))\nend\ngo to x: (((xPos) - (240)) + (scrollX)) y: (((yPos) - (180)) + (scrollY))\n\ndefine slopeCollision\nif <[2] = (letter ([ceiling v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - ([floor v] of ((yPos) / (blockSize)) )) + (1)) of [collisiondata v]))> then\n    if <((xPos) mod (blockSize)) = [0]> then\n        set [ypos v] to (([ceiling v] of ((yPos) / (blockSize)) ) * (blockSize))\n        set [yvel v] to [0]\n    else\n        if <(yPos) < ((([floor v] of ((yPos) / (blockSize)) ) * (blockSize)) + ((xPos) mod (blockSize)))> then\n            set [ypos v] to ((([floor v] of ((yPos) / (blockSize)) ) * (blockSize)) + ((xPos) mod (blockSize)))\n            set [yvel v] to [0]\n        end\n    end\nend\nif <[2] = (letter ([floor v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - ([floor v] of ((yPos) / (blockSize)) )) + (1)) of [collisiondata v]))> then\n    if <((yPos) mod (blockSize)) = [0]> then\n        set [xpos v] to (([ceiling v] of ((xPos) / (blockSize)) ) * (blockSize))\n        set [xvel v] to [0]\n    else\n        set [ypos v] to ((([floor v] of ((yPos) / (blockSize)) ) * (blockSize)) + (blockSize))\n        if <not <key (up arrow v) pressed?>> then\n            set [yvel v] to [0]\n        end\n    end\nend\nif <[3] = (letter ([floor v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - ([floor v] of ((yPos) / (blockSize)) )) + (1)) of [collisiondata v]))> then\n    if <((xPos) mod (blockSize)) = [0]> then\n        set [ypos v] to (([ceiling v] of ((yPos) / (blockSize)) ) * (blockSize))\n        set [yvel v] to [0]\n    else\n        if <(yPos) < ((([floor v] of ((yPos) / (blockSize)) ) * (blockSize)) + ((blockSize) - ((xPos) mod (blockSize))))> then\n            set [ypos v] to ((([floor v] of ((yPos) / (blockSize)) ) * (blockSize)) + ((blockSize) - ((xPos) mod (blockSize))))\n            set [yvel v] to [0]\n        end\n    end\nend\nif <[3] = (letter ([ceiling v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - ([floor v] of ((yPos) / (blockSize)) )) + (1)) of [collisiondata v]))> then\n    if <((yPos) mod (blockSize)) = [0]> then\n        set [xpos v] to (([floor v] of ((xPos) / (blockSize)) ) * (blockSize))\n        set [xvel v] to [0]\n    else\n        set [ypos v] to ((([floor v] of ((yPos) / (blockSize)) ) * (blockSize)) + (blockSize))\n        if <not <key (up arrow v) pressed?>> then\n            set [yvel v] to [0]\n        end\n    end\nend\n\ndefine None\nif <[1] = (letter ([floor v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - (y)) + (1)) of [collisiondata v]))> then\n    if <not <[3] = (letter ([ceiling v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - (y)) + (1)) of [collisiondata v]))>> then\n        set [xpos v] to (([ceiling v] of ((xPos) / (blockSize)) ) * (blockSize))\n        set [xvel v] to [0]\n    end\nend\nif <[1] = (letter ([ceiling v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - (y)) + (1)) of [collisiondata v]))> then\n    if <not <[2] = (letter ([floor v] of ((xPos) / (blockSize)) ) of (item (((length of [collisiondata v]) - (y)) + (1)) of [collisiondata v]))>> then\n        set [xpos v] to (([floor v] of ((xPos) / (blockSize)) ) * (blockSize))\n        set [xvel v] to [0]\n    end\nend\n\nwhen I receive [startloops v]\nforever\n    go to [front v] layer\n    go [backward v] (2) layers\n    physics (22) (0.6) (-1.5) (2) (4)\n    if <not <(costume [number v]) = [1]>> then\n        switch costume to (player v)\n    end\n    broadcast (loop v)\nend\n\n@Scrolling Base\n\ndefine setCostume\nset [counter v] to ((1) + (join (letter (((xPos) * (2)) - (1)) of (item ((length of [leveldata v]) - (yPos)) of [leveldata v])) (letter ((xPos) * (2)) of (item ((length of [leveldata v]) - (yPos)) of [leveldata v]))))\nif <not <(costume [number v]) = (counter)>> then\n    switch costume to (counter)\nend\nif <[backtiles v] contains (costume [number v])?> then\n    go [backward v] (304) layers\nend\nif <[fronttiles v] contains (costume [number v])?> then\n    go to [front v] layer\n    go [backward v] (10) layers\nend\n\nwhen flag clicked\nset size to (200) %\nhide\n\nwhen this sprite clicked\n\ndefine replaceData\nif <(length of ((costume [number v]) - (1))) = [1]> then\n    set [costume v] to (join [0] ((costume [number v]) - (1)))\nelse\n    set [costume v] to ((costume [number v]) - (1))\nend\nset [counter v] to [0]\nset [newitem v] to []\nrepeat (length of (item (1) of [leveldata v]))\n    change [counter v] by (2)\n    if <(xPos) = ((counter) / (2))> then\n        set [newitem v] to (join (newItem) (costume))\n    else\n        set [newitem v] to (join (newItem) (join (letter ((counter) - (1)) of (item ((length of [leveldata v]) - (yPos)) of [leveldata v])) (letter (counter) of (item ((length of [leveldata v]) - (yPos)) of [leveldata v]))))\n    end\nend\nreplace item ((length of [leveldata v]) - (yPos)) of [leveldata v] with (newItem)\nset [counter v] to [0]\nset [newitem v] to []\nrepeat (length of (item (1) of [collisiondata v]))\n    change [counter v] by (1)\n    if <(xPos) = (counter)> then\n        set [counter3 v] to [0]\n        repeat until <(costume) = (join (letter (1) of (item (counter3) of [tile-collisiontype v])) (letter (2) of (item (counter3) of [tile-collisiontype v])))>\n            change [counter3 v] by (1)\n        end\n        set [newitem v] to (join (newItem) (letter (3) of (item (counter3) of [tile-collisiontype v])))\n    else\n        set [newitem v] to (join (newItem) (letter (counter) of (item ((length of [collisiondata v]) - (yPos)) of [collisiondata v])))\n    end\nend\nreplace item ((length of [collisiondata v]) - (yPos)) of [collisiondata v] with (newItem)\n\nwhen I receive [loop v]\nif <(amClone) > [0]> then\n    cloneControl\nend\n\ndefine defineVariables\nset [blocksize v] to [40]\nset [amclone v] to [0]\nset [scrollx v] to ((([xpos v] of [player v]) - (240)) * (-1))\nset [scrolly v] to [0]\nset [xsize v] to [12]\nset [ysize v] to [9]\nset [ypos v] to [0]\nrepeat (ySize)\n    change [ypos v] by (1)\n    set [xpos v] to [0]\n    repeat (xSize)\n        change [xpos v] by (1)\n        create clone of (_myself_ v)\n    end\nend\n\ndefine cloneControl\nmoveTile\nif <not <(x position) < (((xSize) * (blockSize)) / (2))>> then\n    set [xpos v] to ((xPos) - (xSize))\n    setCostume\n    moveTile\nend\nif <not <(x position) > (((xSize) * (blockSize)) / (-2))>> then\n    set [xpos v] to ((xPos) + (xSize))\n    setCostume\n    moveTile\nend\nif <not <(y position) < (((ySize) * (blockSize)) / (2))>> then\n    set [ypos v] to ((yPos) - (ySize))\n    setCostume\n    moveTile\nend\nif <not <(y position) > (((ySize) * (blockSize)) / (-2))>> then\n    set [ypos v] to ((yPos) + (ySize))\n    setCostume\n    moveTile\nend\n\nwhen I receive [initend v]\ndefineVariables\nbroadcast (startLoops v)\n\ndefine moveTile\nset x to (((scrollX) + ((blockSize) * (xPos))) - ((((xSize) / (2)) * (blockSize)) + ((blockSize) / (2))))\nset y to (((scrollY) + ((blockSize) * ((yPos) + (1)))) - ((((ySize) / (2)) * (blockSize)) + ((blockSize) / (2))))\n\nwhen I start as a clone\nsetCostume\nshow\nset [amclone v] to [1]\n\nswitch costume to (tile)\nreplaceData\n\n@Border\n\nwhen flag clicked\ngo to x: (0) y: (0)\n\nwhen I receive [loop v]\ngo to [front v] layer\ngo [backward v] (1) layers\n\n@Background\n\nwhen flag clicked\nset size to (100) %\nhide\nset y to (0)\nset [clone# v] to [0]\nrepeat (2)\n    change [clone# v] by (1)\n    create clone of (_myself_ v)\nend\n\nwhen I receive [loop v]\ngo [backward v] (320) layers\nset x to ((((scrollX) / (2)) mod (480)) + (((clone#) - (1)) * (-480)))\n\nwhen I start as a clone\nshow\n\n@Sprite1\n\ndefine refresh display []\nset [currentdisplay v] to (string1)\nif <(digit) < (length of (currentDisplay))> then\n    repeat ((length of (string1)) - (digit))\n        change [digit v] by (1)\n        create clone of (_myself_ v)\n    end\nend\nif <(digit) > (length of (string1))> then\n    repeat ((digit) - (length of (string1)))\n        broadcast (deleteClone v) and wait\n        change [digit v] by (-1)\n    end\nend\nbroadcast (updateDisplay v)\n\nwhen flag clicked\nset [digit v] to [0]\nset [score v] to [0]\nset [amclone v] to [0]\nhide\nrefresh display []\n\nwhen I receive [deleteclone v]\nif <(digit) = ([digit v] of [sprite1 v])> then\n    delete this clone\nend\n\nwhen I receive [updatedisplay v]\ngo to x: ((((digit) - (1)) * (6)) - (205)) y: (135)\nswitch costume to (letter (digit) of ([currentdisplay v] of [sprite1 v]))\n\nwhen I receive [loop v]\nif <(amClone) = [0]> then\n    change [score v] by (1)\n    refresh display (score)\nend\ngo to [front v] layer\n\nwhen I start as a clone\nset [amclone v] to [1]\nshow\n\n
Arrow keys or WASD, space to toggle mouse panning.\n\nJust a project I made a while ago...\nNo finish or goal or anything special like that. :P\n\nEnjoy! (And maybe leave a love or favorite! Or even a follow if it's that cool!)