Platformer for squirrels(chipm0nk) contest
@Stage\n\nwhen flag clicked\ninit\n\nwhen I receive [start level v]\nstop [other scripts in sprite v]\nswitch backdrop to (sky v)\nforever\n    play sound [SMG2 - Battle Belt Galaxy v] until done\nend\n\nwhen [e v] key pressed\nif <(username) = [amylaser]> then\n    set [@unlocked_levels v] to (=max_levels)\n    if <(@game state) = [go]> then\n        set [@game state v] to [edit]\n    else\n        if <(@game state) = [edit]> then\n            set [@game state v] to [go]\n        end\n    end\n    broadcast (change game state v)\nend\n\nwhen I receive [change_volume2 v]\nset volume to ((100) * (@sound_on?)) %\n\nwhen [m v] key pressed\nstop [other scripts in sprite v]\nset [@game state v] to [title]\nbroadcast (title v)\n\ndefine init_levels\nset [@camera lock v] to [0]\ndelete all of [level spawns v]\nrepeat ((=max_levels) * (2))\n    add [] to [level spawns v]\nend\nadd level spawn [1] [-50] [-110]\nadd level spawn [2] [-130] [740]\nadd level spawn [3] [-120] [1440]\n\ndefine add level spawn (level#) (x) (y)\nreplace item ((level#) * (2)) of [level spawns v] with (y)\nreplace item (((level#) * (2)) - (1)) of [level spawns v] with (x)\n\ndefine init\nset [@camera x v] to [0]\nset [@camera y v] to [0]\nset [@game state v] to [title]\nset [@fish_collected v] to [0]\nset [=max_levels v] to [3]\nset [=panel_width v] to [480]\nset [=panel_height v] to [360]\nset [=level_width_panels v] to [3]\nset [=level_height_panels v] to [2]\nset [=level_width_px v] to ((=level_width_panels) * (=panel_width))\nset [=level_height_px v] to ((=level_height_panels) * (=panel_height))\nset [=map_width_panels v] to (=level_width_panels)\nset [=map_height_panels v] to ((=level_height_panels) * (=max_levels))\nset [=map_width_px v] to ((=map_width_panels) * (=panel_width))\nset [=map_height_px v] to ((=map_height_panels) * (=panel_height))\nset [@sound_on? v] to [1]\nset [@curr_level v] to [1]\nset [@unlocked_levels v] to [1]\nset [@score v] to [0]\nset [@camera_speed v] to [10]\nhide variable [@camera_speed v]\nset volume to (100) %\nswitch backdrop to (cat_wallpaper v)\ninit_levels\n\nwhen [r v] key pressed\nset [@game state v] to [respawn]\nbroadcast (change game state v)\n\nwhen I receive [tick v]\nif <(@game state) = [edit]> then\n    if <key (up arrow v) pressed?> then\n        change [@camera y v] by (@camera_speed)\n    end\n    if <key (down arrow v) pressed?> then\n        change [@camera y v] by ((0) - (@camera_speed))\n    end\n    if <key (left arrow v) pressed?> then\n        change [@camera x v] by ((0) - (@camera_speed))\n    end\n    if <key (right arrow v) pressed?> then\n        change [@camera x v] by (@camera_speed)\n    end\nend\n\nwhen I receive [change game state v]\nif <(@game state) = [edit]> then\n    show variable [@camera_speed v]\nelse\n    hide variable [@camera_speed v]\n    if <<(@game state) = [win]> and <(@curr_level) = (@unlocked_levels)>> then\n        change [@unlocked_levels v] by (1)\n        change [@score v] by ([floor v] of ((10000) / (timer)) )\n    end\nend\n\nwhen I receive [level_select v]\nif <not <(backdrop [name v]) = [cat_wallpaper]>> then\n    switch backdrop to (cat_wallpaper v)\nend\n\nwhen I receive [title v]\nif <not <(backdrop [name v]) = [cat_wallpaper]>> then\n    switch backdrop to (cat_wallpaper v)\nend\n\nwhen I receive [leaderboard v]\nif <not <(backdrop [name v]) = [cat_wallpaper]>> then\n    switch backdrop to (cat_wallpaper v)\nend\n\nwhen backdrop switches to [cat_wallpaper v]\nstop [other scripts in sprite v]\nforever\n    play sound [Fork Lifter - Rhythm Heaven Fever.mp3 v] until done\nend\n\n@player hitbox\n\ndefine get_keyboard_input\nset [@input.down v] to <<<key (down arrow v) pressed?> or <key (s v) pressed?>> or <<mouse down?> and <(mouse y) < ((y position) - (100))>>>\nset [@input.up v] to <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > ((y position) + (100))>>>\nset [@input.left v] to <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(mouse x) < ((x position) - (100))>>>\nset [@input.right v] to <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(mouse x) > ((x position) + (100))>>>\n\nwhen I receive [level_select v]\nstop [other scripts in sprite v]\nhide\n\nwhen I receive [player action v]\nif <<(@game state) = [go]> and <(~air time) < [2]>> then\n    if <<not <<(@game state) = [attack]> or <(@game state) = [talk]>>> and <(@player.animation_type) = [idle]>> then\n        set [@game state v] to [attack]\n        start sound [Rip v]\n    end\nend\n\ndefine init\nhide\nset rotation style [don't rotate v]\nset size to (60) %\nset [ghost v] effect to (100)\nset volume to (100) %\nset [~player_x v] to [0]\nset [~player_y v] to [0]\nset [~vel_x v] to [0]\nset [~vel_y v] to [0]\nset [~force.climb v] to [4]\nset [~force.jump v] to [12]\nset [~force.leftright v] to [8]\nset [~force.gravity v] to [-1.1]\nset [~friction v] to [0.5]\nset [~camera.max_dist v] to [50]\nset [~camera.springiness v] to [0.2]\nset [~move_mode v] to [walk]\nset [~slope v] to [0]\nset [~slope.max v] to [9]\nset [~air time v] to [0]\nset [~player_vel_y.min v] to [-30]\n\nwhen I receive [change game state v]\nif <(@game state) = [respawn]> then\n    if <(~touching_water) = [1]> then\n        start sound [Meow2 v]\n        start sound [Plunge v]\n        wait (2) seconds\n    end\n    respawn\n    start sound [Oops v]\n    wait (2) seconds\n    set [@game state v] to [go]\nend\n\ndefine update wrapper\nget_keyboard_input\nif <(@game state) = [go]> then\n    update_player_vec <(@Input.UP) = [true]> <(@Input.DOWN) = [true]> <(@Input.LEFT) = [true]> <(@Input.RIGHT) = [true]> (~move_mode)\n    update_camera_pos\nend\nupdate_costume <(@Input.UP) = [true]> <(@Input.DOWN) = [true]> <(@Input.LEFT) = [true]> <(@Input.RIGHT) = [true]> ((~vel_x) / ([abs v] of (~vel_x) )) ((~vel_y) / ([abs v] of (~vel_y) ))\ngo to x: ((~player_x) - (@camera x)) y: ((~player_y) - (@camera y))\nif <<(round ((~player_x) - (@camera x))) = (round (x position))> and <(round ((~player_y) - (@camera y))) = (round (y position))>> then\n    show\nelse\n    hide\nend\n\ndefine check_water_collision\nif <touching (water v)?> then\n    set [~touching_water v] to [1]\n    repeat until <not <touching (water v)?>>\n        change y by (1)\n        change [~player_y v] by (1)\n    end\n    if <(@game state) = [go]> then\n        set [@game state v] to [respawn]\n        broadcast (change game state v)\n    end\nelse\n    set [~touching_water v] to [0]\nend\n\ndefine update_player_vec <up> <down> <left> <right> (mode)\nif <(mode) = [walk]> then\n    if <<<up> and <(~air time) = [0]>> and <(@game state) = [go]>> then\n        set [~vel_y v] to (~FORCE.Jump)\n        start sound [Jump v]\n    else\n        set [~vel_y v] to ((~vel_y) + (~FORCE.Gravity))\n        if <(~vel_y) < (~player_vel_y.min)> then\n            set [~vel_y v] to (~player_vel_y.min)\n        end\n    end\n    if <<<left> or <right>> and <(@game state) = [go]>> then\n        set [~vel_x v] to ((~FORCE.LeftRight) * (<right> - <left>))\n        if <(~slope) > (~slope.max)> then\n            if <up> then\n                set [~vel_y v] to (~FORCE.Climb)\n            else\n                set [~vel_y v] to (~FORCE.Gravity)\n            end\n            set [~air time v] to [1]\n        end\n    else\n        set [~vel_x v] to ((~vel_x) * (~FRICTION))\n    end\nend\ncheck_vertical_collision (~vel_y) ((~vel_y) / ([abs v] of (~vel_y) )) (y position)\ncheck_horizontal_collision (~vel_x) (x position) (y position) ((~vel_x) / ([abs v] of (~vel_x) ))\ncheck_water_collision\nif <(~player_y) < ((([floor v] of ((@curr_level) / (=map_width_panels)) ) - (0.5)) * (=level_height_px))> then\n    set [@game state v] to [respawn]\n    broadcast (change game state v)\nend\n\nwhen flag clicked\ninit\n\nwhen I receive [start level v]\nstop [other scripts in sprite v]\nreset timer\nset [@checkpt_x v] to (item (((@curr_level) * (2)) - (1)) of [level spawns v])\nset [@checkpt_y v] to (item ((@curr_level) * (2)) of [level spawns v])\nrespawn\nset [@game state v] to [go]\nforever\n    update wrapper\n    broadcast (tick v) and wait\nend\n\ndefine update_camera_pos\nset [@camera x v] to (round ((@camera x) + ((~CAMERA.springiness) * (((~player_x) + (((~vel_x) / (~FORCE.LeftRight)) * (~CAMERA.max_dist))) - (@camera x)))))\nset [@camera y v] to (round ((@camera y) + ((~CAMERA.springiness) * (((~player_y) + (((~vel_y) / (~FORCE.Jump)) * (~CAMERA.max_dist))) - (@camera y)))))\n\ndefine check_horizontal_collision (vel_x) (abs_x) (abs_y) (dir_vel_x)\nset [~slope v] to [0]\nchange x by (vel_x)\nrepeat until <<not <<touching (level hitbox v)?> or <touching (objects v)?>>> or <(~slope) > (~slope.max)>>\n    change y by (1)\n    change [~slope v] by (1)\nend\nif <(~slope) > (~slope.max)> then\n    set y to (abs_y)\n    set [~vel_x v] to [0]\n    repeat until <not <<touching (level hitbox v)?> or <touching (objects v)?>>>\n        change x by ((0) - (dir_vel_x))\n    end\n    change x by ((2) * ((0) - (dir_vel_x)))\nelse\n    set [~vel_x v] to ((vel_x) - (((~slope) * (1.5)) * (dir_vel_x)))\nend\nset [~player_x v] to ((~player_x) + ((x position) - (abs_x)))\nset [~player_y v] to ((~player_y) + ((y position) - (abs_y)))\n\ndefine check_vertical_collision (vel_y) (dir_vel_y) (abs_y)\nchange [~air time v] by (1)\nchange y by (vel_y)\nrepeat until <not <<touching (level hitbox v)?> or <touching (objects v)?>>>\n    if <(dir_vel_y) < [0]> then\n        set [~air time v] to [0]\n    end\n    change y by ((0) - (dir_vel_y))\n    set [~vel_y v] to [0]\nend\nset [~player_y v] to ((~player_y) + ((y position) - (abs_y)))\n\ndefine update_costume <up> <down> <left> <right> (xdir) (ydir)\nif <(~touching_water) = [1]> then\n    set [@player.animation_type v] to [water]\nelse\n    if <<<(~slope) > (~slope.max)> and <<left> or <right>>> and <(~air time) > [0]>> then\n        if <up> then\n            set [@player.animation_type v] to [climb]\n        else\n            set [@player.animation_type v] to [cling]\n        end\n    else\n        if <(@game state) = [respawn]> then\n            set [@player.animation_type v] to [respawn]\n        else\n            if <(@game state) = [attack]> then\n                set [@player.animation_type v] to [attack]\n            else\n                if <(~air time) > [1]> then\n                    if <(ydir) > [0]> then\n                        set [@player.animation_type v] to [jump]\n                        if <(~air time) > [10]> then\n                            set [@player.animation_type v] to [jump2]\n                        end\n                    else\n                        set [@player.animation_type v] to [fall]\n                    end\n                else\n                    if <<left> or <right>> then\n                        set [@player.animation_type v] to [walk]\n                    else\n                        set [@player.animation_type v] to [idle]\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen [space v] key pressed\nif <not <(@game state) = [title]>> then\n    broadcast (player action v)\nend\n\nwhen I receive [title v]\nstop [other scripts in sprite v]\nhide\n\ndefine respawn\nhide\nset [@camera x v] to (@checkpt_x)\nset [@camera y v] to (@checkpt_y)\nset [~player_x v] to (@checkpt_x)\nset [~player_y v] to (@checkpt_y)\ngo to x: (0) y: (0)\nset [~vel_x v] to [0]\nset [~vel_y v] to [0]\nset [~move_mode v] to [walk]\nset [~touching_water v] to [0]\nshow\n\nwhen I receive [change_volume2 v]\nset volume to ((100) * (@sound_on?)) %\n\n@player visual\n\ndefine init\nhide\nset rotation style [left-right v]\npoint in direction (90)\nset size to (60) %\nset [~animation.frame v] to [0]\nset [@fish_collected v] to [0]\n\nwhen flag clicked\ninit\n\nwhen I receive [start level v]\nshow\ngo to [front v] layer\n\ndefine animate <left> <right>\ngo to (player hitbox v)\nif <touching (_edge_ v)?> then\n    hide\nelse\n    show\n    if <right> then\n        point in direction (90)\n    else\n        if <left> then\n            point in direction (-90)\n        end\n    end\n    switch costume to (@player.animation_type)\n    if <<(@player.animation_type) = [idle]> or <(@player.animation_type) = [cling]>> then\n        set [~animation.frame v] to (((~animation.frame) + (0.05)) mod (2))\n    else\n        if <<(@player.animation_type) = [walk]> or <(@player.animation_type) = [climb]>> then\n            set [~animation.frame v] to (((~animation.frame) + (0.5)) mod (5))\n        else\n            if <(@player.animation_type) = [water]> then\n                set [~animation.frame v] to (((~animation.frame) + (0.5)) mod (6))\n            else\n                if <(@player.animation_type) = [respawn]> then\n                    set [~animation.frame v] to (((~animation.frame) + (0.5)) mod (4))\n                    point in direction (90)\n                else\n                    if <(@player.animation_type) = [attack]> then\n                        set [~animation.frame v] to (((~animation.frame) + (0.25)) mod (5))\n                        if <(~animation.frame) > [4.5]> then\n                            set [@game state v] to [go]\n                        end\n                    else\n                        set [~animation.frame v] to [0]\n                    end\n                end\n            end\n        end\n    end\n    switch costume to ((costume [number v]) + ([floor v] of (~animation.frame) ))\n    go to [front v] layer\n    go [backward v] (3) layers\nend\n\nwhen I receive [title v]\nstop [other scripts in sprite v]\ninit\n\nwhen I receive [tick v]\nanimate <(@Input.LEFT) = [true]> <(@Input.RIGHT) = [true]>\n\nwhen I receive [level_select v]\nstop [other scripts in sprite v]\ninit\n\nwhen this sprite clicked\nbroadcast (player action v)\n\n@level visual\n\nwhen I receive [tick v]\nif <(~panel_set.row_ID) > [0]> then\n    scroll\n    update_costume\nend\n\nwhen flag clicked\ninit\n\ndefine scroll\nset [~x v] to ((=panel_width) - (((@camera x) + (((~panel_set.col_ID) mod (2)) * (=panel_width))) mod ((2) * (=panel_width))))\nset [~y v] to ((=panel_height) - (((@camera y) + (((~panel_set.row_ID) mod (2)) * (=panel_height))) mod ((2) * (=panel_height))))\ngo to x: (~x) y: (~y)\n\ndefine update_costume\nset [~costume.col_id v] to ([floor v] of (((((~x) + (@camera x)) + ((=panel_width) / (2))) / (=map_width_px)) * (=map_width_panels)) )\nset [~costume.row_id v] to ([floor v] of (((((~y) + (@camera y)) + ((=panel_height) / (2))) / (=map_height_px)) * (=map_height_panels)) )\nset [~costume.target_id v] to ((((=map_width_panels) * (~costume.row_ID)) + (~costume.col_ID)) + (1))\nif <<<(~costume.row_ID) > [-1]> and <(~costume.row_ID) < (=map_height_panels)>> and <<(~costume.col_ID) > [-1]> and <(~costume.col_ID) < (=map_width_panels)>>> then\n    show\n    if <not <(costume [number v]) = (~costume.target_ID)>> then\n        switch costume to (~costume.target_ID)\n    end\nelse\n    hide\nend\n\nwhen I receive [start level v]\nif <(~panel_set.row_ID) > [0]> then\n    show\n    go to [back v] layer\nend\n\nwhen I receive [title v]\nhide\n\ndefine init\nhide\nswitch costume to (lvl1_\(1,1\) v)\nset size to (100) %\ngo to x: (0) y: (0)\nset rotation style [don't rotate v]\nset [~panel_set.row_id v] to [0]\nset [~panel_set.col_id v] to [0]\nrepeat (2)\n    change [~panel_set.row_id v] by (1)\n    set [~panel_set.col_id v] to [0]\n    repeat (2)\n        change [~panel_set.col_id v] by (1)\n        create clone of (_myself_ v)\n    end\nend\nset [~panel_set.row_id v] to [0]\nset [~panel_set.col_id v] to [0]\n\nwhen I receive [level_select v]\nhide\n\n@level hitbox\n\nwhen I receive [tick v]\nif <(~panel_set.row_ID) > [0]> then\n    scroll\n    update_costume\nend\n\nwhen flag clicked\ninit\n\ndefine scroll\nset [~x v] to ((=panel_width) - (((@camera x) + (((~panel_set.col_ID) mod (2)) * (=panel_width))) mod ((2) * (=panel_width))))\nset [~y v] to ((=panel_height) - (((@camera y) + (((~panel_set.row_ID) mod (2)) * (=panel_height))) mod ((2) * (=panel_height))))\ngo to x: (~x) y: (~y)\n\ndefine update_costume\nset [~costume.col_id v] to ([floor v] of (((((~x) + (@camera x)) + ((=panel_width) / (2))) / (=map_width_px)) * (=map_width_panels)) )\nset [~costume.row_id v] to ([floor v] of (((((~y) + (@camera y)) + ((=panel_height) / (2))) / (=map_height_px)) * (=map_height_panels)) )\nset [~costume.target_id v] to ((((=map_width_panels) * (~costume.row_ID)) + (~costume.col_ID)) + (1))\nif <<<(~costume.row_ID) > [-1]> and <(~costume.row_ID) < (=map_height_panels)>> and <<(~costume.col_ID) > [-1]> and <(~costume.col_ID) < (=map_width_panels)>>> then\n    show\n    if <not <(costume [number v]) = (~costume.target_ID)>> then\n        switch costume to (~costume.target_ID)\n    end\nelse\n    hide\nend\n\nwhen I receive [start level v]\nif <(~panel_set.row_ID) > [0]> then\n    show\n    go to [back v] layer\nend\n\nwhen I receive [title v]\nhide\n\ndefine init\nhide\nset size to (100) %\ngo to x: (0) y: (0)\nset rotation style [don't rotate v]\nset [~panel_set.row_id v] to [0]\nset [~panel_set.col_id v] to [0]\nswitch costume to (lvl1_\(0,0\) v)\nset [ghost v] effect to (100)\nrepeat (2)\n    change [~panel_set.row_id v] by (1)\n    set [~panel_set.col_id v] to [0]\n    repeat (2)\n        change [~panel_set.col_id v] by (1)\n        create clone of (_myself_ v)\n    end\nend\nset [~panel_set.row_id v] to [0]\nset [~panel_set.col_id v] to [0]\n\nwhen I receive [level_select v]\nhide\n\n@dialogue\n\nwhen flag clicked\ninit\n\ndefine dialogue\nshow\ngo to [front v] layer\nif <not <(~text.opened_index) = (~text.index)>> then\n    set [@game state v] to [talk]\n    set [~text.opened_index v] to (~text.index)\n    switch costume to (item (~text.index) of [~locations v])\n    start sound [Meow v]\n    animate_in (~text.BOUNCE)\nelse\n    start sound [Suction Cup v]\n    if <not <(letter (1) of (costume [name v])) = [_]>> then\n        next costume\n        animate_in (~text.BOUNCE)\n    else\n        set [~text.opened_index v] to [0]\n        animate_out (~text.BOUNCE)\n        set [@game state v] to [go]\n    end\nend\n\ndefine animate_in (bounce)\nset [~text.bounce_vel v] to [10]\nset size to (~text.MIN_SIZE) %\nrepeat until <([abs v] of (~text.bounce_vel) ) < [0.01]>\n    set [~text.bounce_vel v] to (((~text.bounce_vel) * (bounce)) + (((~text.MAX_SIZE) - (size)) * ((1) - (bounce))))\n    change size by (~text.bounce_vel)\nend\n\ndefine check_player_dialogue (stride)\nset [~text.index v] to [1]\nset [~text.dist v] to (~text.MAX_DIST)\nrepeat until <<(~text.index) > (length of [~locations v])> or <(~text.dist) < (~text.MAX_DIST)>>\n    set [~text.x v] to (item ((~text.index) + (1)) of [~locations v])\n    set [~text.y v] to (item ((~text.index) + (2)) of [~locations v])\n    get_dist (~text.x) (~text.y) (([x position v] of [player hitbox v]) + (@camera x)) (([y position v] of [player hitbox v]) + (@camera y))\n    change [~text.index v] by (stride)\nend\nif <(~text.dist) < (~text.MAX_DIST)> then\n    change [~text.index v] by ((0) - (stride))\nend\n\nwhen I receive [player action v]\nif <(~text.dist) < (~text.MAX_DIST)> then\n    dialogue\nend\n\ndefine get_dist (x1) (y1) (x2) (y2)\nset [~text.dist v] to ([sqrt v] of ((((x1) - (x2)) * ((x1) - (x2))) + (((y1) - (y2)) * ((y1) - (y2)))) )\n\ndefine animate_out (bounce)\nrepeat (2)\n    set size to ((~text.BOUNCE) * (size)) %\nend\nhide\n\nwhen I receive [tick v]\ncheck_player_dialogue [3]\nif <(~text.dist) < (~text.MAX_DIST)> then\n    go to x: ((~text.x) - (@camera x)) y: (((~text.y) - (@camera y)) + (60))\n    set [@show icon v] to [1]\nelse\n    set [@show icon v] to [0]\n    if <(~text.opened_index) > [0]> then\n        animate_out (~text.BOUNCE)\n    end\n    set [~text.opened_index v] to [0]\n    if <(@game state) = [talk]> then\n        set [@game state v] to [go]\n    end\nend\n\ndefine add_location | title: (title) x: (x) y: (y)\nadd (title) to [~locations v]\nadd (x) to [~locations v]\nadd (y) to [~locations v]\n\ndefine init\nhide\nset volume to (100) %\nshow list [~locations v]\nset [~text.min_size v] to [40]\nset [~text.bounce v] to [0.5]\nset [~text.max_size v] to [100]\nset [~text.max_dist v] to [30]\nset [~text.opened_index v] to [0]\nset size to (~text.MIN_SIZE) %\ndelete all of [~locations v]\nadd_location | title: [tutorial_walk] x: [0] y: [-108]\nadd_location | title: [tutorial_climb] x: [206] y: [-43]\nadd_location | title: [water] x: [-107] y: [739]\nadd_location | title: [frog] x: [267] y: [741]\n\nwhen I receive [level_select v]\nhide\n\nwhen I receive [change_volume2 v]\nset volume to ((100) * (@sound_on?)) %\n\nwhen I receive [title v]\nhide\n\n@water\n\nwhen I receive [tick v]\nif <(~panel_set.row_ID) > [0]> then\n    scroll\n    update_costume\nend\n\nwhen flag clicked\ninit\n\ndefine scroll\nset [~x v] to (round ((=panel_width) - (((@camera x) + (((~panel_set.col_ID) mod (2)) * (=panel_width))) mod ((2) * (=panel_width)))))\nset [~y v] to (round ((=panel_height) - (((@camera y) + (((~panel_set.row_ID) mod (2)) * (=panel_height))) mod ((2) * (=panel_height)))))\ngo to x: (~x) y: (~y)\n\ndefine update_costume\nset [~costume.col_id v] to ([floor v] of (((((~x) + (@camera x)) + ((=panel_width) / (2))) / (=map_width_px)) * (=map_width_panels)) )\nset [~costume.row_id v] to ([floor v] of (((((~y) + (@camera y)) + ((=panel_height) / (2))) / (=map_height_px)) * (=map_height_panels)) )\nset [~costume.target_id v] to ((((=map_width_panels) * (~costume.row_ID)) + (~costume.col_ID)) + (1))\nif <<(round (~x)) = (round (x position))> and <(round (~y)) = (round (y position))>> then\n    if <<<(~costume.row_ID) > [-1]> and <(~costume.row_ID) < (=map_height_panels)>> and <<(~costume.col_ID) > [-1]> and <(~costume.col_ID) < (=map_width_panels)>>> then\n        show\n        if <not <(costume [number v]) = (~costume.target_ID)>> then\n            switch costume to (~costume.target_ID)\n        end\n    else\n        hide\n    end\nelse\n    hide\nend\n\nwhen I receive [start level v]\nif <(~panel_set.row_ID) > [0]> then\n    show\n    go to [back v] layer\nend\n\nwhen I receive [title v]\nstop [other scripts in sprite v]\nhide\n\ndefine init\nhide\nset size to (100) %\ngo to x: (0) y: (0)\nset rotation style [don't rotate v]\nset [~panel_set.row_id v] to [0]\nset [~panel_set.col_id v] to [0]\nset [ghost v] effect to (100)\nswitch costume to (lvl1_\(0,0\) v)\nrepeat (2)\n    change [~panel_set.row_id v] by (1)\n    repeat (2)\n        change [~panel_set.col_id v] by (1)\n        create clone of (_myself_ v)\n        next costume\n    end\nend\nset [~panel_set.row_id v] to [0]\nset [~panel_set.col_id v] to [0]\n\nwhen I receive [level_select v]\nstop [other scripts in sprite v]\nhide\n\n@icons\n\nwhen flag clicked\nset [~icon.animation_speed v] to [0.05]\nhide\nset size to (100) %\n\nwhen I receive [tick v]\nanimate\n\ndefine animate\nif <(@show icon) = [1]> then\n    if <(~icon.animation_frame) = [-1]> then\n        set [~icon.animation_frame v] to [0]\n        switch costume to (space v)\n        show\n    end\n    go to x: ([x position v] of [player hitbox v]) y: (([y position v] of [player hitbox v]) + (50))\n    set [~icon.animation_frame v] to (((~icon.animation_frame) + (~icon.animation_speed)) mod (2))\n    set [~icon.target_costume v] to (([floor v] of (~icon.animation_frame) ) + (1))\n    if <not <(costume [number v]) = (~icon.target_costume)>> then\n        switch costume to (~icon.target_costume)\n    end\nelse\n    if <(~icon.animation_frame) > [-1]> then\n        set [~icon.animation_frame v] to [-1]\n        hide\n    end\nend\n\nwhen I receive [start level v]\ngo to [front v] layer\n\nwhen I receive [title v]\nstop [other scripts in sprite v]\nhide\n\nwhen I receive [level_select v]\nstop [other scripts in sprite v]\nhide\n\n@fish\n\nwhen flag clicked\ninit\nset [~id v] to [0]\nset [~level v] to [0]\n\ndefine animate_idle (speed)\nchange [~y v] by ([sin v] of (~animation_frame) )\nset [~animation_frame v] to (((~animation_frame) + (speed)) mod (360))\n\nwhen I receive [start level v]\nif <(~ID) > [0]> then\n    reset\n    show\n    go to [front v] layer\nelse\n    switch costume to (fish0 v)\n    show\n    go to [front v] layer\nend\n\ndefine animate_collect\nif <(size) > [40]> then\n    change [~y v] by (1)\n    change size by (1)\n    change [ghost v] effect by (5)\nelse\n    hide\nend\n\ndefine scroll\ngo to x: ((~x) - (@camera x)) y: ((~y) - (@camera y))\nif <<(round ((~x) - (@camera x))) = (round (x position))> and <(round ((~y) - (@camera y))) = (round (y position))>> then\n    show\n    if <(~collected?) = [1]> then\n        animate_collect\n    else\n        animate_idle (~BOB_SPEED)\n        check_cat_collision [30]\n    end\nelse\n    hide\nend\n\nwhen I receive [tick v]\nif <(~ID) > [0]> then\n    if <(@curr_level) = (~level)> then\n        scroll\n    else\n        hide\n    end\nelse\n    switch costume to (join [fish] (@fish_collected))\n    go to [front v] layer\n    if <(@fish_collected) = (item (@curr_level) of [fish_per_level v])> then\n        if <not <(@game state) = [win]>> then\n            set [@game state v] to [win]\n            broadcast (change game state v)\n        end\n    end\nend\n\nwhen I start as a clone\nreset\n\ndefine init\nhide\nswitch costume to (fish v)\nset size to (95) %\nset [ghost v] effect to (0)\nset volume to (100) %\ngo to x: (0) y: (0)\nshow list [~locations v]\nset [~bob_speed v] to [5]\nset [~animation_frame v] to [0]\nset [~collected? v] to [0]\nset [~id v] to [0]\nset [~level v] to [0]\ndelete all of [~locations v]\ndelete all of [fish_per_level v]\nrepeat (=max_levels)\n    add [0] to [fish_per_level v]\nend\nadd location | x: [340] y: [75] level: [1]\nadd location | x: [720] y: [-57] level: [1]\nadd location | x: [820] y: [-57] level: [1]\nadd location | x: [690] y: [123] level: [1]\nadd location | x: [42] y: [378] level: [1]\nadd location | x: [-93] y: [276] level: [1]\nadd location | x: [639] y: [330] level: [1]\nadd location | x: [811] y: [228] level: [1]\nadd location | x: [170] y: [798] level: [2]\nadd location | x: [570] y: [798] level: [2]\nadd location | x: [940] y: [748] level: [2]\nadd location | x: [1120] y: [838] level: [2]\nadd location | x: [870] y: [919] level: [2]\nadd location | x: [740] y: [1009] level: [2]\nadd location | x: [500] y: [1149] level: [2]\nadd location | x: [250] y: [1079] level: [2]\nadd location | x: [167] y: [1457] level: [3]\nadd location | x: [167] y: [1542] level: [3]\nadd location | x: [113] y: [1715] level: [3]\nadd location | x: [465] y: [1715] level: [3]\nadd location | x: [425] y: [1507] level: [3]\nadd location | x: [505] y: [1507] level: [3]\nadd location | x: [941] y: [1640] level: [3]\nadd location | x: [941] y: [1463] level: [3]\n\ndefine check_cat_collision (dist_thresh)\nif <touching (player hitbox v)?> then\n    set [~collected? v] to [1]\n    change [@fish_collected v] by (1)\n    change [~y v] by (30)\n    start sound [Coin v]\n    start sound [Chomp v]\nend\n\ndefine add location | x: (x) y: (y) level: (level)\nset [~id v] to ((length of [~locations v]) + (1))\nset [~level v] to (level)\nadd (x) to [~locations v]\nadd (y) to [~locations v]\nreplace item (level) of [fish_per_level v] with ((item (level) of [fish_per_level v]) + (1))\ncreate clone of (_myself_ v)\nset [~id v] to [0]\nset [~level v] to [0]\n\nwhen I receive [title v]\nhide\n\nwhen I receive [change_volume2 v]\nset volume to ((100) * (@sound_on?)) %\n\nwhen I receive [level_select v]\nhide\n\ndefine reset\nset [~x v] to (item (~ID) of [~locations v])\nset [~y v] to (item ((~ID) + (1)) of [~locations v])\nset [~animation_frame v] to [0]\nset [~collected? v] to [0]\nswitch costume to (fish v)\nset size to (60) %\nset [ghost v] effect to (0)\n\n@checkpoints\n\nwhen flag clicked\ninit\n\ndefine check_player_dist (stride)\nset [~checkpt.index v] to [1]\nset [~checkpt.dist v] to (~checkpt.MAX_DIST)\nrepeat until <<(~checkpt.index) > (length of [~locations v])> or <(~checkpt.dist) < (~checkpt.MAX_DIST)>>\n    set [~checkpt.x v] to (item (~checkpt.index) of [~locations v])\n    set [~checkpt.y v] to (item ((~checkpt.index) + (1)) of [~locations v])\n    get_dist (~checkpt.x) (~checkpt.y) (([x position v] of [player hitbox v]) + (@camera x)) (([y position v] of [player hitbox v]) + (@camera y))\n    change [~checkpt.index v] by (stride)\nend\nif <(~checkpt.dist) < (~checkpt.MAX_DIST)> then\n    change [~checkpt.index v] by ((0) - (stride))\n    set [@checkpt_x v] to (~checkpt.x)\n    set [@checkpt_y v] to (~checkpt.y)\nend\n\ndefine get_dist (x1) (y1) (x2) (y2)\nset [~checkpt.dist v] to ([sqrt v] of ((((x1) - (x2)) * ((x1) - (x2))) + (((y1) - (y2)) * ((y1) - (y2)))) )\n\nwhen I receive [tick v]\ncheck_player_dist [2]\nupdate_checkpt\n\ndefine add location | x: (x) y: (y)\nadd (x) to [~locations v]\nadd (y) to [~locations v]\n\ndefine init\nhide\nset size to (100) %\ngo to x: (0) y: (0)\nshow list [~locations v]\nset [@checkpt_x v] to [0]\nset [@checkpt_y v] to [0]\nset [~checkpt.max_dist v] to [50]\nset [~checkpt.spawn_index v] to [0]\nset [~timer v] to [0]\nset [ghost v] effect to (100)\nshow\ngo to [front v] layer\ndelete all of [~locations v]\nadd location | x: [273] y: [738]\nadd location | x: [713] y: [738]\nadd location | x: [312] y: [1576]\n\nwhen I receive [title v]\nhide\n\nwhen I receive [start level v]\nset [ghost v] effect to (100)\nshow\ngo to [front v] layer\n\ndefine update_checkpt\nif <(~checkpt.dist) < (~checkpt.MAX_DIST)> then\n    if <not <(~checkpt.spawn_index) = (~checkpt.index)>> then\n        set [~checkpt.spawn_index v] to (~checkpt.index)\n        set [~timer v] to [80]\n        set [ghost v] effect to (100)\n    end\nend\nif <(~timer) > [0]> then\n    change [~timer v] by (-1)\n    if <(~timer) > [74]> then\n        change [ghost v] effect by (-20)\n    end\n    if <[49] > (~timer)> then\n        change [ghost v] effect by (2)\n    end\nend\n\nwhen I receive [level_select v]\nhide\n\nadd location | x: [720] y: [1442]\n\n@buttons\n\nwhen flag clicked\nset [~action v] to [0]\nset [~timer v] to [0]\nhide\ngo to x: (0) y: (0)\nset rotation style [don't rotate v]\nset size to (80) %\nset volume to (100) %\n\ndefine add_button | action: (act) skin (skin) x: (x) y: (y)\nset [~action v] to (act)\nswitch costume to (skin)\nset [~costume v] to (costume [number v])\nset [~x v] to (x)\nset [~y v] to (y)\ngo to x: (x) y: (y)\ncreate clone of (_myself_ v)\nset [~action v] to [0]\n\nwhen this sprite clicked\nif <(~action) = [locked level]> then\n    start sound [Crunch v]\n    set size to (105) %\nelse\n    if <(~action) = [start level]> then\n        start sound [Connect v]\n        set size to (105) %\n    else\n        start sound [Suction Cup v]\n        set size to (105) %\n    end\nend\nbroadcast (~action)\n\nwhen I start as a clone\nshow\ngo to [front v] layer\nset volume to ((100) * (@sound_on?)) %\nrepeat until <(@game state) = [go]>\n    animate (0.5) (100) (120)\nend\n\ndefine animate (bounce) (min_size) (max_size)\nif <touching (mouse-pointer v)?> then\n    if <(size) < ((min_size) + (1))> then\n        start sound [Wood Tap v]\n    end\n    change size by (((max_size) - (size)) * (bounce))\nelse\n    change size by (((min_size) - (size)) * (bounce))\nend\n\ndefine animate_out (bounce)\nif <not <(~action) = [0]>> then\n    stop [other scripts in sprite v]\n    repeat (5)\n        set size to ((bounce) * (size)) %\n    end\n    hide\n    delete this clone\nend\n\nwhen I receive [start level v]\nif <(~action) = [0]> then\n    add_button | action: [help] skin [help] x: [200] y: [140]\nelse\n    animate_out [0.5]\nend\n\nwhen I receive [level_select v]\nif <(~action) = [0]> then\n    set [@curr_level v] to [1]\n    add_button | action: [prev_lvl_thumb] skin [prev] x: [-200] y: [0]\n    add_button | action: [next_lvl_thumb] skin [next] x: [200] y: [0]\n    add_button | action: [start level] skin [level1] x: [0] y: [0]\n    add_button | action: [title] skin [back] x: [200] y: [140]\nelse\n    animate_out [0.5]\nend\n\nwhen I receive [change_volume v]\nif <(~action) = [change_volume]> then\n    set [@sound_on? v] to ((1) - (@sound_on?))\n    switch costume to (join [sound] (@sound_on?))\n    broadcast (change_volume2 v)\nend\n\nwhen I receive [prev_lvl_thumb v]\nif <<(~action) = [start level]> or <(~action) = [locked level]>> then\n    set [@curr_level v] to (((=max_levels) - (((((=max_levels) - (@curr_level)) + (1)) mod (=max_levels)) + (1))) + (1))\n    if <(@curr_level) > (@unlocked_levels)> then\n        set [~action v] to [locked level]\n        switch costume to (join [locked] (@curr_level))\n    else\n        set [~action v] to [start level]\n        switch costume to (join [level] (@curr_level))\n    end\n    set size to (80) %\nend\n\nwhen I receive [tick v]\nif <(~action) = [help]> then\n    go to [front v] layer\n    animate (0.5) (100) (120)\nend\n\nwhen I receive [title v]\nif <(~action) = [0]> then\n    add_button | action: [level_select] skin [start] x: [0] y: [-100]\n    add_button | action: [leaderboard] skin [leader] x: [75] y: [-100]\n    add_button | action: [change_volume] skin (join [sound] (@sound_on?)) x: [-75] y: [-100]\nelse\n    animate_out [0.5]\nend\n\nwhen I receive [help v]\nif <(~action) = [help]> then\n    if <(costume [name v]) = [help]> then\n        switch costume to (help2 v)\n        go to [front v] layer\n        go to x: (0) y: (0)\n    else\n        switch costume to (help v)\n        go to x: (200) y: (140)\n    end\nelse\n    animate_out [0.5]\nend\n\nwhen I receive [next_lvl_thumb v]\nif <<(~action) = [start level]> or <(~action) = [locked level]>> then\n    set [@curr_level v] to (((@curr_level) mod (=max_levels)) + (1))\n    if <(@curr_level) > (@unlocked_levels)> then\n        set [~action v] to [locked level]\n        switch costume to (join [locked] (@curr_level))\n    else\n        set [~action v] to [start level]\n        switch costume to (join [level] (@curr_level))\n    end\n    set size to (80) %\nend\n\nwhen I receive [leaderboard v]\nif <(~action) = [0]> then\n    add_button | action: [title] skin [back] x: [200] y: [140]\nelse\n    animate_out [0.5]\nend\n\nwhen I receive [change_volume2 v]\nset volume to ((100) * (@sound_on?)) %\n\nwhen I receive [change game state v]\nif <(@game state) = [win]> then\n    if <(~action) = [0]> then\n        play sound [Tada v] until done\n        add_button | action: [level_select] skin [win] x: [0] y: [0]\n    else\n        animate_out [0.5]\n    end\nend\n\n@overlay\n\nwhen flag clicked\ngo to x: (0) y: (0)\npoint in direction (90)\nset rotation style [all around v]\nhide\n\ndefine title | wiggle: (v) turn: (dr) d_size (ds) d_popup (ds') x: (x) y: (y) size: (s)\ngo to x: (x) y: (y)\npoint in direction (90)\nswitch costume to (title v)\nshow\ngo to [front v] layer\nset size to (100) %\nset [~angle v] to [0]\nrepeat (10)\n    set [~angle v] to (((~angle) + (v)) mod (360))\n    turn right (([sin v] of ((~angle) + (100)) ) * (dr)) degrees\n    set size to ((size) + (((s) - (size)) * (ds'))) %\nend\nforever\n    set [~angle v] to (((~angle) + (v)) mod (360))\n    turn right (([sin v] of ((~angle) + (100)) ) * (dr)) degrees\n    change size by (([sin v] of (~angle) ) * (ds))\nend\n\nwhen I receive [start level v]\nstop [other scripts in sprite v]\ngo to x: (0) y: (0)\npoint in direction (90)\nswitch costume to (border v)\nset size to (100) %\nshow\ngo to [front v] layer\n\nwhen I receive [level_select v]\nstop [other scripts in sprite v]\nanimate_out\n\nwhen I receive [title v]\nstop [other scripts in sprite v]\ntitle | wiggle: (10) turn: (0.5) d_size (0.5) d_popup (1) x: (0) y: (50) size: (100)\n\nwhen I receive [leaderboard v]\nstop [other scripts in sprite v]\nanimate_out\n\ndefine animate_out\nrepeat (2)\n    set size to ((0.5) * (size)) %\nend\nhide\n\nwhen I receive [change game state v]\nif <<(@game state) = [edit]> and <(costume [name v]) = [border]>> then\n    switch costume to (edit v)\n    go to [front v] layer\nelse\n    if <<(@game state) = [go]> and <(costume [name v]) = [edit]>> then\n        switch costume to (border v)\n    end\nend\n\nwhen I receive [tick v]\ngo to [front v] layer\n\nswitch costume to (thumbnail2 v)\nset size to (100) %\ngo to x: (0) y: (0)\npoint in direction (90)\nset rotation style [all around v]\nshow\n\n@leaderboard\n\nwhen flag clicked\nhide\nset [~leaderboard_max_rank v] to [5]\nset [~bounce_vel v] to [0]\nset size to (100) %\ngo to x: (0) y: (0)\n\ndefine encode_str (string)\nset [~i v] to [0]\nset [~temp v] to []\nrepeat (length of (string))\n    change [~i v] by (1)\n    switch costume to (? v)\n    switch costume to (letter (~i) of (string))\n    set [~temp v] to (join (~temp) ((costume [number v]) + (10)))\nend\n\ndefine decode_str (string)\nset [~i v] to [1]\nset [~temp v] to []\nrepeat until <(~i) > (length of (string))>\n    switch costume to (space v)\n    set [~char v] to ((join (letter (~i) of (string)) (letter ((~i) + (1)) of (string))) - (10))\n    if <(~char) > [0]> then\n        switch costume to (~char)\n    end\n    set [~temp v] to (join (~temp) (costume [name v]))\n    change [~i v] by (2)\nend\n\ndefine get_cloud_leaderboard\ndelete all of [~leaderboard v]\nrepeat ((2) * (~leaderboard_max_rank))\n    add [] to [~leaderboard v]\nend\ndecode_leader_entry (☁ leader1) [1]\ndecode_leader_entry (☁ leader2) [2]\ndecode_leader_entry (☁ leader3) [3]\ndecode_leader_entry (☁ leader4) [4]\ndecode_leader_entry (☁ leader5) [5]\n\ndefine update_leaderboard (name) (score)\nget_cloud_leaderboard\nif <[~leaderboard v] contains (name)?> then\n    set [~i v] to (item # of (name) in [~leaderboard v])\n    if <(score) > (item ((~i) + (1)) of [~leaderboard v])> then\n        repeat (2)\n            delete (~i) of [~leaderboard v]\n        end\n    else\n        stop [this script v]\n    end\nend\nset [~i v] to [1]\nrepeat until <(~i) > ((~leaderboard_max_rank) * (2))>\n    if <(score) > (item ((~i) + (1)) of [~leaderboard v])> then\n        insert (name) at (~i) of [~leaderboard v] \n        insert (score) at ((~i) + (1)) of [~leaderboard v] \n        set [~i v] to ((~leaderboard_max_rank) * (2))\n    end\n    change [~i v] by (2)\nend\nrepeat until <not <(length of [~leaderboard v]) > ((~leaderboard_max_rank) * (2))>>\n    delete (length of [~leaderboard v]) of [~leaderboard v]\nend\nencode_name&score (item (1) of [~leaderboard v]) (item (2) of [~leaderboard v])\nset [☁ leader1 v] to (~temp)\nwait (0.1) seconds\nencode_name&score (item (3) of [~leaderboard v]) (item (4) of [~leaderboard v])\nset [☁ leader2 v] to (~temp)\nwait (0.1) seconds\nencode_name&score (item (5) of [~leaderboard v]) (item (6) of [~leaderboard v])\nset [☁ leader3 v] to (~temp)\nwait (0.1) seconds\nencode_name&score (item (7) of [~leaderboard v]) (item (8) of [~leaderboard v])\nset [☁ leader4 v] to (~temp)\nwait (0.1) seconds\nencode_name&score (item (9) of [~leaderboard v]) (item (10) of [~leaderboard v])\nset [☁ leader5 v] to (~temp)\n\ndefine encode_name&score (name) (score)\nset [~temp v] to ((length of (name)) + (10))\nset [~temp v] to (join (~temp) (name))\nset [~temp v] to (join (~temp) (score))\nencode_str (~temp)\n\ndefine decode_leader_entry (enc) (rank)\nset [~temp v] to (enc)\nif <(enc) = [0]> then\n    encode_name&score [-] [0]\nend\ndecode_str (~temp)\nset [~i v] to ((join (letter (1) of (~temp)) (letter (2) of (~temp))) - (10))\nset [~char v] to [2]\nreplace item (((rank) * (2)) - (1)) of [~leaderboard v] with []\nrepeat (~i)\n    change [~char v] by (1)\n    replace item (((rank) * (2)) - (1)) of [~leaderboard v] with (join (item (((rank) * (2)) - (1)) of [~leaderboard v]) (letter (~char) of (~temp)))\nend\nreplace item ((rank) * (2)) of [~leaderboard v] with []\nrepeat ((length of (~temp)) - ((2) + (~i)))\n    change [~char v] by (1)\n    replace item ((rank) * (2)) of [~leaderboard v] with (join (item ((rank) * (2)) of [~leaderboard v]) (letter (~char) of (~temp)))\nend\n\nupdate_leaderboard [-Zoinks-] [1475]\n\nwhen I receive [leaderboard v]\nupdate_leaderboard (username) (@score)\nswitch costume to (background v)\nanimate_in [0.5] [40] [110]\nstamp\nhide\nset [~i v] to [0]\nrepeat (~leaderboard_max_rank)\n    change [~i v] by (1)\n    display_leader_entry (~i)\nend\nprint [Your current score:] [-135] [-125] [80] [200] [25]\nprint (@score) [55] [-125] [80] [200] [200]\n\nwhen I receive [title v]\nstop [other scripts in sprite v]\nerase all\nanimate_out\n\ndefine animate_in (bounce) (min_size) (max_size)\nset [~bounce_vel v] to [10]\nset size to (bounce) %\nclear graphic effects\nswitch costume to (background v)\ngo to x: (0) y: (0)\nshow\ngo to [front v] layer\nrepeat until <([abs v] of (~bounce_vel) ) < [0.01]>\n    set [~bounce_vel v] to (((~bounce_vel) * (bounce)) + (((max_size) - (size)) * ((1) - (bounce))))\n    change size by (~bounce_vel)\nend\n\ndefine animate_out\nclear graphic effects\nswitch costume to (background v)\ngo to x: (0) y: (0)\nshow\nset size to (100) %\nrepeat (2)\n    set size to ((0.5) * (size)) %\nend\nhide\n\ndefine display_leader_entry (rank)\nprint (join (join (rank) [. ]) (item (((rank) * (2)) - (1)) of [~leaderboard v])) [-135] ((-25) * ((rank) - (1))) [80] [200] [25]\nprint (item ((rank) * (2)) of [~leaderboard v]) [55] ((-25) * ((rank) - (1))) [80] [200] [200]\n\ndefine print (text) (lx) (ly) (size) (color) (rx)\nset size to (size) %\nset [brightness v] effect to (color)\ngo to x: (lx) y: (ly)\nset [~char v] to [0]\nrepeat (length of (text))\n    change [~char v] by (1)\n    if <(x position) < (rx)> then\n        switch costume to (space v)\n        switch costume to (letter (~char) of (text))\n        stamp\n        if <(costume [name v]) = [space]> then\n            change x by (6)\n        else\n            repeat until <not <touching color (#ffffff)?>>\n                change x by (1)\n            end\n            change x by (1)\n        end\n    else\n        switch costume to (. v)\n        repeat (3)\n            stamp\n            repeat until <not <touching color (#ffffff)?>>\n                change x by (1)\n            end\n            change x by (1)\n        end\n        stop [this script v]\n    end\nend\n\nwhen I receive [level_select v]\nupdate_leaderboard (username) (@score)\n\ndefine reset_leaderboard\nset [☁ leader1 v] to [0]\nset [☁ leader2 v] to [0]\nset [☁ leader3 v] to [0]\nset [☁ leader4 v] to [0]\nset [☁ leader5 v] to [0]\nupdate_leaderboard [earth7] [1968]\nupdate_leaderboard [Coding_Guy8648] [1836]\nupdate_leaderboard [scarleg37] [1715]\nupdate_leaderboard [-Party-] [1683]\nupdate_leaderboard [AnimationsTV-com] [1663]\n\n@parallax\n\nwhen flag clicked\ninit\n\nwhen I receive [tick v]\nif <(~col_ID) > [0]> then\n    set x to (((=panel_width) * ((~col_ID) - (1))) - ((((=level_width_px) - (=panel_width)) / ((=map_width_px) + (=panel_width))) * ((@camera x) - (item (((@curr_level) * (2)) - (1)) of [level spawns v]))))\n    set y to ((0) - (((=level_height_px) / (=map_height_px)) * ((@camera y) - (item ((@curr_level) * (2)) of [level spawns v]))))\nend\n\nwhen I receive [start level v]\nif <(~col_ID) > [0]> then\n    switch costume to (join [level] (@curr_level))\n    show\n    go to [back v] layer\nelse\n    stop [other scripts in sprite v]\n    hide\nend\n\ndefine init\nhide\nswitch costume to (level1 v)\nset size to (100) %\ngo to x: (0) y: (0)\nset rotation style [don't rotate v]\nset [~col_id v] to [0]\nrepeat (2)\n    change [~col_id v] by (1)\n    create clone of (_myself_ v)\nend\nset [~col_id v] to [0]\n\nwhen I receive [title v]\ntitle_visuals\n\nwhen I receive [level_select v]\ntitle_visuals\n\ndefine title_visuals\nif <(~col_ID) > [0]> then\n    hide\nelse\n    switch costume to (cat_wallpaper v)\n    show\n    go to [back v] layer\n    forever\n        turn right (5) degrees\n        go to x: (([cos v] of (direction) ) * (5)) y: (([sin v] of (direction) ) * (5))\n    end\nend\n\nwhen I receive [leaderboard v]\nstop [other scripts in sprite v]\nhide\n\n@objects\n\nwhen flag clicked\ninit\n\nwhen I receive [start level v]\nif <(~ID) > [0]> then\n    reset\n    show\n    go to [front v] layer\nend\n\ndefine scroll\nif <<(round ((~x) - (@camera x))) = (round (x position))> and <(round ((~y) - (@camera y))) = (round (y position))>> then\n    update_pos (x position) (y position) (costume [name v])\nend\ngo to x: ((~x) - (@camera x)) y: ((~y) - (@camera y))\nif <<(round ((~x) - (@camera x))) = (round (x position))> and <(round ((~y) - (@camera y))) = (round (y position))>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [tick v]\nif <(~ID) > [0]> then\n    scroll\nend\n\nwhen I start as a clone\nreset\n\ndefine init\nset rotation style [all around v]\npoint in direction (90)\nhide\nset size to (100) %\nshow list [~locations v]\nset [~hanging? v] to [0]\nset [~pushable? v] to [0]\nset [~id v] to [0]\nset [~force.gravity v] to [-1.1]\nset [~force.friction v] to [0.5]\nset [~vel_x v] to [0]\nset [~vel_y v] to [0]\nset [~x v] to [0]\nset [~y v] to [0]\ndelete all of [~locations v]\nadd location | x: [477] y: [859] hanging? [1] pushable? [0] costume: [log]\nadd location | x: [950] y: [859] hanging? [1] pushable? [0] costume: [log]\nadd location | x: [426] y: [1663] hanging? [1] pushable? [0] costume: [flowerpot]\nadd location | x: [505] y: [1663] hanging? [1] pushable? [0] costume: [flowerpot]\n\ndefine add location | x: (x) y: (y) hanging? (h) pushable? (p) costume: (c)\nset [~id v] to ((length of [~locations v]) + (1))\nadd (x) to [~locations v]\nadd (y) to [~locations v]\nadd (h) to [~locations v]\nadd (p) to [~locations v]\nswitch costume to (c)\ncreate clone of (_myself_ v)\nset [~id v] to [0]\n\nwhen I receive [title v]\nif <(~ID) > [0]> then\n    stop [other scripts in sprite v]\n    hide\nend\n\ndefine update_pos (abs_x) (abs_y) (costume)\nif <(~hanging?) = [0]> then\n    switch costume to (join [hitbox_] (costume))\n    check_vertical_collision (y position)\n    if <(~pushable?) = [1]> then\n        check_horizontal_collision (x position)\n    end\n    switch costume to (costume)\nend\n\nwhen I receive [player action v]\nif <<(~ID) > [0]> and <(distance to [player hitbox v]) < [70]>> then\n    wait until <(@game state) = [attack]>\n    set [~hanging? v] to [0]\nend\n\ndefine check_vertical_collision (abs_y)\nchange [~vel_y v] by (~FORCE.gravity)\nchange y by (~vel_y)\nrepeat until <not <touching (level hitbox v)?>>\n    change y by (1)\n    set [~vel_y v] to [0]\nend\nchange [~y v] by ((y position) - (abs_y))\n\ndefine check_horizontal_collision (abs_x)\nset [~vel_x v] to ((~vel_x) * (~FORCE.friction))\nchange x by (4)\nif <<touching (level hitbox v)?> or <touching (player hitbox v)?>> then\n    change [~vel_x v] by (-4)\n    if <(~vel_x) < [-4]> then\n        set [~vel_x v] to [-4]\n    end\nend\nset x to (abs_x)\nchange x by (-4)\nif <<touching (level hitbox v)?> or <touching (player hitbox v)?>> then\n    change [~vel_x v] by (4)\n    if <(~vel_x) > [4]> then\n        set [~vel_x v] to [4]\n    end\nend\nset x to (abs_x)\nchange x by (~vel_x)\nchange [~x v] by ((x position) - (abs_x))\nturn right ((x position) - (abs_x)) degrees\n\nwhen I receive [change game state v]\n\nif <(@game state) = [respawn]> then\n    reset\nend\n\nwhen I receive [level_select v]\nif <(~ID) > [0]> then\n    stop [other scripts in sprite v]\n    hide\nend\n\ndefine reset\nset [~x v] to (item (~ID) of [~locations v])\nset [~y v] to (item ((~ID) + (1)) of [~locations v])\nset [~hanging? v] to (item ((~ID) + (2)) of [~locations v])\nset [~pushable? v] to (item ((~ID) + (3)) of [~locations v])\nset [~vel_y v] to [0]\n\n@logo3\n\nwhen flag clicked\nhide\ngo to x: (0) y: (0)\nswitch costume to (backdrop1 v)\nset [ghost v] effect to (0)\nshow\ngo to [front v] layer\nset [_cloneid v] to [0]\nrepeat (2)\n    change [_cloneid v] by (1)\n    create clone of (_myself_ v)\nend\nwait (3.5) seconds\nfade [-1] [10]\nhide\nbroadcast (title v)\n\nwhen I receive [end logo v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nwhen I start as a clone\nshow\ngo to [front v] layer\nif <(_cloneID) = [1]> then\n    switch costume to (costume1 v)\n    fade in and out [0] [1.8]\nelse\n    switch costume to (costume2 v)\n    fade in and out [0.5] [0.8]\nend\n\ndefine fade in and out (delay) (pause)\nset [ghost v] effect to (100)\nwait (delay) seconds\nfade [1] [5]\nwait (pause) seconds\nfade [-1] [5]\ndelete this clone\n\ndefine fade (in\(1\)/out\(-1\)) (speed)\nrepeat ((100) / (speed))\n    change [ghost v] effect by (((0) - (in\(1\)/out\(-1\))) * (speed))\nend\n\n
Use arrow keys or w,a,s,d to move.\nAlso is mobile!\nPress s to skip and press r to reset