Work In Progress Platformer
@Stage\n\n@Sprite1\n\nwhen flag clicked\nset [playerx v] to [0]\nset [playery v] to [0]\nset [playerdirection v] to [90]\nset [speedx v] to [0]\nset [speedy v] to [0]\nset [camerax v] to (playerX)\nset [cameray v] to (playerY)\nset [rotationspeed v] to []\nset [constcollisionlength v] to [15]\nset [jumppad? v] to []\nforever\n    if <(jumpPad?) = []> then\n        if <key (right arrow v) pressed?> then\n            if <<(collision?) = [floor]> or <(collision?) = [ramp]>> then\n                change [speedx v] by ((1.5) * ([cos v] of ((90) - (playerDirection)) ))\n                change [speedy v] by ((1.5) * ([sin v] of ((90) - (playerDirection)) ))\n            else\n                if <not <(collision?) = [ceiling]>> then\n                    change [speedx v] by (0.5)\n                end\n            end\n        end\n        if <key (left arrow v) pressed?> then\n            if <<(collision?) = [floor]> or <(collision?) = [ramp]>> then\n                change [speedx v] by ((-1.5) * ([cos v] of ((90) - (playerDirection)) ))\n                change [speedy v] by ((-1.5) * ([sin v] of ((90) - (playerDirection)) ))\n            else\n                if <not <(collision?) = [ceiling]>> then\n                    change [speedx v] by (-0.5)\n                end\n            end\n        end\n        if <<<key (left arrow v) pressed?> or <key (right arrow v) pressed?>> and <<(collision?) = [floor]> or <(collision?) = [ramp]>>> then\n            change [speedx v] by ((-0.5) * ([cos v] of (playerDirection) ))\n            change [speedy v] by ((-0.5) * ([sin v] of (playerDirection) ))\n        end\n        if <<key (up arrow v) pressed?> and <<(collision?) = [floor]> or <(collision?) = [ramp]>>> then\n            change [speedx v] by ((20) * ([cos v] of ((180) - (playerDirection)) ))\n            change [speedy v] by ((20) * ([sin v] of ((180) - (playerDirection)) ))\n        end\n        if <<(collision?) = []> or <<<(collision?) = [ramp]> or <<(collisionAngle) > [20]> or <(collisionAngle) < [-20]>>> and <not <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>>>>> then\n            change [speedy v] by (-1)\n        end\n        if <<(collision?) = [bounce]> or <(collision?) = [ceiling]>> then\n            distanceFormula (collisionPY2) (collisionPY1) (collisionPX1) (collisionPX2)\n            if <(collision?) = [bounce]> then\n                set [speedx v] to ((1) * ((speedX) - ((2) * ((((speedX) * (((collisionPY2) - (collisionPY1)) / (returnDistance))) + ((speedY) * (((collisionPX1) - (collisionPX2)) / (returnDistance)))) * (((collisionPY2) - (collisionPY1)) / (returnDistance))))))\n            else\n                set [speedx v] to ((-1) * ((speedX) - ((2) * ((((speedX) * (((collisionPY2) - (collisionPY1)) / (returnDistance))) + ((speedY) * (((collisionPX1) - (collisionPX2)) / (returnDistance)))) * (((collisionPY2) - (collisionPY1)) / (returnDistance))))))\n            end\n            set [speedy v] to ((-1) * ((speedY) - ((2) * ((((speedX) * (((collisionPY2) - (collisionPY1)) / (returnDistance))) + ((speedY) * (((collisionPX1) - (collisionPX2)) / (returnDistance)))) * (((collisionPX1) - (collisionPX2)) / (returnDistance))))))\n        else\n            if <<(collision?) = [floor]> or <(collision?) = [ramp]>> then\n                if <(((speedX) * ((collisionPY1) - (collisionPY2))) + ((speedY) * ((collisionPX2) - (collisionPX1)))) > [0]> then\n                    set [drift v] to ((((speedX) * ((collisionPX1) - (collisionPX2))) + ((speedY) * ((collisionPY1) - (collisionPY2)))) / ([sqrt v] of ((((collisionPX2) - (collisionPX1)) * ((collisionPX2) - (collisionPX1))) + (((collisionPY2) - (collisionPY1)) * ((collisionPY2) - (collisionPY1)))) ))\n                    set [speedx v] to ((drift) * ([cos v] of ((90) - (playerDirection)) ))\n                    set [speedy v] to ((drift) * ([sin v] of ((90) - (playerDirection)) ))\n                end\n            end\n        end\n        set [speedx v] to ((speedX) * (0.96))\n        set [speedy v] to ((speedY) * (0.96))\n        if <not <(wallCollision?) = []>> then\n            set [speedx v] to [0]\n        end\n        if <(airBorne?) > [3]> then\n            if <(rotationSpeed) = []> then\n                if <<(collisionAngle) > [-45]> and <(collisionAngle) < [45]>> then\n                    set [rotationspeed v] to ((collisionAngle) / (9))\n                else\n                    set [rotationspeed v] to (((((speedX) * ([cos v] of ((90) - (playerDirection)) )) + ((speedY) * ([sin v] of ((90) - (playerDirection)) ))) / (((30) * (2)) * (3.1415926535))) * (-360))\n                end\n            end\n            if <(collision?) = [bounce]> then\n                set [rotationspeed v] to ((rotationSpeed) * (2))\n            end\n            if <<(playerDirection) < [80]> or <(playerDirection) > [110]>> then\n                set [playerdirection v] to (((((playerDirection) + (rotationSpeed)) + (180)) mod (360)) - (180))\n            else\n                set [playerdirection v] to [90]\n            end\n        else\n            set [rotationspeed v] to []\n        end\n        change [playerx v] by (speedX)\n        change [playery v] by (speedY)\n        correctForCollisions\n        set [camerax v] to (playerX)\n        set [cameray v] to (playerY)\n        touchingJumpPad?\n    else\n        if <(countJumpPad) > (length of [jumppadheight v])> then\n            set [speedy v] to [100]\n            set [jumppad? v] to []\n        else\n            set [playery v] to ((item (jumpPad?) of [jumppady v]) + ((padP2Y) + (item (countJumpPad) of [jumppadheight v])))\n        end\n        set [camerax v] to (playerX)\n        set [cameray v] to (playerY)\n    end\n    reset timer\nend\n\nset [grav v] to [-5]\n\nset [collision? v] to []\n\ngo to x: ((playerX) - (10)) y: ((playerY) + (26))\n\ngo to x: ((playerX) + (10)) y: ((playerY) - (22))\n\ngo to x: (0) y: (0)\n\ndefine rotatePointAroundPoint p1: (px) (py) r1: (rx) (ry) direction: (direction)\nset [returnrotaterx v] to (((((rx) - (px)) * ([cos v] of (direction) )) - (((ry) - (py)) * ([sin v] of (direction) ))) + (px))\nset [returnrotatery v] to (((((rx) - (px)) * ([sin v] of (direction) )) + (((ry) - (py)) * ([cos v] of (direction) ))) + (py))\n\nadd [-10] to [collisionpointsx v]\nadd [24] to [collisionpointsy v]\n\nset [i v] to [0]\nforever\n\nrotatePointAroundPoint p1: ([x position v] of [sprite2 v]) ([y position v] of [sprite2 v]) r1: ((item (((i) mod (length of [collisionpointsx v])) + (1)) of [collisionpointsx v]) + ([x position v] of [sprite2 v])) ((item (((i) mod (length of [collisionpointsy v])) + (1)) of [collisionpointsy v]) + ([y position v] of [sprite2 v])) direction: ((90) - ([direction v] of [sprite2 v]))\ngo to x: (returnRotateRX) y: (returnRotateRY)\nchange [i v] by (1)\n\ndefine findCollisionLine\nset [icollisionline v] to [0]\nset [jumpthru? v] to [false]\nrotatePointAroundPoint p1: (playerX) (playerY) r1: ((item ((iCollisionLine) + (1)) of [collisionpointsx v]) + (playerX)) ((item ((iCollisionLine) + (1)) of [collisionpointsy v]) + (playerY)) direction: ((90) - (playerDirection))\ngoTo (returnRotateRX) (returnRotateRY)\ntouchingGround?\nif <(returnTouchGround) = [true]> then\n    repeat until <<((iCollisionLine) + (1)) > (length of [collisionpointsx v])> or <(returnTouchGround) = [false]>>\n        change [icollisionline v] by (1)\n        rotatePointAroundPoint p1: (playerX) (playerY) r1: ((item ((iCollisionLine) + (1)) of [collisionpointsx v]) + (playerX)) ((item ((iCollisionLine) + (1)) of [collisionpointsy v]) + (playerY)) direction: ((90) - (playerDirection))\n        goTo (returnRotateRX) (returnRotateRY)\n        touchingGround?\n    end\n    if <((iCollisionLine) + (1)) > (length of [collisionpointsx v])> then\n        set [collisiontype v] to [2]\n    else\n        set [collisionp2 v] to (iCollisionLine)\n        set [returntouchground v] to []\n        set [countcollisionline v] to [0]\n        repeat until <(returnTouchGround) = [false]>\n            set [icollisionline v] to (((iCollisionLine) - (1)) mod (length of [collisionpointsx v]))\n            rotatePointAroundPoint p1: (playerX) (playerY) r1: ((item ((iCollisionLine) + (1)) of [collisionpointsx v]) + (playerX)) ((item ((iCollisionLine) + (1)) of [collisionpointsy v]) + (playerY)) direction: ((90) - (playerDirection))\n            goTo (returnRotateRX) (returnRotateRY)\n            touchingGround?\n            change [countcollisionline v] by (1)\n        end\n        if <(countCollisionLine) < (constCollisionLength)> then\n            set [collisiontype v] to [0]\n        else\n            set [collisiontype v] to [1]\n            set [collisionp1 v] to ((((iCollisionLine) + (1)) mod (length of [collisionpointsx v])) + (1))\n        end\n    end\nelse\n    repeat until <<((iCollisionLine) + (1)) > (length of [collisionpointsx v])> or <(returnTouchGround) = [true]>>\n        change [icollisionline v] by (1)\n        rotatePointAroundPoint p1: (playerX) (playerY) r1: ((item ((iCollisionLine) + (1)) of [collisionpointsx v]) + (playerX)) ((item ((iCollisionLine) + (1)) of [collisionpointsy v]) + (playerY)) direction: ((90) - (playerDirection))\n        goTo (returnRotateRX) (returnRotateRY)\n        touchingGround?\n    end\n    if <((iCollisionLine) + (1)) > (length of [collisionpointsx v])> then\n        set [collisiontype v] to [0]\n    else\n        set [returntouchground v] to []\n        set [collisionp1 v] to ((iCollisionLine) + (1))\n        set [countcollisionline v] to [0]\n        repeat until <(returnTouchGround) = [false]>\n            set [icollisionline v] to (((iCollisionLine) + (1)) mod (length of [collisionpointsx v]))\n            rotatePointAroundPoint p1: (playerX) (playerY) r1: ((item ((iCollisionLine) + (1)) of [collisionpointsx v]) + (playerX)) ((item ((iCollisionLine) + (1)) of [collisionpointsy v]) + (playerY)) direction: ((90) - (playerDirection))\n            goTo (returnRotateRX) (returnRotateRY)\n            touchingGround?\n            change [countcollisionline v] by (1)\n        end\n        if <(countCollisionLine) < (constCollisionLength)> then\n            set [collisiontype v] to [0]\n        else\n            set [collisiontype v] to [1]\n            set [collisionp2 v] to (iCollisionLine)\n        end\n    end\nend\n\ndefine touchingGround?\nset [returntouchground v] to <<touching (sprite5 v)?> or <touching (sprite8 v)?>>\nif <touching (sprite8 v)?> then\n    set [jumpthru? v] to [true]\nend\n\ndefine goTo (x) (y)\ngo to x: ((x) - (cameraX)) y: ((y) - (cameraY))\n\ngoTo (returnRotateRX) (returnRotateRY)\n\nset [playerdirection v] to [90]\n\ndefine collisionCalculations\nfindCollisionLine\nif <(collisionType) = [1]> then\n    rotatePointAroundPoint p1: (playerX) (playerY) r1: ((item (collisionP1) of [collisionpointsx v]) + (playerX)) ((item (collisionP1) of [collisionpointsy v]) + (playerY)) direction: ((90) - (playerDirection))\n    set [collisionpx1 v] to (returnRotateRX)\n    set [collisionpy1 v] to (returnRotateRY)\n    rotatePointAroundPoint p1: (playerX) (playerY) r1: ((item (collisionP2) of [collisionpointsx v]) + (playerX)) ((item (collisionP2) of [collisionpointsy v]) + (playerY)) direction: ((90) - (playerDirection))\n    set [collisionpx2 v] to (returnRotateRX)\n    set [collisionpy2 v] to (returnRotateRY)\n    set [collisionmidx v] to (((collisionPX1) + (collisionPX2)) / (2))\n    set [collisionmidy v] to (((collisionPY1) + (collisionPY2)) / (2))\n    set [collisionangle v] to ([atan v] of (((collisionPY2) - (collisionPY1)) / ((collisionPX2) - (collisionPX1))) )\n    if <(jumpThru?) = [true]> then\n        if <<<(speedY) > [0]> or <(collisionPX1) < (collisionPX2)>> or <([abs v] of (collisionAngle) ) > [3]>> then\n            set [collisiontype v] to [0]\n        end\n    end\nend\nfindCollisionWall\n\ndefine correctForCollisions\ncollisionCalculations\nset [wallcollision? v] to (wall?)\nrepeat until <(wall?) = []>\n    if <(wall?) = [left]> then\n        change [playerx v] by (1)\n    end\n    if <(wall?) = [right]> then\n        change [playerx v] by (-1)\n    end\n    collisionCalculations\nend\nif <(collisionType) = [0]> then\n    change [airborne? v] by (1)\n    set [collision? v] to []\nelse\n    repeat until <(collisionType) = [0]>\n        if <(collisionType) = [2]> then\n            change [playery v] by (1)\n        else\n            if <(collisionPX1) > (collisionPX2)> then\n                if <<(airBorne?) > [3]> and <<<(collisionP2) > [241]> or <(collisionP2) < [73]>> and <<(collisionP1) > [241]> or <(collisionP1) < [73]>>>> then\n                    change [playerx v] by ([cos v] of ((collisionAngle) + (90)) )\n                    change [playery v] by ([sin v] of ((collisionAngle) + (90)) )\n                    set [collision? v] to [bounce]\n                else\n                    angleDifference ((90) - (collisionAngle)) (playerDirection)\n                    if <([abs v] of (returnAngDiff) ) > [3]> then\n                        rotatePointAroundPoint p1: (collisionMidX) (collisionMidY) r1: (playerX) (playerY) direction: (((90) - (collisionAngle)) - (playerDirection))\n                        set [playerx v] to (returnRotateRX)\n                        set [playery v] to (returnRotateRY)\n                        set [playerdirection v] to ((90) - (collisionAngle))\n                    end\n                    change [playerx v] by ([cos v] of ((collisionAngle) + (90)) )\n                    change [playery v] by ([sin v] of ((collisionAngle) + (90)) )\n                    set [collision? v] to [floor]\n                end\n            else\n                if <(airBorne?) > [3]> then\n                    set [collision? v] to [ceiling]\n                    change [playerx v] by ((-1) * ([cos v] of ((collisionAngle) + (90)) ))\n                    change [playery v] by ((-1) * ([sin v] of ((collisionAngle) + (90)) ))\n                else\n                    angleDifference ((-90) - (collisionAngle)) (playerDirection)\n                    if <([abs v] of (returnAngDiff) ) > [3]> then\n                        rotatePointAroundPoint p1: (collisionMidX) (collisionMidY) r1: (playerX) (playerY) direction: (((-90) - (collisionAngle)) - (playerDirection))\n                        set [playerx v] to (returnRotateRX)\n                        set [playery v] to (returnRotateRY)\n                        set [playerdirection v] to ((-90) - (collisionAngle))\n                    end\n                    change [playerx v] by ((-1) * ([cos v] of ((collisionAngle) + (90)) ))\n                    change [playery v] by ((-1) * ([sin v] of ((collisionAngle) + (90)) ))\n                    set [collision? v] to [ramp]\n                end\n            end\n        end\n        collisionCalculations\n    end\n    if <<(collision?) = [floor]> or <(collision?) = [ramp]>> then\n        repeat until <(collisionType) = [1]>\n            if <(collision?) = [ramp]> then\n                change [playerx v] by ([cos v] of ((collisionAngle) + (90)) )\n                change [playery v] by ([sin v] of ((collisionAngle) + (90)) )\n            else\n                change [playerx v] by ((-1) * ([cos v] of ((collisionAngle) + (90)) ))\n                change [playery v] by ((-1) * ([sin v] of ((collisionAngle) + (90)) ))\n            end\n            collisionCalculations\n        end\n        repeat (1)\n            if <(collision?) = [ramp]> then\n                change [playerx v] by ([cos v] of ((collisionAngle) + (90)) )\n                change [playery v] by ([sin v] of ((collisionAngle) + (90)) )\n            else\n                change [playerx v] by ((-1) * ([cos v] of ((collisionAngle) + (90)) ))\n                change [playery v] by ((-1) * ([sin v] of ((collisionAngle) + (90)) ))\n            end\n        end\n    end\n    if <<(collision?) = [ceiling]> or <(collision?) = []>> then\n        change [airborne? v] by (1)\n    else\n        set [airborne? v] to [0]\n    end\nend\n\nchange [playerx v] by ([cos v] of ((collisionAngle) - (90)) )\nchange [playery v] by ([sin v] of ((collisionAngle) - (90)) )\n\nchange [playerx v] by ((-80) * ([cos v] of ((collisionAngle) + (90)) ))\nchange [playery v] by ((-80) * ([sin v] of ((collisionAngle) + (90)) ))\n\ngoTo ((collisionPX1) + ((10) * ([cos v] of ((collisionAngle) + (90)) ))) ((collisionPY1) + ((10) * ([sin v] of ((collisionAngle) + (90)) )))\ntouchingGround?\n\ndelete all of [collisionpointsx v]\ndelete all of [collisionpointsy v]\nset [i v] to [0]\nrepeat (40)\n    add ((-10) + ((0.5) * (i))) to [collisionpointsx v]\n    add [26] to [collisionpointsy v]\n    change [i v] by (1)\nend\nset [i v] to [0]\nrepeat (96)\n    add [10] to [collisionpointsx v]\n    add ((26) + ((-0.5) * (i))) to [collisionpointsy v]\n    change [i v] by (1)\nend\nset [i v] to [0]\nrepeat (40)\n    add ((10) + ((-0.5) * (i))) to [collisionpointsx v]\n    add [-22] to [collisionpointsy v]\n    change [i v] by (1)\nend\nset [i v] to [0]\nrepeat (96)\n    add [-10] to [collisionpointsx v]\n    add ((-22) + ((0.5) * (i))) to [collisionpointsy v]\n    change [i v] by (1)\nend\n\nset [grav v] to ((grav) * (0.95))\n\ndefine angleDifference (angle1) (angle2)\nset [returnangdiff v] to ((angle1) - (angle2))\nif <(returnAngDiff) < [-180]> then\n    change [returnangdiff v] by (360)\nend\nif <(returnAngDiff) > [180]> then\n    change [returnangdiff v] by (-360)\nend\n\nset [driftx v] to ((((grav) * ((collisionPY2) - (collisionPY1))) / ((((collisionPX2) - (collisionPX1)) * ((collisionPX2) - (collisionPX1))) + (((collisionPY2) - (collisionPY1)) * ((collisionPY2) - (collisionPY1))))) * ((collisionPX2) - (collisionPX1)))\nset [drifty v] to ((((grav) * ((collisionPY2) - (collisionPY1))) / ((((collisionPX2) - (collisionPX1)) * ((collisionPX2) - (collisionPX1))) + (((collisionPY2) - (collisionPY1)) * ((collisionPY2) - (collisionPY1))))) * ((collisionPY2) - (collisionPY1)))\n\nchange [speedlr v] by (1)\n\nsay [Hello!]\n\nsay []\n\ndefine distanceFormula (x1) (y1) (x2) (y2)\nset [returndistance v] to ([sqrt v] of ((((x2) - (x1)) * ((x2) - (x1))) + (((y2) - (y1)) * ((y2) - (y1)))) )\n\ndefine touchingWall?\nset [returntouchwall v] to <touching (sprite4 v)?>\n\ndefine findCollisionWall\nset [icollisionwall v] to [1]\nset [wall? v] to []\ngoTo (playerX) (playerY)\ntouchingWall?\nif <(returnTouchWall) = [true]> then\n    if <(speedX) > [0]> then\n        set [wall? v] to [right]\n    else\n        set [wall? v] to [left]\n    end\nelse\n    repeat (length of [cornerpoints v])\n        rotatePointAroundPoint p1: (playerX) (playerY) r1: ((item (item (iCollisionWall) of [cornerpoints v]) of [collisionpointsx v]) + (playerX)) ((item (item (iCollisionWall) of [cornerpoints v]) of [collisionpointsy v]) + (playerY)) direction: ((90) - (playerDirection))\n        goTo (returnRotateRX) (returnRotateRY)\n        touchingWall?\n        if <(returnTouchWall) = [true]> then\n            if <(returnRotateRX) > (playerX)> then\n                set [wall? v] to [right]\n            else\n                set [wall? v] to [left]\n            end\n        end\n        change [icollisionwall v] by (1)\n    end\nend\n\nif <not <(wall?) = []>> then\nend\n\ndefine touchingJumpPad?\nset [itouchjumppad v] to [1]\nrepeat until <<not <(jumpPad?) = []>> or <(iTouchJumpPad) > (length of [jumppadx v])>>\n    set [jtouchjumppad v] to [1]\n    repeat until <<not <(jumpPad?) = []>> or <(jTouchJumpPad) > (length of [cornerpoints v])>>\n        rotatePointAroundPoint p1: (playerX) (playerY) r1: ((item (item (jTouchJumpPad) of [cornerpoints v]) of [collisionpointsx v]) + (playerX)) ((item (item (jTouchJumpPad) of [cornerpoints v]) of [collisionpointsy v]) + (playerY)) direction: ((90) - (playerDirection))\n        if <(returnRotateRY) < (playerY)> then\n            if <<(returnRotateRY) > ((item (iTouchJumpPad) of [jumppady v]) + (padP1Y))> and <((returnRotateRY) + (speedY)) < ((item (iTouchJumpPad) of [jumppady v]) + (padP1Y))>> then\n                if <<(((((item (iTouchJumpPad) of [jumppady v]) + (padP1Y)) - (returnRotateRY)) / ((speedY) / (speedX))) + (returnRotateRX)) > ((item (iTouchJumpPad) of [jumppadx v]) + (padP1X))> and <(((((item (iTouchJumpPad) of [jumppady v]) + (padP1Y)) - (returnRotateRY)) / ((speedY) / (speedX))) + (returnRotateRX)) < ((item (iTouchJumpPad) of [jumppadx v]) + (padP2X))>> then\n                    set [speedx v] to [0]\n                    set [speedy v] to [0]\n                    set [jumppad? v] to (iTouchJumpPad)\n                end\n            end\n        end\n        change [jtouchjumppad v] by (1)\n    end\n    change [itouchjumppad v] by (1)\nend\n\ngoTo [] []\n\nset [jumppad? v] to []\n\nset [padp2y v] to [-15]\n\nset [speedy v] to [14]\nset [collision? v] to []\n\nset [padp1x v] to [-30]\nset [padp2x v] to [30]\n\nif <<(collision?) = [floor]> and <<<(collisionAngle) > [20]> or <(collisionAngle) < [-20]>> or <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>>>> then\n    change [speedy v] by (-3)\nelse\nend\n\nwait until <key (space v) pressed?>\n\nset [returntouchjumpthru v] to [0]\n\n@Sprite2\n\nwhen flag clicked\nswitch costume to (costume2 v)\nforever\n    go to [front v] layer\n    go to x: ((playerX) - (cameraX)) y: ((playerY) - (cameraY))\n    point in direction (playerDirection)\nend\n\nairBorne?\n\ndefine airBorne?\n\nswitch costume to (costume3 v)\nif <touching (sprite3 v)?> then\n    set [airborne? v] to [0]\nelse\n    change [airborne? v] by (1)\nend\nswitch costume to (costume2 v)\n\n@Sprite3\n\nwhen flag clicked\nforever\n    go to x: ((-50) - (cameraX)) y: ((-50) - (cameraY))\n    set size to (200) %\nend\n\n@Sprite4\n\ndefine goTo (x) (y) (size)\nset [tempgoto v] to (costume [number v])\nswitch costume to (costume1 v)\nset size to (99999) %\nswitch costume to (costume2 v)\ngo to x: (x) y: (y)\nswitch costume to (costume1 v)\nset size to (size) %\nswitch costume to (tempGoTo)\n\ngo to x: (0) y: (11)\n\ngoTo ((0) - (cameraX)) ((0) - (cameraY)) [1565]\n\nwhen flag clicked\ninitLevel [1]\n\nadd [630] to [levelonex v]\nadd [-110] to [leveloney v]\nadd (round (((1452.55) / (480)) * (100))) to [levelonesize v]\n\nadd [3] to [levelonecostume v]\n\ndefine initLevel (level)\nif <(level) = [1]> then\n    set [countinit v] to [1]\n    repeat (length of [levelonex v])\n        create clone of (_myself_ v)\n        change [countinit v] by (1)\n    end\nend\n\nwhen I start as a clone\nswitch costume to (item (countInit) of [levelonecostume v])\nshow\nforever\n    goTo ((item (countInit) of [levelonex v]) - (cameraX)) ((item (countInit) of [leveloney v]) - (cameraY)) (item (countInit) of [levelonesize v])\nend\n\n@Sprite5\n\ndefine goTo (x) (y) (size)\nset [tempgoto v] to (costume [number v])\nswitch costume to (costume1 v)\nset size to (99999) %\nswitch costume to (costume2 v)\ngo to x: (x) y: (y)\nswitch costume to (costume1 v)\nset size to (size) %\nswitch costume to (tempGoTo)\n\ngo to x: (0) y: (11)\n\ngoTo ((0) - (cameraX)) ((0) - (cameraY)) [1565]\n\nwhen flag clicked\ninitLevel [1]\n\nadd [630] to [levelonex v]\nadd [-110] to [leveloney v]\nadd (round (((1452.55) / (480)) * (100))) to [levelonesize v]\n\nadd [3] to [levelonecostume v]\n\ndefine initLevel (level)\nif <(level) = [1]> then\n    set [countinit v] to [1]\n    repeat (length of [levelonex v])\n        create clone of (_myself_ v)\n        change [countinit v] by (1)\n    end\nend\n\nwhen I start as a clone\nswitch costume to (item (countInit) of [levelonecostume v])\nshow\nforever\n    goTo ((item (countInit) of [levelonex v]) - (cameraX)) ((item (countInit) of [leveloney v]) - (cameraY)) (item (countInit) of [levelonesize v])\nend\n\n@Sprite6\n\nforever\n    next costume\nend\n\nwhen flag clicked\ninitLevel [1]\n\ndefine goTo (x) (y)\nset [tempgoto v] to (costume [number v])\nswitch costume to (costume1 v)\nset size to (99999) %\nswitch costume to (costume2 v)\ngo to x: (x) y: (y)\nswitch costume to (costume1 v)\nset size to (100) %\nswitch costume to (tempGoTo)\n\ndefine initLevel (level)\ndelete all of [jumppadx v]\ndelete all of [jumppady v]\ndelete all of [jumppadcollision? v]\nif <(level) = [1]> then\n    set [countinit v] to [1]\n    repeat (length of [levelonex v])\n        add (item (countInit) of [levelonex v]) to [jumppadx v]\n        add (item (countInit) of [leveloney v]) to [jumppady v]\n        add [false] to [jumppadcollision? v]\n        create clone of (_myself_ v)\n        change [countinit v] by (1)\n    end\nend\n\nwhen I start as a clone\nswitch costume to (image005 v)\nshow\nset [jumppadanimation? v] to [false]\nforever\n    goTo ((item (countInit) of [levelonex v]) - (cameraX)) ((item (countInit) of [leveloney v]) - (cameraY))\n    if <<(jumpPad?) = (countInit)> and <(jumpPadAnimation?) = [false]>> then\n        set [jumppadanimation? v] to [true]\n        set [countjumppad v] to [1]\n    end\n    if <(jumpPadAnimation?) = [true]> then\n        switch costume to ((countJumpPad) + (2))\n        change [countjumppad v] by (1)\n        if <((countJumpPad) + (2)) > [26]> then\n            set [jumppadanimation? v] to [false]\n            switch costume to (image005 v)\n        end\n    end\nend\n\n@Sprite7\n\nwhen flag clicked\n\ndefine goTo (x) (y) (size)\nset [tempgoto v] to (costume [number v])\nswitch costume to (costume1 v)\nset size to (99999) %\nswitch costume to (costume2 v)\ngo to x: (x) y: (y)\nswitch costume to (costume1 v)\nset size to (size) %\nswitch costume to (tempGoTo)\n\nadd [0] to [levelonex v]\nadd [0] to [leveloney v]\n\nwhen flag clicked\ninitLevel [1]\n\ndefine initLevel (level)\nif <(level) = [1]> then\n    set [countinit v] to [1]\n    repeat (length of [levelonez v])\n        set [cloneindex v] to (item (countInit) of [levelonez v])\n        create clone of (_myself_ v)\n        change [countinit v] by (1)\n    end\nend\n\nwhen I start as a clone\nswitch costume to (item (cloneIndex) of [levelonecostume v])\nshow\nforever\n    goTo ((item (cloneIndex) of [levelonex v]) - (cameraX)) ((item (cloneIndex) of [leveloney v]) - (cameraY)) (item (cloneIndex) of [levelonesize v])\nend\n\nadd [thing] to [levelonesize v]\nadd [4] to [levelonecostume v]\n\n@Sprite8\n\ndefine goTo (x) (y) (size)\nset [tempgoto v] to (costume [number v])\nswitch costume to (costume1 v)\nset size to (99999) %\nswitch costume to (costume2 v)\ngo to x: (x) y: (y)\nswitch costume to (costume1 v)\nset size to (size) %\nswitch costume to (tempGoTo)\n\ngo to x: (0) y: (11)\n\ngoTo ((0) - (cameraX)) ((0) - (cameraY)) [1565]\n\nwhen flag clicked\ninitLevel [1]\n\nadd [630] to [levelonex v]\nadd [-110] to [leveloney v]\nadd (round (((1452.55) / (480)) * (100))) to [levelonesize v]\n\nadd [3] to [levelonecostume v]\n\ndefine initLevel (level)\nif <(level) = [1]> then\n    set [countinit v] to [1]\n    repeat (length of [levelonex v])\n        create clone of (_myself_ v)\n        change [countinit v] by (1)\n    end\nend\n\nwhen I start as a clone\nswitch costume to (item (countInit) of [levelonecostume v])\nshow\nset [ghost v] effect to (100)\nforever\n    goTo ((item (countInit) of [levelonex v]) - (cameraX)) ((item (countInit) of [leveloney v]) - (cameraY)) (item (countInit) of [levelonesize v])\nend\n\n
It's obviously quite laggy, at least for now.\n\nThis project is far from finished, but at least I've had a bit of success on getting some of the physics working. I'm mainly working on trying to optimize the physics engine now, and trying to fix any bugs (corner detection, wall detection, jump thru platforms, etc)