Tile Based Platformer Test v0.5

Instructions: W, A, S, D, or Arrow Keys!\n\nRun through the evil tower dodging spikes and great falls! Can you make it? What's your time?\n\nLiterally everyone was complaining about the spikes, so I made a little change. Spikes don't exist anymore, only hurty squares.

@Stage\n\nwhen flag clicked\nset [time v] to [0]\nswitch backdrop to (backdrop1 v)\nset [color v] effect to (0)\nforever\n    set [time v] to (timer)\n    set [color v] effect to ()\n    set [brightness v] effect to (0)\nend\n\nwhen I receive [win v]\nswitch backdrop to (backdrop6 v)\nstop all sounds\nstop [other scripts in sprite v]\nif <(Time) < (☁ Hi-score)> then\n    set [☁ hi-score v] to (Time)\nend\n\nwhen I receive [player spawn 1 v]\nreset timer\nplay sound [Summer Intro v] until done\nforever\n    play sound [Summer Loop v] until done\nend\n\n@Player\n\nwhen flag clicked\nset [global hue v] to (pick random (0) to ([sqrt v] of (200) ))\nset [global hue v] to ((Global HUE) * (Global HUE))\nbroadcast (Generate Level v) and wait\nbroadcast (Clone Level Tiles v) and wait\nReset Player\nbroadcast (Player Spawn 1 v)\nGame Loop\n\ndefine Move Camera\nset [camera x v] to ((Camera X) + ((((X) - (Camera X)) + ((Speed X) * (20))) * (0.05)))\nif <(Fall Off screen) = [0]> then\n    if <(Speed Y) < [-18]> then\n        change [camera y v] by ((((Y) + (-64)) - (Camera Y)) * (0.1))\n    else\n        change [camera y v] by ((((Y) + (64)) - (Camera Y)) * (0.15))\n    end\nelse\n    change [camera y v] by (((Prev Cam y) - (Camera Y)) * (0.15))\nend\nif <(Editor) < [1]> then\n    if <(Camera X) < [240]> then\n        set [camera x v] to [240]\n    end\n    if <(Camera Y) < [180]> then\n        set [camera y v] to [180]\n    end\n    if <(Camera X) > (((32) * (Grid Width)) - (240))> then\n        set [camera x v] to (((32) * (Grid Width)) - (240))\n    end\n    if <(Camera Y) > (((32) * (Grid Height)) - (180))> then\n        set [camera y v] to (((32) * (Grid Height)) - (180))\n    end\nend\n\ndefine Reset Player\nshow\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [x v] to (Spawn X)\nset [y v] to (Spawn Y)\nset [camera x v] to (Spawn X)\nset [camera y v] to (Spawn Y)\nset [height v] to [12]\nset [width v] to [12]\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [jumping v] to [0]\nset [falling v] to [0]\nMove Camera\n\ndefine Game Loop\nforever\n    broadcast (Check Controls v)\n    set [brightness v] effect to (0)\n    set [color v] effect to (0)\n    broadcast (Move Player v)\n    broadcast (Position Tiles v)\nend\n\nwhen I receive [move player v]\nif <(Editor) > [0]> then\n    Handle God Mode\n    set [falling v] to [0]\nelse\n    Handle Keys L/R\n    Handle Keys U/D\n    Move Sprite X\n    Move Sprite Y\nend\nMove Camera\nPaint Sprite\nif <(Y) < [-16]> then\n    broadcast (Player Death v)\nend\n\ndefine Get Tile at X: (x) Y: (y)\nset [tile grid x v] to ([floor v] of ((x) / (32)) )\nset [tile grid y v] to ([floor v] of ((y) / (32)) )\nset [tile index v] to (((1) + (Tile Grid Y)) + ((Tile Grid X) * (Grid Height)))\nset [tile v] to (item (Tile Index) of [tile grid v])\n\ndefine Fix Collision in Direction (dx) (dy)\nset [fix dx v] to (dx)\nset [fix dy v] to (dy)\nset [solid v] to []\nFix Collision at Point (X) (Y)\nFix Collision at Point ((X) - (Width)) ((Y) + (Height))\nFix Collision at Point ((X) + (Width)) ((Y) + (Height))\nFix Collision at Point ((X) + (Width)) ((Y) - (Height))\nFix Collision at Point ((X) - (Width)) ((Y) - (Height))\n\ndefine Fix Collision at Point (x) (y)\nGet Tile at X: (x) Y: (y)\nif <<<(Tile) = [47]> or <<(Tile) = [48]> or <(Tile) = [49]>>> or <<(Tile) = [50]> or <<(Tile) = [51]> or <(Tile) = [52]>>>> then\n    broadcast (Player Death v)\nelse\n    if <(Tile) = [58]> then\n        broadcast (Win v)\n    end\n    set [-tiny v] to [-0.00001]\n    if <(Tile) > [2]> then\n        set [counter v] to [1]\n        repeat (length of [non-colliding v])\n            if <(Tile) = (item (Counter) of [non-colliding v])> then\n                stop [this script v]\n            end\n            change [counter v] by (1)\n        end\n        if <(Tile) = [47]> then\n            set [solid v] to [99]\n        else\n            set [solid v] to [10]\n        end\n        set [mod x v] to ((x) mod (32))\n        set [mod y v] to ((y) mod (32))\n        if <(Fix DY) < [0]> then\n            change [y v] by ((32) - (mod Y))\n        end\n        if <(Fix DX) < [0]> then\n            change [x v] by ((32) - (mod X))\n        end\n        if <(Fix DY) > [0]> then\n            change [y v] by ((-TINY) - (mod Y))\n        end\n        if <(Fix DX) > [0]> then\n            change [x v] by ((-TINY) - (mod X))\n        end\n    end\nend\n\ndefine Handle Keys L/R\nset [key walk v] to ([x axis v] of [controls v])\nif <(Key Walk) = [0]> then\n    if <(Falling) = [0]> then\n        if <(Speed X) > [1]> then\n            change [speed x v] by (-1)\n        else\n            if <(Speed X) < [-1]> then\n                change [speed x v] by (1)\n            else\n                set [speed x v] to [0]\n            end\n        end\n    else\n        if <(Speed X) > [0.5]> then\n            change [speed x v] by (-0.5)\n        else\n            if <(Speed X) < [-0.5]> then\n                change [speed x v] by (0.5)\n            else\n                set [speed x v] to [0]\n            end\n        end\n    end\nelse\n    point in direction ((90) * (Key Walk))\n    if <((Key Walk) * (Speed X)) < [7]> then\n        if <((Key Walk) * (Speed X)) < [0]> then\n            change [speed x v] by ((Key Walk) * (3))\n        else\n            change [speed x v] by ((Key Walk) * (0.7))\n        end\n    end\nend\n\ndefine Handle Keys U/D\nchange [speed y v] by (-1.8)\nif <(Speed Y) < [-24]> then\n    set [speed y v] to [-24]\nend\nif <([y axis v] of [controls v]) > [0]> then\n    if <<(Falling) < [4]> or <(Jumping) > [0]>> then\n        change [jumping v] by (1)\n        if <(Jumping) < [8]> then\n            set [speed y v] to ((8) + ([abs v] of ((Speed X) / (5)) ))\n        end\n    end\nelse\n    set [jumping v] to [0]\nend\n\ndefine Move Sprite X\nchange [x v] by (Speed X)\nFix Collision in Direction (Speed X) [0]\nif <(Solid) > [0]> then\n    set [speed x v] to [0]\nend\n\ndefine Move Sprite Y\nchange [y v] by (Speed Y)\nchange [falling v] by (1)\nFix Collision in Direction [0] (Speed Y)\nbroadcast (Check player height v)\nif <(Solid) > [0]> then\n    if <(Falling) > [35]> then\n        broadcast (Fall Damage Check v)\n    end\n    if <(Speed Y) < [0]> then\n        set [falling v] to [0]\n    else\n        set [jumping v] to [99]\n    end\n    set [speed y v] to [0]\nend\n\ndefine Paint Sprite\nswitch costume to (basic v)\ngo to x: ((X) - (Camera X)) y: ((Y) - (Camera Y))\n\ndefine Handle God Mode\nchange [speed x v] by (([x axis v] of [controls v]) * (4))\nchange [speed y v] by (([y axis v] of [controls v]) * (4))\nset [speed x v] to ((Speed X) * (0.7))\nset [speed y v] to ((Speed Y) * (0.7))\nchange [x v] by (Speed X)\nchange [y v] by (Speed Y)\n\nwhen I receive [delete v]\ndelete all of [non-colliding v]\nadd [2] to [non-colliding v]\nadd [21] to [non-colliding v]\nadd [22] to [non-colliding v]\nadd [23] to [non-colliding v]\nadd [24] to [non-colliding v]\nadd [25] to [non-colliding v]\nadd [26] to [non-colliding v]\nadd [27] to [non-colliding v]\nadd [31] to [non-colliding v]\nadd [32] to [non-colliding v]\nadd [37] to [non-colliding v]\nadd [38] to [non-colliding v]\nadd [44] to [non-colliding v]\nadd [45] to [non-colliding v]\nadd [46] to [non-colliding v]\nadd [53] to [non-colliding v]\nadd [54] to [non-colliding v]\nadd [55] to [non-colliding v]\nadd [56] to [non-colliding v]\nadd [57] to [non-colliding v]\nadd [58] to [non-colliding v]\n\nwhen I receive [player death v]\nbroadcast (Disable Controls for 2 sec v)\nset [speed x v] to [0]\nset [speed y v] to [0]\nif <<(CPX) = []> and <(CPY) = []>> then\n    set [x v] to (Spawn X)\n    set [y v] to (Spawn Y)\nelse\n    set [x v] to (CPX)\n    set [y v] to (CPY)\nend\nrepeat (3)\n    set [ghost v] effect to (75)\n    wait (0.1) seconds\n    set [ghost v] effect to (0)\n    wait (0.1) seconds\nend\nclear graphic effects\n\nwhen I receive [fall damage check v]\nbroadcast (Player Death v)\n\ndefine Find Height\nset [height above ground v] to (([floor v] of ((Y) / (32)) ) + (([floor v] of ((X) / (32)) ) * (Grid Height)))\nset [counter h v] to (([floor v] of ((Y) / (32)) ) + (([floor v] of ((X) / (32)) ) * (Grid Height)))\nrepeat until <not <(item (Counter H) of [tile grid v]) = [2]>>\n    change [counter h v] by (-1)\nend\nset [height above ground v] to ((Height above ground) - (Counter H))\n\nwhen I receive [check player height v]\nFind Height\n\nif <<(Height above ground) > [10]> or <(Fall Off screen) > [20]>> then\n    if <(Prev Cam y) = []> then\n        set [prev cam y v] to (Y)\n    end\n    if <<not <(Solid) > [0]>> and <(Falling) > [22]>> then\n        set [falling v] to [99]\n    end\n    change [fall off screen v] by (1)\n    if <(Solid) > [0]> then\n        set [fall off screen v] to [0]\n    end\nelse\n    set [prev cam y v] to []\n    if <(Solid) > [0]> then\n        set [fall off screen v] to [0]\n    end\nend\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\n\n@Tiles\n\ndefine Steup\nshow\nset [tile index v] to [1]\nset [tile x v] to [16]\nrepeat (Clone Count X)\n    set [tile y v] to [16]\n    repeat (Clone Count Y)\n        create clone of (_myself_ v)\n        change [tile index v] by (1)\n        change [tile y v] by (32)\n    end\n    change [tile x v] by (32)\n    change [tile index v] by ((Grid Height) - (Clone Count Y))\nend\nhide\nset [tile index v] to []\n\nwhen I receive [position tiles v]\nset [color v] effect to ()\nset [brightness v] effect to (0)\ngo to [back v] layer\nif <(Tile Index) = []> then\n    Editor Brush\nelse\n    if <([abs v] of ((Tile X) - (Camera X)) ) > ((Clone Count X) * (16))> then\n        if <(Tile X) < (Camera X)> then\n            Loop Tile X (Clone Count X)\n        else\n            Loop Tile X ((0) - (Clone Count X))\n        end\n    end\n    if <([abs v] of ((Tile Y) - (Camera Y)) ) > ((Clone Count Y) * (16))> then\n        if <(Tile Y) < (Camera Y)> then\n            Loop Tile Y (Clone Count Y)\n        else\n            Loop Tile Y ((0) - (Clone Count Y))\n        end\n    end\n    set [tile v] to (item (Tile Index) of [tile grid v])\nend\nswitch costume to (big v)\ngo to x: ((Tile X) - (Camera X)) y: ((Tile Y) - (Camera Y))\nif <(Tile) < [2]> then\n    set [tile v] to [2]\nend\nswitch costume to (Tile)\nif <<(item (Tile Index) of [tile grid v]) = [53]> and <(Tile Index) = ((1) + (([floor v] of (([y v] of [player v]) / (32)) ) + (([floor v] of (([x v] of [player v]) / (32)) ) * (Grid Height))))>> then\n    start sound [Bell 8-bit SFX v]\n    set [checked v] to (Tile Index)\n    set [cp hit v] to (Tile Index)\n    set [cpx v] to (Tile X)\n    set [cpy v] to (Tile Y)\n    broadcast (Bell Checkpoint v)\nend\n\ndefine Loop Tile X (tile skip)\nchange [tile x v] by ((tile skip) * (32))\nchange [tile index v] by ((tile skip) * (Grid Height))\n\ndefine Loop Tile Y (tile skip)\nchange [tile y v] by ((tile skip) * (32))\nchange [tile index v] by (tile skip)\n\nwhen I receive [clone level tiles v]\nset size to (200) %\nset [clone count y v] to [13]\nset [clone count x v] to [16]\nset [checked v] to [0]\nSteup\n\ndefine Editor Brush\nif <<(Editor) < [1]> or <mouse down?>> then\n    hide\n    stop [this script v]\nend\nset [tile x v] to (((32) * ([tile grid x v] of [editor v])) + (16))\nset [tile y v] to (((32) * ([tile grid y v] of [editor v])) + (16))\nset [tile v] to ([chosen brush v] of [editor v])\nset [ghost v] effect to (50)\nshow\n\nwhen I receive [bell checkpoint v]\nif <not <(Checked) = (CP HIT)>> then\n    stop [this script v]\nend\nreplace item (Tile Index) of [tile grid v] with [54]\nset [cp rs counter v] to [57]\nbroadcast (Reset CP v)\nwait (0.45) seconds\nreplace item (Tile Index) of [tile grid v] with [55]\nwait (0.1) seconds\nreplace item (Tile Index) of [tile grid v] with [56]\nwait (0.45) seconds\nreplace item (Tile Index) of [tile grid v] with [57]\nset [checked v] to [0]\n\nwhen I receive [reset cp v]\nif <(Tile Index) = []> then\n    Reset CPs\nend\n\nwhen I receive [player spawn 1 v]\nset [cpx v] to []\nset [cpy v] to []\nwait (0.1) seconds\nbroadcast (Full Reset CP v)\n\ndefine Reset CPs\nrepeat until <not <[tile grid v] contains (CP rs counter)?>>\n    replace item (item # of (CP rs counter) in [tile grid v]) of [tile grid v] with [53]\nend\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\n\nwhen I receive [full reset cp v]\nif <(Tile Index) = []> then\n    set [cp rs counter v] to [53]\n    repeat (4)\n        change [cp rs counter v] by (1)\n        Reset CPs\n    end\nend\n\n@Editor\n\ndefine Generate Level\ndelete all of [tile grid v]\nAdd Wall Column\nSpawn\nrepeat ((Grid Width) - (3))\n    Add Boxed Column\nend\nAdd Wall Column\n\ndefine Add Wall Column\nrepeat (Grid Height)\n    add [28] to [tile grid v]\nend\n\ndefine Add Boxed Column\nadd [17] to [tile grid v]\nadd [3] to [tile grid v]\nrepeat ((Grid Height) - (3))\n    add [2] to [tile grid v]\nend\nadd [28] to [tile grid v]\n\nwhen I receive [generate level v]\nset [editor v] to [0]\nset [brush v] to [0]\nset [chosen brush v] to [4]\nif <(Delete) = [1]> then\n    broadcast (Delete v) and wait\nend\nif <(length of [tile grid v]) = [0]> then\n    set [delete v] to [0]\n    Generate Level\nend\n\nwhen I receive [move player v]\nif <key (q v) pressed?> then\n    set [chosen brush v] to (Tile)\nend\nif <(Editor) < [1]> then\n    stop [this script v]\nend\nGet Tile at X: ((mouse x) + (Camera X)) Y: ((mouse y) + (Camera Y))\nif <not <mouse down?>> then\n    set [brush v] to [0]\n    stop [this script v]\nend\nif <(Brush) = [0]> then\n    if <(Tile) = (Chosen Brush)> then\n        set [brush v] to [2]\n    else\n        set [brush v] to (Chosen Brush)\n    end\nend\nif <<<(Chosen Brush) = [31]> or <(Chosen Brush) = [32]>> or <(Chosen Brush) = [45]>> then\n    replace item (item # of [31] in [tile grid v]) of [tile grid v] with [2]\n    replace item (item # of [32] in [tile grid v]) of [tile grid v] with [21]\n    replace item (item # of [45] in [tile grid v]) of [tile grid v] with [44]\n    set [spawn x v] to (((Tile Grid X) * (32)) + (16))\n    set [spawn y v] to (((Tile Grid Y) * (32)) + (16))\nend\nif <not <(item # of (Tile Index) in [tile grid v]) = []>> then\n    replace item (Tile Index) of [tile grid v] with (Brush)\n    if <(Pretty Brush) = [1]> then\n        Make Prettier\n    end\nend\n\ndefine Get Tile at X: (x) Y: (y)\nset [tile grid x v] to ([floor v] of ((x) / (32)) )\nset [tile grid y v] to ([floor v] of ((y) / (32)) )\nset [tile index v] to (((1) + (Tile Grid Y)) + ((Tile Grid X) * (Grid Height)))\nset [tile v] to (item (Tile Index) of [tile grid v])\n\nwhen [1 v] key pressed\nNext Brush [1]\n\nwhen [2 v] key pressed\nNext Brush [2]\n\nwhen [3 v] key pressed\nNext Brush [3]\n\nwhen [e v] key pressed\n\nif <(Editor) = [0]> then\n    set [editor v] to [1]\nelse\n    set [editor v] to [0]\nend\n\nwhen I receive [delete v]\ndelete all of [tile grid v]\n\nwhen [o v] key pressed\n\nwhen I receive [show v]\nshow variable [delete v]\nshow variable [grid height v]\nshow variable [grid width v]\nstop [all v]\n\nwhen [4 v] key pressed\nNext Brush [4]\n\ndefine Next Brush (key)\nrepeat (length of [tile key map v])\n    if <(Chosen Brush) < (length of [tile key map v])> then\n        change [chosen brush v] by (1)\n    else\n        set [chosen brush v] to [0]\n    end\n    if <(item (Chosen Brush) of [tile key map v]) = (key)> then\n        stop [this script v]\n    end\nend\n\nwhen I receive [move player v]\nif <(Editor) = [0]> then\n    hide variable [chosen brush v]\n    hide variable [pretty brush v]\nelse\n    show variable [chosen brush v]\n    show variable [pretty brush v]\nend\n\ndefine Spawn\nadd [17] to [tile grid v]\nadd [3] to [tile grid v]\nadd [31] to [tile grid v]\nset [spawn x v] to [48]\nset [spawn y v] to ((64) + (16))\nrepeat ((Grid Height) - (4))\n    add [2] to [tile grid v]\nend\nadd [28] to [tile grid v]\n\ndefine Make Prettier\nset [counter v] to [0]\nrepeat (length of [tile grid v])\n    change [counter v] by (1)\n    set [1 v] to (item ((Counter) + (1)) of [tile grid v])\n    set [2 v] to (item ((Counter) + (Grid Height)) of [tile grid v])\n    set [3 v] to (item ((Counter) - (1)) of [tile grid v])\n    set [4 v] to (item ((Counter) - (Grid Height)) of [tile grid v])\n    Check ####: (1) (2) (3) (4) (item (Counter) of [tile grid v]) (Counter)\nend\n\ndefine Check ####: (up) (right) (down) (left) (tile) (tile i)\nif <<(tile) = [3]> and <<<(up) = [2]> and <(right) = [2]>> and <(left) = [3]>>> then\n    replace item (tile i) of [tile grid v] with [4]\nend\nif <<(tile) = [3]> and <<<(up) = [2]> and <(right) = [3]>> and <(left) = [2]>>> then\n    replace item (tile i) of [tile grid v] with [6]\nend\nif <<(tile) = [17]> and <<<<<(up) = [19]> or <(up) = [4]>> or <(up) = [17]>> and <(right) = [2]>> and <(left) = [17]>>> then\n    replace item (tile i) of [tile grid v] with [19]\nend\nif <<(tile) = [17]> and <<<<<(up) = [20]> or <(up) = [6]>> or <(up) = [17]>> and <(right) = [17]>> and <(left) = [2]>>> then\n    replace item (tile i) of [tile grid v] with [20]\nend\nif <<<(tile) = [17]> or <(tile) = [3]>> and <<<(up) = [20]> and <(right) = [17]>> and <(left) = [3]>>> then\n    replace item (tile i) of [tile grid v] with [15]\nend\nif <<<(tile) = [17]> or <(tile) = [3]>> and <<<(up) = [19]> and <(right) = [3]>> and <(left) = [17]>>> then\n    replace item (tile i) of [tile grid v] with [13]\nend\n\nwhen flag clicked\nset [pretty brush v] to [0]\nforever\n    wait until <key (space v) pressed?>\n    if <not <(Editor) < [1]>> then\n        if <(Pretty Brush) = [1]> then\n            set [pretty brush v] to [0]\n        else\n            set [pretty brush v] to [1]\n        end\n    end\n    wait until <not <key (space v) pressed?>>\nend\n\nwhen flag clicked\nforever\n    if <(Pretty Brush) = [1]> then\n        Make Prettier\n        set [pretty brush v] to [0]\n    end\nend\n\nset [grid width v] to [1500]\nset [grid height v] to [80]\n\nwhen flag clicked\nhide variable [delete v]\nhide variable [grid height v]\nhide variable [grid width v]\n\nif <(Delete) = [0]> then\n    set [delete v] to [1]\n    broadcast (show v) and wait\nelse\n    set [delete v] to [0]\n    broadcast (show v) and wait\nend\nbroadcast (show v)\n\nwhen I receive [win v]\nstop [other scripts in sprite v]\n\n@Controls\n\nwhen I receive [check controls v]\nif <(Controlable) = [1]> then\n    set [left v] to <<key (left arrow v) pressed?> or <key (a v) pressed?>>\n    set [right v] to <<key (right arrow v) pressed?> or <key (d v) pressed?>>\n    set [up v] to <<key (up arrow v) pressed?> or <key (w v) pressed?>>\n    set [down v] to <<key (down arrow v) pressed?> or <key (s v) pressed?>>\n    set [x axis v] to ((Right) - (Left))\n    set [y axis v] to ((Up) - (Down))\nend\n\nwhen I receive [disable controls for 2 sec v]\nset [left v] to [0]\nset [right v] to [0]\nset [up v] to [0]\nset [down v] to [0]\nset [x axis v] to [0]\nset [y axis v] to [0]\nset [controlable v] to [0]\nwait (1) seconds\nset [controlable v] to [1]\n\nwhen flag clicked\nset [controlable v] to [1]\n\nwhen I receive [win v]\nstop [other scripts in sprite v]\n\n@Darkness\n\nwhen I receive [position tiles v]\nhide\n\nif <((200) - (Darknessssssss)) < [180]> then\n    show\n    set size to (0) %\n    switch costume to (costume2 v)\n    go to x: (([x v] of [player v]) - (Camera X)) y: (([y v] of [player v]) - (Camera Y))\n    set size to (((200) - (Darknessssssss)) + ([floor v] of (([sin v] of ((timer) * (500)) ) * (([sin v] of ((timer) * (280)) ) * (1.5))) )) %\n    switch costume to (costume1 v)\nend\n\nwhen flag clicked\nset [darknessssssss v] to (pick random (0) to (50))\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\n\n