⭐ Star Collector (Pen Platformer)


@Stage\n\nwhen flag clicked\nswitch backdrop to (join [1] [])\n\n@zPawPalette\n\nwhen flag clicked\nhide\ngo to x: (0) y: (0)\nset volume to (100) %\nforever\n    play sound [Butter Building - Kirby's Epic Yarn v] until done\nend\n\nwhen [m v] key pressed\nif <(volume) = [0]> then\n    set volume to (100) %\nelse\n    set volume to (0) %\nend\n\n@zThumbnail2\n\nwhen flag clicked\nhide\ngo to x: (0) y: (0)\n\ndefine Thumbnail\nshow\ngo to x: (0) y: (0)\nset size to (100) %\ngo to [front v] layer\nhide variable [stars display v]\n\n@renderer\n\nwhen flag clicked\npen up\nerase all\nhide\ngo to x: (0) y: (0)\npoint in direction (90)\nset [xscroll v] to [0]\nset [yscroll v] to [0]\nset [stars v] to [0]\nset [atmouse v] to [0]\nhide variable [edit.selection v]\nhide variable [edit.description v]\nset [checkpointx v] to [0]\nset [checkpointy v] to [0]\nshow variable [stars display v]\nreset level storages\nreset player\nforever\n    frame\nend\n\ndefine renderlevel\nset [levelblock# v] to [0]\ngo to x: ((-240) + (10)) y: ((-180) + (10))\ngo to x: ((x position) + ((() - (Xscroll)) mod (-20))) y: ((y position) + ((() - (Yscroll)) mod (-20)))\nset [gobacktox v] to (x position)\nset [x v] to ([floor v] of ((Xscroll) / (20)) )\nset [y v] to ([floor v] of ((Yscroll) / (20)) )\nrepeat (19)\n    repeat (25)\n        change [x v] by (1)\n        set [levelblock# v] to ((x) + ((y) * (MAP LENGTH)))\n        set [iam v] to (item (levelblock#) of [level1 v])\n        if <(iam) = [1]> then\n            set pen color to (#e1ad96)\n        else\n            if <(iam) = [2]> then\n                set pen color to (#bcf09e)\n            else\n                if <(iam) = [3]> then\n                    set pen color to (#f3afea)\n                else\n                    if <(iam) = [4]> then\n                        set pen color to (#d54e4e)\n                        draw box size (10)\n                        set pen color to (#ed6e6e)\n                    else\n                        if <(iam) = [7]> then\n                            set pen color to (#7f98e4)\n                            set [watertop v] to [0]\n                            change [y v] by (1)\n                            set [levelblock# v] to ((x) + ((y) * (MAP LENGTH)))\n                            if <<[non-solid v] contains (item (levelblock#) of [level1 v])?> and <not <(item (levelblock#) of [level1 v]) = [7]>>> then\n                                set pen color to (#8fb2ff)\n                                set [watertop v] to [1]\n                            end\n                            change [y v] by (-1)\n                            set [levelblock# v] to ((x) + ((y) * (MAP LENGTH)))\n                        else\n                            if <<(iam) = [10]> or <(iam) = [11]>> then\n                                set pen color to (#626365)\n                            else\n                                set pen color to (#ffdb8d)\n                            end\n                        end\n                    end\n                end\n            end\n        end\n        if <(iam) = [0]> then\n        else\n            if <(iam) = [5]> then\n                if <(item (levelblock#) of [level1storage v]) = [0]> then\n                    draw star size (6)\n                else\n                end\n            else\n                if <(iam) = [4]> then\n                    set pen size to ((([sin v] of (((timer) + ((x) + (y))) * (400)) ) * (3)) + (10))\n                    pen down\n                    pen up\n                else\n                    if <(iam) = [7]> then\n                        if <(watertop) = [1]> then\n                            change y by (-1)\n                        end\n                        draw box size (12)\n                        if <(watertop) = [1]> then\n                            change y by (1)\n                            set pen color to (#ffffff)\n                            set pen size to (4)\n                            change x by (10)\n                            change y by ((([sin v] of (((timer) + ((x) + (y))) * (400)) ) * (2)) + (11))\n                            pen down\n                            change x by (-20)\n                            pen up\n                            change x by (10)\n                            change y by ((([sin v] of (((timer) + ((x) + (y))) * (400)) ) * (-2)) - (11))\n                            set [randomx v] to ((([sin v] of (((timer) + ((x) + (y))) * (400)) ) * (10)) + (0))\n                            set [randomy v] to (pick random (6) to (10))\n                            set pen color to (#ffffff)\n                            set pen size to (pick random (2) to (4))\n                            change x by (() + (randomx))\n                            change y by (() + (randomy))\n                            pen down\n                            pen up\n                            change x by (() - (randomx))\n                            change y by (() - (randomy))\n                        end\n                    else\n                        if <(iam) = [8]> then\n                            if <(item (levelblock#) of [level1storage v]) > [0]> then\n                                replace item (levelblock#) of [level1storage v] with ((item (levelblock#) of [level1storage v]) + (1))\n                                if <(item (levelblock#) of [level1storage v]) = [30]> then\n                                    replace item (levelblock#) of [level1 v] with [9]\n                                end\n                            end\n                            set pen color to (#ffad7c)\n                            draw box size (12)\n                            set pen color to (#cfefff)\n                            draw box size (((item (levelblock#) of [level1storage v]) / (30)) * (12))\n                        else\n                            if <(iam) = [9]> then\n                                if <(item (levelblock#) of [level1storage v]) > [0]> then\n                                    replace item (levelblock#) of [level1storage v] with ((item (levelblock#) of [level1storage v]) - (1))\n                                else\n                                    replace item (levelblock#) of [level1 v] with [8]\n                                end\n                                set pen color to (#ffdbb8)\n                                draw box size (((((item (levelblock#) of [level1storage v]) * (-1)) + (30)) / (30)) * (12))\n                            else\n                                draw box size (12)\n                                if <<(iam) = [10]> or <(iam) = [11]>> then\n                                    set pen color to (#ffffff)\n                                    set pen size to (4)\n                                    if <(iam) = [10]> then\n                                        set [randomx v] to ((round (((timer) * (50)) mod (20))) - (10))\n                                    else\n                                        set [randomx v] to ((round (((timer) * (-50)) mod (20))) - (10))\n                                    end\n                                    change x by (randomx)\n                                    pen down\n                                    pen up\n                                    change x by (() - (randomx))\n                                    if <(iam) = [10]> then\n                                        set [randomx v] to ((round ((((timer) - (1)) * (50)) mod (20))) - (10))\n                                    else\n                                        set [randomx v] to ((round ((((timer) - (1)) * (-50)) mod (20))) - (10))\n                                    end\n                                    change x by (randomx)\n                                    pen down\n                                    pen up\n                                    change x by (() - (randomx))\n                                else\n                                    if <(iam) = [6]> then\n                                        get block at xpos (playerX) ypos ((playerY) - (10))\n                                        if <(getblockis) = (levelblock#)> then\n                                            set pen color to (#ffffff)\n                                        else\n                                            set pen color to (#edb56e)\n                                        end\n                                        set pen size to ((([sin v] of (((timer) + ((x) + (y))) * (400)) ) * (3)) + (10))\n                                        pen down\n                                        pen up\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n        if <(atmouse) = (levelblock#)> then\n            set pen color to (#ffdb8d)\n            draw star size (8)\n        end\n        change x by (20)\n    end\n    change y by (20)\n    change [y v] by (1)\n    set x to (gobacktoX)\n    change [x v] by (-25)\nend\ngo to x: ((CheckpointX) - (Xscroll)) y: ((CheckpointY) - (Yscroll))\nset pen color to (#9be0f8)\nset pen size to ((([sin v] of ((timer) * (200)) ) * (4)) + (12))\npen down\npen up\nset pen color to (#ffffff)\nchange pen size by (-5)\npen down\npen up\n\ndefine movecharacter\nchange [playerxvel v] by ((<key (right arrow v) pressed?> - <key (left arrow v) pressed?>) * (2))\nset [playerxvel v] to ((playerXvel) * (0.7))\nget block at xpos ((playerX) + (playerXvel)) ypos (playerY)\nif <[non-solid v] contains (item (getblockis) of [level1 v])?> then\n    get block at xpos ((playerX) + (playerXvel)) ypos ((playerY) + (11))\n    if <[non-solid v] contains (item (getblockis) of [level1 v])?> then\n        change [playerx v] by (playerXvel)\n    else\n        set [playerxvel v] to [0]\n        if <(item (getblockis) of [level1 v]) = [8]> then\n            if <(item (getblockis) of [level1storage v]) < [1]> then\n                replace item (getblockis) of [level1storage v] with [1]\n            end\n        else\n        end\n    end\nelse\n    set [playerxvel v] to [0]\n    if <(item (getblockis) of [level1 v]) = [8]> then\n        if <(item (getblockis) of [level1storage v]) < [1]> then\n            replace item (getblockis) of [level1storage v] with [1]\n        end\n    else\n    end\nend\nget block at xpos (playerX) ypos ((playerY) + (6))\nif <(item (getblockis) of [level1 v]) = [7]> then\n    set [playeryvel v] to ((playerYvel) * (0.8))\n    if <key (up arrow v) pressed?> then\n        change [playeryvel v] by (1)\n    end\n    if <key (down arrow v) pressed?> then\n        change [playeryvel v] by (-1)\n    end\nelse\n    if <key (up arrow v) pressed?> then\n        change [playeryvel v] by (-0.7)\n    else\n        change [playeryvel v] by (-1.2)\n    end\nend\nget block at xpos (playerX) ypos ((playerY) + (playerYvel))\nif <[non-solid v] contains (item (getblockis) of [level1 v])?> then\n    get block at xpos (playerX) ypos (((playerY) + (playerYvel)) + (12))\n    if <[non-solid v] contains (item (getblockis) of [level1 v])?> then\n        change [playery v] by (playerYvel)\n    else\n        set [playeryvel v] to [0]\n        if <(item (getblockis) of [level1 v]) = [8]> then\n            if <(item (getblockis) of [level1storage v]) < [1]> then\n                replace item (getblockis) of [level1storage v] with [1]\n            end\n        else\n        end\n    end\nelse\n    set [playeryvel v] to [0]\n    if <(item (getblockis) of [level1 v]) = [8]> then\n        if <(item (getblockis) of [level1storage v]) < [1]> then\n            replace item (getblockis) of [level1storage v] with [1]\n        end\n    else\n    end\nend\nget block at xpos (playerX) ypos ((playerY) - (8))\nif <[non-solid v] contains (item (getblockis) of [level1 v])?> then\nelse\n    if <(item (getblockis) of [level1 v]) = [10]> then\n        change [playerxvel v] by (0.85)\n    else\n        if <(item (getblockis) of [level1 v]) = [11]> then\n            change [playerxvel v] by (-0.85)\n        else\n            if <(item (getblockis) of [level1 v]) = [8]> then\n                if <(item (getblockis) of [level1storage v]) < [1]> then\n                    replace item (getblockis) of [level1storage v] with [1]\n                end\n            else\n                if <(item (getblockis) of [level1 v]) = [6]> then\n                    set [checkpointx v] to (playerX)\n                    set [checkpointy v] to (playerY)\n                end\n            end\n        end\n    end\n    if <(item (getblockis) of [level1 v]) = [3]> then\n        set [playeryvel v] to [25]\n    else\n        if <key (up arrow v) pressed?> then\n            set [playeryvel v] to [11.5]\n        else\n            set [playeryvel v] to [0]\n        end\n    end\nend\nget block at xpos (playerX) ypos ((playerY) + (15))\nif <(item (getblockis) of [level1 v]) = [4]> then\n    reset player\nelse\n    if <(item (getblockis) of [level1 v]) = [5]> then\n        if <(item (getblockis) of [level1storage v]) = [0]> then\n            replace item (getblockis) of [level1storage v] with [1]\n            change [stars v] by (1)\n            start sound [Bloop v]\n        end\n    else\n    end\nend\n\ndefine block at mouse\nset [atmouse v] to ((([floor v] of ((((mouse x) + (Xscroll)) - (0)) / (20)) ) + (([floor v] of ((((mouse y) + (Yscroll)) - (0)) / (20)) ) * (MAP LENGTH))) + (877))\n\ndefine None\nset [getblockis v] to (((round (((x) + (10)) / (20))) + ((round ((y) / (20))) * (MAP LENGTH))) + (780))\n\ndefine frame\nerase all\npan camera\nrenderlevel\nmovecharacter\nrendercharacter\n\ndefine rendercharacter\ngo to x: ((playerX) - (Xscroll)) y: ((playerY) - (Yscroll))\nset pen size to (8)\nchange y by (6)\nset pen color to (#a57957)\npen down\nset pen size to (4)\nchange y by (-8)\npen up\nset [legx v] to (x position)\nset [legy v] to (y position)\ngo to x: (legx) y: (legy)\nset pen color to (#79502f)\npen down\ngo to x: ((legx) + (([sin v] of ((timer) * (600)) ) * (([abs v] of (playerXvel) ) * (-1)))) y: ((y position) - (7))\npen up\ngo to x: (legx) y: (legy)\nset pen color to (#a57957)\npen down\ngo to x: ((legx) + (([sin v] of ((timer) * (600)) ) * (([abs v] of (playerXvel) ) * (1)))) y: ((y position) - (7))\npen up\ngo to x: (legx) y: ((legy) + (6))\nset pen color to (#79502f)\npen down\ngo to x: (((legx) + (0)) + (([sin v] of ((timer) * (600)) ) * ((([abs v] of (playerXvel) ) + (3)) * (1)))) y: ((y position) - (7))\npen up\ngo to x: (legx) y: ((legy) + (6))\nset pen color to (#a57957)\npen down\ngo to x: (((legx) - (0)) + (([sin v] of ((timer) * (600)) ) * ((([abs v] of (playerXvel) ) + (3)) * (-1)))) y: ((y position) - (7))\npen up\n\ndefine pan camera\nif <(playerX) < [0]> then\n    set [camx v] to [0]\nelse\n    if <(playerX) > (((MAP LENGTH) - (24)) * (20))> then\n        set [camx v] to (((MAP LENGTH) - (24)) * (20))\n    else\n        set [camx v] to (playerX)\n    end\nend\nif <(playerY) < [0]> then\n    set [camy v] to [0]\nelse\n    if <(playerY) > (((MAP HEIGHT) - (18)) * (20))> then\n        set [camy v] to (((MAP HEIGHT) - (18)) * (20))\n    else\n        set [camy v] to (playerY)\n    end\nend\nchange [xscroll v] by (((camX) - (Xscroll)) / (8))\nchange [yscroll v] by (((camY) - (Yscroll)) / (8))\n\ndefine reset level storages\ndelete (all) of [level1storage v]\nrepeat until <not <(length of [level1storage v]) < (length of [level1 v])>>\n    add [0] to [level1storage v]\nend\n\nwhen [z v] key pressed\nchange [edit.selection v] by (-1)\nset [edit.selection v] to ((edit.Selection) mod (length of [blocknames v]))\n\nwhen [x v] key pressed\nchange [edit.selection v] by (1)\nset [edit.selection v] to ((edit.Selection) mod (length of [blocknames v]))\n\nwhen [c v] key pressed\nwait until <not <key (c v) pressed?>>\nshow variable [edit.selection v]\nshow variable [edit.description v]\nset [edit.selection v] to [1]\nrepeat until <key (c v) pressed?>\n    edit mode\nend\nset [atmouse v] to [0]\nhide variable [edit.selection v]\nhide variable [edit.description v]\n\ndefine edit mode\nif <([abs v] of (mouse x) ) < [235]> then\n    if <([abs v] of (mouse y) ) < [175]> then\n        block at mouse\n        if <mouse down?> then\n            replace item (atmouse) of [level1 v] with (edit.Selection)\n            replace item (atmouse) of [level1storage v] with [0]\n        end\n    end\nend\nset [edit.description v] to (item ((edit.Selection) + (1)) of [blocknames v])\n\ndefine create new level\nrepeat (MAP LENGTH)\n    add [1] to [level1 v]\nend\nrepeat ((MAP HEIGHT) - (2))\n    add [1] to [level1 v]\n    repeat ((MAP LENGTH) - (2))\n        add [0] to [level1 v]\n    end\n    add [1] to [level1 v]\nend\nrepeat (MAP LENGTH)\n    add [1] to [level1 v]\nend\n\ndefine reset player\nset [playerxvel v] to [0]\nset [playeryvel v] to [0]\nset [playerx v] to (CheckpointX)\nset [playery v] to (CheckpointY)\n\ndefine None\nset [size v] to (size)\nset pen size to ((size) / (3))\npoint in direction (((timer) + (((x) + (y)) / (4))) * (200))\nmove ((size) / (2)) steps\npen down\nrepeat (5)\n    turn right ((180) + ((180) / (5))) degrees\n    move (size) steps\nend\npen up\nmove ((size) / (-2)) steps\npoint in direction (90)\n\nwhen [r v] key pressed\nreset player\n\ndefine None\nset [size v] to (size)\nset pen size to ((size) + (0))\nchange x by ((size) / (2))\nchange y by ((size) / (-2))\npen down\nchange y by ((size) / (1))\nchange x by ((size) / (-1))\nchange y by ((size) / (-1))\nchange x by ((size) / (1))\npen up\nchange x by ((size) / (-2))\nchange y by ((size) / (2))\n\n@finish!\n\nwhen flag clicked\nhide\ngo to x: (0) y: (0)\nshow variable [stars display v]\nset [max stars v] to [305]\nset [stars v] to [0]\nrepeat until <(Stars) = (MAX STARS)>\n    set [stars display v] to (join (join (Stars) [ / ]) (MAX STARS))\n    wait (0.1) seconds\nend\nstart sound [Finished v]\nset [stars display v] to [Complete!]\nshow\ngo to x: (0) y: (15)\nset size to (100) %\nset [velocity v] to [10]\nrepeat (21)\n    change size by (5)\n    change y by (velocity)\n    change [velocity v] by (-1)\nend\nrepeat (60)\n    change y by (-0.5)\n    wait (0.1) seconds\nend\nset [velocity v] to [0]\nrepeat (23)\n    change y by (velocity)\n    change [velocity v] by (-1)\nend\nhide\n\n