Arena | A 90% Pen Scrolling Platformer (WIP)
@Stage\n\n@Scrolling Pen Platformer Engine\n\ndefine Do physics\nchange [yv v] by (-1)\nif <key (left arrow v) pressed?> then\n    change [xv v] by (-1)\nend\nif <key (right arrow v) pressed?> then\n    change [xv v] by (1)\nend\nset [xv v] to ((Xv) * (0.9))\nchange x by (Xv)\nif <touching color (#000000)?> then\n    change y by (1)\nend\nif <touching color (#000000)?> then\n    change y by (1)\nend\nif <touching color (#000000)?> then\n    change y by (1)\nend\nif <touching color (#000000)?> then\n    change y by (1)\nend\nif <touching color (#000000)?> then\n    change y by (-4)\n    change x by ((Xv) * (-1))\n    if <key (up arrow v) pressed?> then\n        set [yv v] to [17]\n        if <(Xv) > [0]> then\n            set [xv v] to [-10]\n        else\n            set [xv v] to [10]\n        end\n    else\n        set [xv v] to [0]\n    end\nend\nchange y by (Yv)\nif <touching color (#000000)?> then\n    change y by ((Yv) * (-1))\n    set [yv v] to [0]\nend\nchange y by (-1)\nif <<key (up arrow v) pressed?> and <touching color (#000000)?>> then\n    set [yv v] to [15]\nend\nchange y by (1)\nif <(Yv) < [-20]> then\n    set [yv v] to [-20]\nend\n\ndefine Draw line from (x1) (y1) to (x2) (y2) with offset (ox) (oy)\ngo to x: ((x1) + (ox)) y: ((y1) + (oy))\npen down\ngo to x: ((x2) + (ox)) y: ((y2) + (oy))\npen up\n\ndefine Draw level collision with offset (ox) (oy)\nset pen size to (2)\nset pen color to (#000000)\nDraw line from [-240] [-86] to [720] [-86] with offset (ox) (oy)\nDraw line from [720] [-86] to [720] [-200] with offset (ox) (oy)\nDraw line from [-240] [-86] to [720] [-86] with offset (ox) (oy)\nDraw line from [-240] [-200] to [720] [-200] with offset (ox) (oy)\nDraw line from [480] [0] to [560] [0] with offset (ox) (oy)\nDraw line from [560] [0] to [560] [80] with offset (ox) (oy)\nDraw line from [560] [80] to [480] [80] with offset (ox) (oy)\nDraw line from [480] [80] to [480] [0] with offset (ox) (oy)\nDraw line from [720] [80] to [800] [80] with offset (ox) (oy)\nDraw line from [800] [80] to [800] [160] with offset (ox) (oy)\nDraw line from [800] [160] to [720] [160] with offset (ox) (oy)\nDraw line from [720] [160] to [720] [80] with offset (ox) (oy)\nDraw line from [795] [160] to [850] [160] with offset (ox) (oy)\nDraw line from [850] [160] to [850] [120] with offset (ox) (oy)\nDraw line from [850] [120] to [800] [120] with offset (ox) (oy)\nDraw square at [1000] [350] and size [40] with offset (ox) (oy)\nDraw line from [1050] [-86] to [1200] [-86] with offset (ox) (oy)\nDraw line from [1200] [-86] to [1200] [-120] with offset (ox) (oy)\nDraw line from [1200] [-120] to [1050] [-120] with offset (ox) (oy)\nDraw line from [1050] [-120] to [1050] [-86] with offset (ox) (oy)\nDraw square at [520] [270] and size [80] with offset (ox) (oy)\nDraw line from [200] [230] to [480] [230] with offset (ox) (oy)\nDraw square at [160] [270] and size [80] with offset (ox) (oy)\nset pen color to (#ff0000)\nDraw line from [-16] [-86] to [-16] [-10] with offset (ox) (oy)\nDraw line from [-16] [-10] to [16] [-10] with offset (ox) (oy)\nDraw line from [16] [-10] to [16] [-86] with offset (ox) (oy)\nDraw line from [120] [-86] to [120] [-60] with offset (ox) (oy)\nDraw line from [120] [-60] to [170] [-60] with offset (ox) (oy)\nDraw line from [170] [-60] to [170] [-86] with offset (ox) (oy)\nDraw line from [240] [-86] to [240] [-60] with offset (ox) (oy)\nDraw line from [240] [-60] to [290] [-60] with offset (ox) (oy)\nDraw line from [290] [-60] to [290] [-86] with offset (ox) (oy)\nDraw square at [800] [172] and size [20] with offset (ox) (oy)\nset pen color to (#ff00e9)\nDraw square at [680] [-20] and size [40] with offset (ox) (oy)\nset pen color to (#ff8800)\nDraw square at [935] [130] and size [25] with offset (ox) (oy)\nset pen color to (#9800ff)\nDraw square at [1179] [-20] and size [40] with offset (ox) (oy)\nset pen color to (#51aaff)\nDraw line from [200] [280] to [480] [280] with offset (ox) (oy)\nDraw line from [200] [270] to [480] [270] with offset (ox) (oy)\nDraw line from [200] [260] to [480] [260] with offset (ox) (oy)\nDraw line from [200] [250] to [480] [250] with offset (ox) (oy)\nDraw line from [200] [240] to [480] [240] with offset (ox) (oy)\n\ndefine Draw square at (center x) (center y) and size (side length) with offset (ox) (oy)\ngo to x: (((center x) + (ox)) + ((side length) / (2))) y: (((center y) + (oy)) + ((side length) / (2)))\npen down\ngo to x: (((center x) + (ox)) + ((side length) / (-2))) y: (((center y) + (oy)) + ((side length) / (2)))\ngo to x: (((center x) + (ox)) + ((side length) / (-2))) y: (((center y) + (oy)) + ((side length) / (-2)))\ngo to x: (((center x) + (ox)) + ((side length) / (2))) y: (((center y) + (oy)) + ((side length) / (-2)))\ngo to x: (((center x) + (ox)) + ((side length) / (2))) y: (((center y) + (oy)) + ((side length) / (2)))\npen up\n\ndefine Draw player\nset pen color to (#1fd64f)\nset pen size to (2)\nDraw square at [0] [0] and size [14] with offset [0] [0]\n\nwhen I receive [broadcast / when \[green flag\] clicked v]\nset [checkpoint v] to [0]\nReset player\nforever\n    Collision\n    Drawing\nend\n\ndefine Do special collision\nif <<touching color (#ff0000)?> or <(Player Y) < [-240]>> then\n    Reset player\nend\nif <touching color (#ff8800)?> then\n    set [yv v] to [22]\nend\nif <touching color (#51aaff)?> then\n    if <key (down arrow v) pressed?> then\n        set [yv v] to [-1]\n    else\n        set [yv v] to [5]\n    end\nend\n\ndefine Reset player\nif <(Checkpoint) = [0]> then\n    set [player x v] to [-200]\n    set [player y v] to [0]\n    set [xv v] to [0]\n    set [yv v] to [0]\nend\nif <(Checkpoint) = [1]> then\n    set [player x v] to [680]\n    set [player y v] to [20]\n    set [xv v] to [0]\n    set [yv v] to [0]\nend\nif <(Checkpoint) = [2]> then\n    set [player x v] to [1179]\n    set [player y v] to [-20]\n    set [xv v] to [0]\n    set [yv v] to [0]\nend\n\ndefine Collision\nerase all\nDraw level collision with offset (() - (Player X)) (() - (Player Y))\ngo to x: (0) y: (0)\nDo physics\nchange [player x v] by (x position)\nchange [player y v] by (y position)\nDo special collision\nCheckpoint\n\ndefine Drawing\nset size to (10000) %\nerase all\nDraw level visual with offset (() - (Player X)) (() - (Player Y))\nDraw player\nset size to (100) %\n\ndefine Draw level visual with offset (ox) (oy)\nset pen size to (2)\nset pen color to (#000000)\nDraw line from [720] [80] to [800] [80] with offset (ox) (oy)\nDraw line from [800] [80] to [800] [160] with offset (ox) (oy)\nDraw line from [800] [160] to [720] [160] with offset (ox) (oy)\nDraw line from [720] [160] to [720] [80] with offset (ox) (oy)\nset pen color to (#ffffff)\nset pen size to (3)\nDraw line from [800] [160] to [800] [120] with offset (ox) (oy)\nset pen size to (2)\nset pen color to (#ff6251)\nDraw line from [-16] [-86] to [-16] [-10] with offset (ox) (oy)\nDraw line from [-16] [-10] to [16] [-10] with offset (ox) (oy)\nDraw line from [16] [-10] to [16] [-86] with offset (ox) (oy)\nDraw line from [120] [-86] to [120] [-60] with offset (ox) (oy)\nDraw line from [120] [-60] to [170] [-60] with offset (ox) (oy)\nDraw line from [170] [-60] to [170] [-86] with offset (ox) (oy)\nDraw line from [240] [-86] to [240] [-60] with offset (ox) (oy)\nDraw line from [240] [-60] to [290] [-60] with offset (ox) (oy)\nDraw line from [290] [-60] to [290] [-86] with offset (ox) (oy)\nDraw square at [800] [172] and size [20] with offset (ox) (oy)\nset pen color to (#1b1b1b)\nDraw line from [-240] [-86] to [-240] [-200] with offset (ox) (oy)\nDraw line from [720] [-86] to [720] [-200] with offset (ox) (oy)\nDraw line from [-240] [-86] to [720] [-86] with offset (ox) (oy)\nDraw line from [-240] [-200] to [720] [-200] with offset (ox) (oy)\nDraw line from [480] [0] to [560] [0] with offset (ox) (oy)\nDraw line from [560] [0] to [560] [80] with offset (ox) (oy)\nDraw line from [560] [80] to [480] [80] with offset (ox) (oy)\nDraw line from [480] [80] to [480] [0] with offset (ox) (oy)\nDraw line from [795] [160] to [850] [160] with offset (ox) (oy)\nDraw line from [850] [160] to [850] [120] with offset (ox) (oy)\nDraw line from [850] [120] to [800] [120] with offset (ox) (oy)\nDraw square at [1000] [350] and size [40] with offset (ox) (oy)\nDraw line from [1050] [-86] to [1200] [-86] with offset (ox) (oy)\nDraw line from [1200] [-86] to [1200] [-120] with offset (ox) (oy)\nDraw line from [1200] [-120] to [1050] [-120] with offset (ox) (oy)\nDraw line from [1050] [-120] to [1050] [-86] with offset (ox) (oy)\nDraw square at [520] [270] and size [80] with offset (ox) (oy)\nDraw line from [200] [230] to [480] [230] with offset (ox) (oy)\nDraw square at [160] [270] and size [80] with offset (ox) (oy)\nset pen color to (#ffa551)\nDraw square at [935] [130] and size [25] with offset (ox) (oy)\nset pen color to (#ff51b6)\nDraw square at [680] [-20] and size [40] with offset (ox) (oy)\nDraw square at [1179] [-20] and size [40] with offset (ox) (oy)\nset pen color to (#51aaff)\nDraw line from [200] [280] to [480] [280] with offset (ox) (oy)\nDraw line from [200] [270] to [480] [270] with offset (ox) (oy)\nDraw line from [200] [260] to [480] [260] with offset (ox) (oy)\nDraw line from [200] [250] to [480] [250] with offset (ox) (oy)\nDraw line from [200] [240] to [480] [240] with offset (ox) (oy)\n\nwhen flag clicked\nbroadcast (Broadcast / When \[green flag\] clicked v)\n\ndefine Checkpoint\nif <touching color (#ff00e9)?> then\n    set [checkpoint v] to [1]\nend\nif <touching color (#9800ff)?> then\n    set [checkpoint v] to [2]\nend\n\nwhen [space v] key pressed\nReset player\n\n@Thumbnail\n\nwhen flag clicked\nset [ghost v] effect to (100)\nforever\n    go to [front v] layer\nend\n\n