Pixel Platformer 2.0
@Stage\n\nwhen flag clicked\ninit [62] [5064]\n\nwhen I receive [change game state v]\nif <<(@game state) = [transition.to_game]> or <(@game state) = [game]>> then\n    switch backdrop to (level1 v)\n    change song (@current_song) [SMG2 - Battle Belt Galaxy]\nelse\n    if < (@game state) contains [transition.to_title]?> then\n        switch backdrop to (level1 v)\n        change song (@current_song) [Fork Lifter - Rhythm Heaven Fever.mp3]\n    end\nend\n\nwhen [e v] key pressed\nif <(username) = [amylaser]> then\n    if <(@game state) = [game]> then\n        if <(@player state) = [pause]> then\n            set [@player state v] to [camera_return]\n        else\n            set [@player state v] to [pause]\n        end\n        broadcast (change player state v)\n    end\nend\n\nwhen I receive [change_volume2 v]\nset volume to ((100) * (@sound_on?)) %\n\nwhen [m v] key pressed\nif <(@game state) = [game]> then\n    set [@player state v] to [pause]\n    set [@game state v] to [transition.target_title]\n    broadcast (change game state v)\nend\n\ndefine init (startx) (starty)\nset [@startx v] to (startx)\nset [@starty v] to (starty)\nset [@camera x v] to (startx)\nset [@camera y v] to (starty)\nset [@player.x v] to (startx)\nset [@player.y v] to (starty)\nset [@checkpt_x v] to (startx)\nset [@checkpt_y v] to (starty)\nset [@game state v] to [transition.target_title]\nset [@player state v] to [pause]\nset [=max_levels v] to [4]\nset [=panel_width v] to [480]\nset [=panel_height v] to [360]\nset [=level_width_panels v] to [4]\nset [=level_height_panels v] to [4]\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 [@camera_speed v] to [10]\nset [@current_song v] to [0]\nhide variable [@camera_speed v]\nhide variable [@camera x v]\nhide variable [@camera y v]\nhide variable [@player.x v]\nhide variable [@player.y v]\nset volume to (100) %\nswitch backdrop to (level1 v)\nset [brightness v] effect to (-10)\n\nwhen [r v] key pressed\nif <(@game state) = [game]> then\n    set [@player state v] to [pause]\n    set [@game state v] to [transition.target_game]\n    broadcast (change game state v)\nend\n\nwhen I receive [tick v]\nset [@curr_level v] to ([ceiling v] of (((@camera y) + ((=panel_height) / (2))) / (=level_height_px)) )\nif <(@player state) = [pause]> 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\nif <not <(backdrop [number v]) = (@curr_level)>> then\n    switch backdrop to (@curr_level)\nend\n\nwhen I receive [change player state v]\nif <(@player state) = [pause]> then\n    show variable [@camera_speed v]\n    show variable [@camera x v]\n    show variable [@camera y v]\n    show variable [@player.x v]\n    show variable [@player.y v]\nelse\n    hide variable [@camera_speed v]\n    hide variable [@camera x v]\n    hide variable [@camera y v]\n    hide variable [@player.x v]\n    hide variable [@player.y v]\nend\n\nwhen [t v] key pressed\nif <(username) = [amylaser]> then\n    set [@player.x v] to (@camera x)\n    set [@player.y v] to (@camera y)\nend\n\ndefine change song (curr_song) (new_song)\nif <not <(curr_song) = (new_song)>> then\n    stop all sounds\n    set [@current_song v] to (new_song)\n    broadcast (change music v)\nend\n\nwhen I receive [change music v]\nforever\n    play sound (@current_song) 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) - (60))>>>\nset [@input.up v] to <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > ((y position) + (60))>>>\nset [@input.left v] to <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(mouse x) < ((x position) - (70))>>>\nset [@input.right v] to <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(mouse x) > ((x position) + (70))>>>\nset [@input.action v] to <<key (space v) pressed?> or <<mouse down?> and <(distance to [mouse-pointer v]) < [100]>>>\nif <(@Input.ACTION) = [true]> then\n    if <<<(@player state) = [go]> or <(@player state) = [talk]>> and <(~timer.action) = [0]>> then\n        set [~timer.action v] to [20]\n        broadcast (player action v)\n    end\nend\nif <(~timer.action) > [0]> then\n    change [~timer.action v] by (-1)\nend\n\nwhen I receive [player attack v]\nif <<(@player state) = [go]> and <(~air time) < [1]>> then\n    set [@player state v] to [attack]\n    set [@player.animation_type v] to [attack]\n    start sound [Rip v]\nend\n\ndefine respawn\nhide\nset [@camera x v] to (@checkpt_x)\nset [@camera y v] to (@checkpt_y)\nif <(@camera x) > ((=map_width_px) - (=panel_width))> then\n    set [@camera x v] to ((=map_width_px) - (=panel_width))\nelse\n    if <(@camera x) < [0]> then\n        set [@camera x v] to [0]\n    end\nend\nset [@player.x v] to (@checkpt_x)\nset [@player.y v] to (@checkpt_y)\nset [@player.xvel v] to [0]\nset [@player.yvel v] to [0]\nset [@player.animation_type v] to [idle]\nset [~move_mode v] to [walk]\nset [~timer.hurt v] to [0]\nset [~air time v] to [0]\nset [@player state v] to [go]\nset [@player.is_invincible v] to [0]\nset [@is_ghost_floor_active? v] to [0]\ngo to x: ((@player.x) - (@camera x)) y: ((@player.y) - (@camera y))\n\nwhen I receive [change_volume2 v]\nset volume to ((100) * (@sound_on?)) %\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.xvel v] to [0]\nset [@player.yvel v] to [0]\nset [~max_health v] to [3]\nset [@player.health v] to (~max_health)\nset [@player.is_invincible v] to [0]\nset [~force.climb v] to [4]\nset [~force.jump v] to [13]\nset [~force.leftright v] to [9]\nset [~force.gravity v] to [-1.1]\nset [~force.push v] to [4]\nset [~friction v] to [0.5]\nset [~camera.max_dist v] to [100]\nset [~camera.springiness v] to [0.13]\nset [~move_mode v] to [walk]\nset [~slope v] to [0]\nset [~slope.max v] to [12]\nset [~air time v] to [0]\nset [~player.yvel_min v] to [-30]\nset [~timer.action v] to [0]\nset [~timer.hurt v] to [0]\nset [@is_ghost_floor_active? v] to [0]\n\ndefine update wrapper\ngo to x: ((@player.x) - (@camera x)) y: ((@player.y) - (@camera y))\nget_keyboard_input\nif <<(@player state) = [go]> or <(@player state) = [hurt]>> then\n    update_player_vec <(@Input.UP) = [true]> <(@Input.DOWN) = [true]> <(@Input.LEFT) = [true]> <(@Input.RIGHT) = [true]> (~move_mode)\nend\nif <<<(@player state) = [go]> or <(@player state) = [hurt]>> or <<(@player state) = [stunned]> or <(@player state) = [camera_return]>>> then\n    update_camera_pos\nend\nupdate_costume <(@Input.UP) = [true]> <(@Input.DOWN) = [true]> <(@Input.LEFT) = [true]> <(@Input.RIGHT) = [true]> ((@player.xvel) / ([abs v] of (@player.xvel) )) ((@player.yvel) / ([abs v] of (@player.yvel) ))\ngo to x: ((@player.x) - (@camera x)) y: ((@player.y) - (@camera y))\nif <<([abs v] of (((@player.x) - (@camera x)) - (x position)) ) < [10]> and <([abs v] of (((@player.y) - (@camera y)) - (y position)) ) < [10]>> then\n    show\n    if <<(@player state) = [camera_return]> and <<([abs v] of (x position) ) < [220]> and <([abs v] of (y position) ) < [160]>>> then\n        set [@player state v] to [go]\n    end\nelse\n    hide\nend\nif <(~timer.hurt) > [0]> then\n    change [~timer.hurt v] by (-1)\nelse\n    set [~timer.hurt v] to [0]\n    if <not <<(@player state) = [stunned]> or <(@player state) = [win]>>> then\n        set [@player.is_invincible v] to [0]\n    end\nend\nif <(@player.health) > (~max_health)> then\n    set [@player.health v] to (~max_health)\nend\n\ndefine state_behavior.drowning\nchange [@player.health v] by (-1)\nstart sound [Plunge v]\nrepeat until <not <touching (water v)?>>\n    change y by (1)\n    change [@player.y v] by (1)\nend\nstart sound [Meow2 v]\nwait (2) seconds\nif <(@player.health) < [1]> then\n    start sound [Oops v]\n    set [@game state v] to [transition.target_game]\n    broadcast (change game state v)\nelse\n    set [@player state v] to [respawn]\n    broadcast (change player state v)\nend\n\ndefine update_player_vec <up> <down> <left> <right> (mode)\nif <(mode) = [walk]> then\n    if <<<up> and <(~air time) = [0]>> and <(@player state) = [go]>> then\n        set [@player.yvel v] to (~FORCE.Jump)\n        start sound [Jump v]\n    else\n        set [@player.yvel v] to ((@player.yvel) + (~FORCE.Gravity))\n        if <(@player.yvel) < (~player.yvel_min)> then\n            set [@player.yvel v] to (~player.yvel_min)\n        end\n    end\n    if <<<left> or <right>> and <(@player state) = [go]>> then\n        set [@player.xvel v] to ((~FORCE.LeftRight) * (<right> - <left>))\n        if <(~slope) > (~slope.max)> then\n            if <up> then\n                set [@player.yvel v] to (~FORCE.Climb)\n            else\n                set [@player.yvel v] to (~FORCE.Gravity)\n            end\n            set [~air time v] to [1]\n        end\n    else\n        if <<(~air time) < [2]> or <(@player state) = [go]>> then\n            set [@player.xvel v] to ((@player.xvel) * (~FRICTION))\n        end\n    end\nend\ncheck_horizontal_collision (@player.xvel) (x position) (y position) ((@player.xvel) / ([abs v] of (@player.xvel) ))\ncheck_ghost_platform <(@Input.DOWN) = [true]> (x position) (y position)\ncheck_vertical_collision (@player.yvel) ((@player.yvel) / ([abs v] of (@player.yvel) )) (y position)\nif <(@player.y) < ((([floor v] of ((@curr_level) / (=map_width_panels)) ) - (0.5)) * (=level_height_px))> then\n    set [@player state v] to [respawn]\n    broadcast (change player state v)\nend\n\nwhen flag clicked\ninit\n\ndefine update_camera_pos\nset [@camera x v] to (round ((@camera x) + ((~CAMERA.springiness) * (((@player.x) + (((@player.xvel) / (~FORCE.LeftRight)) * (~CAMERA.max_dist))) - (@camera x)))))\nset [@camera y v] to (round ((@camera y) + ((~CAMERA.springiness) * (((@player.y) + (((@player.yvel) / (~FORCE.Jump)) * (~CAMERA.max_dist))) - (@camera y)))))\nif <(@camera x) > ((=map_width_px) - (=panel_width))> then\n    set [@camera x v] to ((=map_width_px) - (=panel_width))\nelse\n    if <(@camera x) < [0]> then\n        set [@camera x v] to [0]\n    end\nend\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 <<touching (ghost floors v)?> and <(@is_ghost_floor_active?) = [1]>>>> 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    if <<not <<touching (level hitbox v)?> or <touching (objects v)?>>> and <<touching (ghost floors v)?> and <(@is_ghost_floor_active?) = [1]>>> then\n        set [~slope v] to [0]\n    else\n        set [@player.xvel v] to [0]\n        repeat until <not <<touching (level hitbox v)?> or <touching (objects v)?>>>\n            change [@player.xvel v] by (1)\n            change x by (((((@player.xvel) mod (2)) * (2)) - (1)) * (@player.xvel))\n            if <(@player.xvel) > (~slope.max)> then\n                set x to (abs_x)\n                set [@player.xvel v] to [0]\n                repeat until <not <<touching (level hitbox v)?> or <touching (objects v)?>>>\n                    change [@player.xvel v] by (1)\n                    change y by (((((@player.xvel) mod (2)) * (2)) - (1)) * (@player.xvel))\n                end\n                set [@player.xvel v] to [0]\n            end\n        end\n        set [@player.xvel v] to [0]\n    end\nelse\n    change x by ((0) - (round (((~slope) / (~slope.max)) * (vel_x))))\n    change y by ((0) - (round (((~slope) / (~slope.max)) * (~slope))))\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)\nif <<<touching (level hitbox v)?> or <touching (objects v)?>> or <<touching (ghost floors v)?> and <(@is_ghost_floor_active?) = [1]>>> then\n    set [@player.yvel v] to [0]\n    repeat until <not <<<touching (level hitbox v)?> or <touching (objects v)?>> or <<touching (ghost floors v)?> and <(@is_ghost_floor_active?) = [1]>>>>\n        if <(dir_vel_y) < [0]> then\n            set [~air time v] to [0]\n        end\n        change [@player.yvel v] by (1)\n        change y by (((((@player.yvel) mod (2)) * (2)) - (1)) * (@player.yvel))\n    end\n    set [@player.yvel 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 <(@player state) = [win]> then\n    set [@player.animation_type v] to [win]\nelse\n    if <(@player state) = [drowning]> then\n        set [@player.animation_type v] to [water]\n    else\n        if <(@player state) = [hurt]> then\n            set [@player.animation_type v] to [hurt]\n            if <(~air time) < [1]> then\n                set [@player state v] to [go]\n                if <(@player.health) < [1]> then\n                    set [@player state v] to [stunned]\n                end\n                broadcast (change player state v)\n            end\n        else\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 <(@player state) = [stunned]> then\n                    set [@player.animation_type v] to [stunned]\n                else\n                    if <(@player 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) > [8]> 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 <not <<left> = <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\n        end\n    end\nend\n\ndefine state_behavior.hurt\nif <<(~timer.hurt) = [0]> and <(@player.is_invincible) = [0]>> then\n    set [~timer.hurt v] to [60]\n    set [@player.is_invincible v] to [1]\n    change [@player.health v] by (-1)\n    start sound [Meow2 v]\n    start sound [Pew v]\n    set [@player.xvel v] to [0]\n    change x by (30)\n    if <<touching (rats v)?> or <touching (spikes v)?>> then\n        change [@player.xvel v] by ((0) - (~FORCE.LeftRight))\n    end\n    change x by (-60)\n    if <<touching (rats v)?> or <touching (spikes v)?>> then\n        change [@player.xvel v] by (~FORCE.LeftRight)\n    end\n    change x by (10)\n    set [@player.yvel v] to ((~FORCE.Jump) - (3))\nend\n\nwhen I receive [change game state v]\nif <(@game state) = [transition.target_game]> then\n    hide\n    set [@player state v] to [pause]\n    set [@player.health v] to (~max_health)\n    set [@checkpt_x v] to (@startx)\n    set [@checkpt_y v] to (@starty)\n    respawn\nelse\n    if <(@game state) = [transition.to_game]> then\nend\n\nwhen I receive [change player state v]\nif <(@player state) = [respawn]> then\n    respawn\n    start sound [Oops v]\nelse\n    if <(@player state) = [drowning]> then\n        state_behavior.drowning\n    else\n        if <(@player state) = [hurt]> then\n            state_behavior.hurt\n        else\n            if <(@player state) = [stunned]> then\n                set [@player.is_invincible v] to [1]\n                start sound [Oops v]\n                wait (2) seconds\n                set [@game state v] to [transition.target_game]\n                broadcast (change game state v)\n            else\n                if <(@player state) = [win]> then\n                    set [@player.is_invincible v] to [1]\n                    start sound [Tada v]\n                end\n            end\n        end\n    end\nend\n\ndefine check_ghost_platform <down_key> (startx) (starty)\nif <<(@player.yvel) > [0]> or <<touching (ghost floors v)?> or <down_key>>> then\n    set [@is_ghost_floor_active? v] to [0]\nelse\n    set [@is_ghost_floor_active? v] to [1]\nend\n\n@player visual\n\ndefine init\nhide\nset rotation style [left-right v]\npoint in direction (90)\nswitch costume to (idle v)\nset size to (70) %\nset [ghost v] effect to (0)\nset [~animation.frame v] to [0]\n\nwhen flag clicked\ninit\n\nwhen I receive [change game state v]\nif <(@game state) = [transition.to_game]> then\n    init\n    go to (player hitbox v)\n    show\n    go to [front v] layer\n    go [backward v] (6) layers\nelse\n    if < (@game state) contains [transition.to_]?> then\n        stop [other scripts in sprite v]\n        hide\n    else\n        if <(@game state) = [game]> then\n            forever\n                if <(@player.animation_type) = [walk]> then\n                    play sound [Gallop v] until done\n                else\n                    if <(@player.animation_type) = [climb]> then\n                        play sound [Shaker v] until done\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine animate <left> <right>\ngo to (player hitbox v)\nif <<([abs v] of (x position) ) > [235]> or <([abs v] of (y position) ) > [175]>> 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]>> or <(@player.animation_type) = [win]>> 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) = [stunned]> then\n                    set [~animation.frame v] to (((~animation.frame) + (0.5)) mod (4))\n                else\n                    if <(@player.animation_type) = [attack]> then\n                        if <mouse down?> then\n                            point in direction ((90) * (([abs v] of ((mouse x) - (x position)) ) / ((mouse x) - (x position))))\n                        end\n                        set [~animation.frame v] to (((~animation.frame) + (0.5)) mod (9))\n                        if <(~animation.frame) > [8]> then\n                            set [@player 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) ))\nend\nif <<([~timer.hurt v] of [player hitbox v]) > [0]> and <not <(@player.animation_type) = [stunned]>>> then\n    set [ghost v] effect to ((30) * ((round (([~timer.hurt v] of [player hitbox v]) / (5))) mod (2)))\nelse\n    set [ghost v] effect to (0)\nend\n\nwhen I receive [tick v]\nanimate <(@Input.LEFT) = [true]> <(@Input.RIGHT) = [true]>\n\n@level visual\n\nwhen I receive [tick v]\nif <(~panel_set.row_ID) > [0]> then\n    scroll\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)\nupdate_costume\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 (join (join (~costume.col_ID) [,]) (~costume.row_ID))\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 [name v]) = (~costume.target_ID)>> then\n        switch costume to (~costume.target_ID)\n    end\n    if <<([abs v] of ((x position) - (~x)) ) < [5]> and <([abs v] of ((y position) - (~y)) ) < [5]>> then\n        show\n    else\n        hide\n    end\nelse\n    hide\nend\n\ndefine init\nhide\nswitch costume to (0,3 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]\nset [~costume.col_id v] to [-1]\nset [~costume.row_id v] to [-1]\n\nwhen I receive [change game state v]\nif <(~panel_set.row_ID) > [0]> then\n    if <(@game state) = [transition.to_game]> then\n        scroll\n        show\n        go to [back v] layer\n        wait (0.1) seconds\n        scroll\n    else\n        if < (@game state) contains [transition.to_]?> then\n            stop [other scripts in sprite v]\n            hide\n        end\n    end\nend\n\n@level hitbox\n\nwhen I receive [tick v]\nif <(~panel_set.row_ID) > [0]> then\n    scroll\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)\nupdate_costume\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 (join (join (~costume.col_ID) [,]) (~costume.row_ID))\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 [name v]) = (~costume.target_ID)>> then\n        switch costume to (~costume.target_ID)\n    end\n    if <<([abs v] of ((x position) - (~x)) ) < [10]> and <([abs v] of ((y position) - (~y)) ) < [10]>> then\n        show\n    else\n        hide\n    end\nelse\n    hide\nend\n\nwhen I receive [change game state v]\nif <(~panel_set.row_ID) > [0]> then\n    if <(@game state) = [transition.to_game]> then\n        wait (0.1) seconds\n        scroll\n        show\n        go to [back v] layer\n    else\n        if < (@game state) contains [transition.to_]?> then\n            stop [other scripts in sprite v]\n            hide\n        end\n    end\nend\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 (0,3 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\n@dialogue\n\nwhen flag clicked\ninit\n\ndefine dialogue\nif <<(@player state) = [go]> or <(@player state) = [talk]>> then\n    show\n    go to [front v] layer\n    if <not <(~text.opened_index) = (~text.index)>> then\n        set [@player 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)\n    else\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 [@player state v] to [go]\n        end\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\nelse\n    broadcast (player attack v)\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    if <(~text.opened_index) > [0]> then\n        animate_out (~text.BOUNCE)\n    end\n    set [~text.opened_index v] to [0]\n    if <(@player state) = [talk]> then\n        set [@player 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: [intro] x: [127] y: [5066]\nadd_location | title: [tutorial_climb] x: [257] y: [5066]\nadd_location | title: [tutorial_attack] x: [497] y: [5276]\nadd_location | title: [tutorial_down] x: [872] y: [5276]\nadd_location | title: [tutorial_push] x: [862] y: [5066]\n\nwhen I receive [change_volume2 v]\nset volume to ((100) * (@sound_on?)) %\n\nwhen I receive [change game state v]\nif <<not <(@game state) = [transition.to_game]>> and < (@game state) contains [transition.to_]?>> then\n    stop [other scripts in sprite v]\n    hide\nend\n\n@water\n\nwhen I receive [tick v]\nif <(~panel_set.row_ID) > [0]> then\n    scroll\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)))))\nanimate [3] [5]\nupdate_costume\ngo to x: (~x) y: (~y)\nif <<([abs v] of ((~x) - (x position)) ) < [5]> and <([abs v] of ((~y) - (y position)) ) < [5]>> then\n    show\n    check_player_collision\nelse\n    hide\nend\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 (join (join (~costume.col_ID) [,]) (~costume.row_ID))\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 [name v]) = (~costume.target_ID)>> then\n        switch costume to (~costume.target_ID)\n        if <not <(costume [name v]) = (~costume.target_ID)>> then\n            switch costume to (null v)\n        end\n    end\nelse\n    hide\nend\n\nwhen I receive [change game state v]\nif <(~panel_set.row_ID) > [0]> then\n    if <(@game state) = [transition.to_game]> then\n        wait (0.1) seconds\n        scroll\n        go to [front v] layer\n        go [backward v] (6) layers\n    else\n        if < (@game state) contains [transition.to_]?> then\n            stop [other scripts in sprite v]\n            hide\n        end\n    end\nend\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 (40)\nswitch costume to (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]\nset [~animation.timer v] to [0]\n\ndefine check_player_collision\nif <<touching (player hitbox v)?> and <not <(@player state) = [drowning]>>> then\n    set [@player state v] to [drowning]\n    broadcast (change player state v)\nend\n\ndefine animate (range) (speed)\nset [~animation.timer v] to (((~animation.timer) + (speed)) mod (360))\nchange [~y v] by (([sin v] of (~animation.timer) ) * (range))\n\n@icons\n\nwhen flag clicked\nset [@show icon v] to [0]\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]> and <(@player state) = [go]>> then\n    set [@show icon v] to [0]\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    set [~icon.animation_frame v] to [-1]\n    hide\nend\n\nwhen I receive [change game state v]\nif <(@game state) = [game]> then\n    stop [other scripts in sprite v]\n    set [@show icon v] to [0]\n    set [~icon.animation_frame v] to [0]\n    go to [front v] layer\n    go [backward v] (2) layers\n    hide\nelse\n    if < (@game state) contains [transition.to_]?> then\n        stop [other scripts in sprite v]\n        hide\n    end\nend\n\n@score fish\n\nwhen flag clicked\ninit\nset [~id v] to [0]\n\ndefine animate_idle (speed)\nturn right (([sin v] of (~animation_frame) ) * (2)) degrees\nchange size by (([sin v] of ((~animation_frame) * (5)) ) * (2))\nset [~animation_frame v] to (((~animation_frame) + (speed)) mod (360))\n\nwhen I receive [change game state v]\nif <(@game state) = [game]> then\n    if <(~ID) > [0]> then\n        reset\n        show\n        go to [front v] layer\n        go [backward v] (16) layers\n    else\n        switch costume to (score v)\n        reset timer\n        show\n        go to [front v] layer\n        set [@score.fish v] to [0]\n        set [@score.fish.display v] to (join [0/] (@num_fish))\n        set [@score.time v] to [0]\n        show variable [@score.fish.display v]\n        show variable [@score.time v]\n    end\nelse\n    if < (@game state) contains [transition.target_]?> then\n        hide variable [@score.fish.display v]\n        hide variable [@score.time v]\n    else\n        if < (@game state) contains [transition.to_]?> then\n            hide\n        end\n    end\nend\n\ndefine animate_collect\npoint in direction (90)\nif <(size) < [120]> 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 <<([abs v] of (((~x) - (@camera x)) - (x position)) ) < [5]> and <([abs v] of (((~y) - (@camera y)) - (y position)) ) < [5]>> then\n    show\n    if <(~collected?) = [0]> then\n        animate_idle (~ROTATE_SPEED)\n        check_cat_collision [30]\n    end\nelse\n    hide\nend\nif <(~collected?) = [1]> then\n    animate_collect\nend\n\nwhen I receive [tick v]\nif <(~ID) = [0]> then\n    check_win_condition\nelse\n    if <<([abs v] of ((~x) - (@camera x)) ) < (=panel_width)> and <([abs v] of ((~y) - (@camera y)) ) < (=panel_height)>> then\n        if <not <(costume [name v]) = [collected]>> then\n            scroll\n        end\n    else\n        hide\n    end\nend\n\nwhen I start as a clone\nreset\n\ndefine init\nhide\nswitch costume to (score v)\nset size to (100) %\nset [ghost v] effect to (0)\nset volume to (100) %\ngo to x: (0) y: (0)\nset rotation style [all around v]\npoint in direction (90)\nshow list [~fish_locations v]\ndelete all of [~fish_locations v]\nset [@score.fish v] to [0]\nset [@score.time v] to [0]\nset [~rotate_speed v] to [5]\nset [~animation_frame v] to [0]\nset [~collected? v] to [0]\nset [~id v] to [0]\nhide variable [@score.fish v]\nhide variable [@score.time v]\nhide variable [@score.fish.display v]\nadd location | x: [83] y: [5300] desc: [dojo]\nadd location | x: [360] y: [4562] desc: [small house]\nadd location | x: [114] y: [770] desc: [small house roof]\nadd location | x: [478] y: [1120] desc: [dojo roof]\nadd location | x: [1007] y: [4651] desc: [cistern S cubby]\nadd location | x: [1378] y: [5006] desc: [cistern N cubby]\nadd location | x: [1135] y: [4450] desc: [cistern water]\nadd location | x: [-66] y: [30] desc: [W well]\nadd location | x: [-46] y: [1470] desc: [W pond]\nadd location | x: [1290] y: [1490] desc: [E pond]\nadd location | x: [1250] y: [2189] desc: [SE woods tree]\nadd location | x: [472] y: [2249] desc: [SW woods tree]\nadd location | x: [-17] y: [2415] desc: [W woods cliff]\nadd location | x: [25] y: [3277] desc: [SW pagoda island ledge]\nadd location | x: [-15] y: [3687] desc: [NW sakura tree]\nadd location | x: [575] y: [3977] desc: [W pagoda roof]\nadd location | x: [1035] y: [3977] desc: [E pagoda roof]\nadd location | x: [950] y: [3162] desc: [S sakura tree]\nadd location | x: [1510] y: [3082] desc: [SE sakura tree]\nadd location | x: [1520] y: [3632] desc: [NE sakura tree]\nset [@num_fish v] to ((length of [~fish_locations v]) / (2))\nset [@score.fish.display v] to (join [0/] (@num_fish))\n\ndefine check_cat_collision (dist_thresh)\nif <touching (player hitbox v)?> then\n    set [~collected? v] to [1]\n    change [@score.fish v] by (1)\n    change [@player.health v] by (1)\n    set [@score.fish.display v] to (join (join (@score.fish) [/]) (@num_fish))\n    change [~y v] by (30)\n    set size to (100) %\n    start sound [Chomp v]\n    start sound [Coin v]\nend\n\ndefine add location | x: (x) y: (y) desc: (d)\nset [~id v] to ((length of [~fish_locations v]) + (1))\nswitch costume to (salmon v)\nadd (x) to [~fish_locations v]\nadd (y) to [~fish_locations v]\ncreate clone of (_myself_ v)\nset [~id v] to [0]\n\nwhen I receive [change_volume2 v]\nset volume to ((100) * (@sound_on?)) %\n\ndefine reset\nset [~x v] to (item (~ID) of [~fish_locations v])\nset [~y v] to (item ((~ID) + (1)) of [~fish_locations v])\nset [~animation_frame v] to [0]\nset [~collected? v] to [0]\nswitch costume to (salmon v)\nset size to (100) %\nset [ghost v] effect to (0)\ngo to x: ((~x) - (@camera x)) y: ((~y) - (@camera y))\npoint in direction (90)\n\ndefine check_win_condition\nif <(@score.fish) = (@num_fish)> then\n    if <not <(@player state) = [win]>> then\n        set [@player state v] to [win]\n        broadcast (change player state v)\n    end\nend\nif <not <(@player state) = [win]>> then\n    if <(timer) > [1]> then\n        reset timer\n        if <(@score.time) < [1000000]> then\n            change [@score.time v] by (1)\n        end\n    end\nend\n\nset [@num_fish v] to [1]\n\n@checkpoints\n\nwhen flag clicked\ninit\n\ndefine check_player_dist\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    change [~checkpt.index v] by (2)\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))\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\nupdate_checkpt\n\ndefine add location | x: (x) y: (y) desc: (desc)\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]\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 [@checkpt_x v] to (~checkpt.x)\n        set [@checkpt_y v] to (~checkpt.y)\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 [change game state v]\nif <(@game state) = [game]> then\n    set [ghost v] effect to (100)\n    show\n    go to [front v] layer\nelse\n    if < (@game state) contains [transition.to_]?> then\n        stop [other scripts in sprite v]\n        hide\n    end\nend\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\nstart sound [Suction Cup v]\nset size to (105) %\nbroadcast (~action)\n\nwhen I start as a clone\nshow\ngo to [front v] layer\ngo [backward v] (1) layers\nset volume to ((100) * (@sound_on?)) %\nrepeat until <(@game state) = [game]>\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 [change game state v]\nif <(~action) = [0]> then\n    if <(@game state) = [title]> then\n        add_button | action: [button.reset] skin [start] x: [0] y: [-120]\n        add_button | action: [button.leaderboard] skin [leader] x: [75] y: [-120]\n        add_button | action: [change_volume] skin (join [sound] (@sound_on?)) x: [-75] y: [-120]\n    else\n        if <(@game state) = [game]> then\n            add_button | action: [button.help] skin [help] x: [125] y: [140]\n            add_button | action: [button.reset] skin [reset] x: [165] y: [140]\n            add_button | action: [button.title] skin [back] x: [205] y: [140]\n        else\n            if <(@game state) = [leaderboard]> then\n                add_button | action: [button.title] skin [back] x: [-200] y: [140]\n            else\n                animate_out [0.5]\n            end\n        end\n    end\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 [tick v]\nif <<(@game state) = [game]> and <not <<(~action) = [0]> or <<(costume [name v]) = [help2]> or <(costume [name v]) = [help3]>>>>> then\n    animate (0.5) (100) (120)\nend\n\nwhen I receive [button.help v]\nif <(~action) = [button.help]> then\n    if <<(costume [name v]) = [help]> or <(costume [name v]) = [help2]>> then\n        next costume\n        go to [front v] layer\n        go to x: (0) y: (0)\n        hide variable [@score.fish.display v]\n        hide variable [@score.time v]\n        set [@player state v] to [talk]\n    else\n        switch costume to (help v)\n        go to [front v] layer\n        go to x: (125) y: (140)\n        show variable [@score.fish.display v]\n        show variable [@score.time v]\n        set [@player state v] to [go]\n    end\nend\n\nwhen I receive [change_volume2 v]\nset volume to ((100) * (@sound_on?)) %\n\nwhen I receive [button.reset v]\nif <(~action) = [0]> then\n    set [@game state v] to [transition.target_game]\n    broadcast (change game state v)\nelse\n    animate_out [0.5]\nend\n\nwhen I receive [button.title v]\nif <(~action) = [0]> then\n    set [@game state v] to [transition.target_title]\n    broadcast (change game state v)\nelse\n    animate_out [0.5]\nend\n\nwhen I receive [button.leaderboard v]\nif <(~action) = [0]> then\n    set [@game state v] to [transition.target_leaderboard]\n    broadcast (change game state v)\nelse\n    animate_out [0.5]\nend\n\nwhen I receive [change player state v]\nif <(@player state) = [win]> then\n    if <(~action) = [0]> then\n        wait (2) seconds\n        add_button | action: [button.leaderboard] skin [win] x: [0] y: [0]\n    else\n        delete this clone\n    end\nend\n\n@rats\n\nwhen flag clicked\ninit\n\ndefine scroll\nswitch costume to (hitbox v)\nif <<([abs v] of (x position) ) < [220]> and <([abs v] of (y position) ) < [160]>> then\n    if <<([abs v] of (((~x) - (@camera x)) - (x position)) ) < [10]> and <([abs v] of (((~y) - (@camera y)) - (y position)) ) < [10]>> then\n        if <not <<(@player state) = [pause]> or <(@player state) = [talk]>>> then\n            update_pos\n        end\n    end\nend\ngo to x: ((~x) - (@camera x)) y: ((~y) - (@camera y))\nif <<([abs v] of (((~x) - (@camera x)) - (x position)) ) < [10]> and <([abs v] of (((~y) - (@camera y)) - (y position)) ) < [10]>> then\n    show\nelse\n    hide\nend\nanimate\n\nwhen I receive [tick v]\nif <<(~ID) > [0]> and <(~health) > [0]>> then\n    scroll\nend\n\nwhen I start as a clone\nreset\n\ndefine init\nset rotation style [left-right v]\npoint in direction (90)\nhide\nswitch costume to (idle v)\nset [ghost v] effect to (0)\nset size to (60) %\nshow list [~locations v]\nset [~id v] to [0]\nset [~force.gravity v] to [-1.1]\nset [~force.move v] to [5]\nset [~vel_x v] to [0]\nset [~vel_y v] to [0]\nset [~x v] to [0]\nset [~y v] to [0]\nset [~slope.max v] to [5]\nset [~animation.type v] to [idle]\nset [~animation.frame v] to [0]\nset [~max_health v] to [2]\nset [~health v] to (~max_health)\nset [~timer.hurt v] to [0]\ndelete all of [~locations v]\nadd location | x: [836] y: [3550] desc: [pagodas]\nadd location | x: [226] y: [3470] desc: [E pagodas]\nadd location | x: [656] y: [2920] desc: [S pagodas]\nadd location | x: [1143] y: [2020] desc: [E woods]\nadd location | x: [633] y: [2020] desc: [W woods]\n\ndefine add location | x: (x) y: (y) desc: (desc)\nset [~id v] to ((length of [~locations v]) + (1))\nadd (x) to [~locations v]\nadd (y) to [~locations v]\ncreate clone of (_myself_ v)\nset [~id v] to [0]\n\ndefine update_pos\nupdate_vec (x position) (y position) (([abs v] of (([x position v] of [player hitbox v]) - (x position)) ) / (([x position v] of [player hitbox v]) - (x position)))\nswitch costume to (hitbox v)\ncheck_horizontal_collision (x position) (y position) (~vel_x) (([abs v] of (~vel_x) ) / (~vel_x))\ncheck_vertical_collision (y position) (([abs v] of (~vel_y) ) / (~vel_y))\n\ndefine check_vertical_collision (abs_y) (dir_y)\nchange y by (~vel_y)\nrepeat until <not <<<touching (level hitbox v)?> or <touching (objects v)?>> or <touching (ghost floors v)?>>>\n    change y by ((0) - (dir_y))\n    set [~vel_y v] to [0]\nend\nchange [~y v] by ((y position) - (abs_y))\n\ndefine check_horizontal_collision (abs_x) (abs_y) (vel_x) (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 <touching (ghost floors 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)?>> or <touching (ghost floors v)?>>>\n        change [~vel_x v] by (1)\n        change x by (((((~vel_x) mod (2)) * (2)) - (1)) * (~vel_x))\n        change y by (1)\n    end\n    set [~vel_x v] to [0]\nelse\n    set [~vel_x v] to ((vel_x) - (((~slope) * (1.5)) * (dir_vel_x)))\nend\nchange [~x v] by ((x position) - (abs_x))\nchange [~y v] by ((y position) - (abs_y))\n\ndefine reset\nset [~x v] to (item (~ID) of [~locations v])\nset [~y v] to (item ((~ID) + (1)) of [~locations v])\nset [~vel_y v] to [0]\nset [~health v] to (~max_health)\nset [~timer.hurt v] to [0]\nset [~timer.attack v] to [0]\nset [~animation.type v] to [idle]\ngo to x: ((~x) - (@camera x)) y: ((~y) - (@camera y))\nset [ghost v] effect to (0)\nswitch costume to (idle v)\ngo to [front v] layer\ngo [backward v] (7) layers\n\ndefine update_vec (abs_x) (abs_y) (dir_of_player)\nif <<<(distance to [player hitbox v]) < [200]> and <(~timer.hurt) = [0]>> and <(~health) > [0.5]>> then\n    switch costume to (attackbox v)\n    set y to ([y position v] of [player hitbox v])\n    if <not <touching (player hitbox v)?>> then\n        set [~vel_x v] to ((~FORCE.move) * (dir_of_player))\n        set [~animation.type v] to [walk]\n        set [~timer.attack v] to [10]\n    else\n        if <([abs v] of ((abs_y) - ([y position v] of [player hitbox v])) ) < [50]> then\n            set [~vel_x v] to [0]\n        end\n    end\n    set y to (abs_y)\nelse\n    set [~vel_x v] to ((~vel_x) * (0.5))\nend\nchange [~vel_y v] by (~FORCE.gravity)\nif <(~health) > [0.5]> then\n    check_is_attacking_player (dir_of_player)\n    check_player_is_attacking (dir_of_player)\n    if <touching (water v)?> then\n        set [~timer.hurt v] to [100]\n        set [~animation.type v] to [die]\n        set [~health v] to [0.5]\n        start sound [Squeaky Toy v]\n        start sound [Plunge v]\n    end\nend\n\ndefine animate\nif <(~animation.type) = [walk]> then\n    if <(~vel_x) > [0]> then\n        point in direction (90)\n    else\n        if <(~vel_x) < [0]> then\n            point in direction (-90)\n        end\n    end\n    if <(~vel_x) = [0]> then\n        set [~animation.type v] to [idle]\n    end\nend\nswitch costume to (~animation.type)\nif <(~animation.type) = [idle]> then\n    set [~animation.frame v] to (((~animation.frame) + (0.05)) mod (2))\nelse\n    if <(~animation.type) = [walk]> then\n        set [~animation.frame v] to (((~animation.frame) + (0.5)) mod (5))\n    else\n        if <(~animation.type) = [attack]> then\n            set [~animation.frame v] to (((~animation.frame) + (0.5)) mod (5))\n            if <([floor v] of (~animation.frame) ) = [4]> then\n                set [~animation.type v] to [idle]\n            end\n        else\n            if <(~animation.type) = [hurt]> then\n                set [~animation.frame v] to [0]\n                if <(~vel_y) = [0]> then\n                    set [~animation.type v] to [idle]\n                end\n            else\n                set [~animation.frame v] to [0]\n            end\n        end\n    end\nend\nswitch costume to ((costume [number v]) + ([floor v] of (~animation.frame) ))\nif <(~timer.hurt) > [0]> then\n    change [~timer.hurt v] by (-1)\nend\nif <(~timer.attack) > [0]> then\n    change [~timer.attack v] by (-1)\nend\nif <(~animation.type) = [die]> then\n    set [ghost v] effect to ((100) - (~timer.hurt))\n    if <(~timer.hurt) = [0]> then\n        hide\n        set [~health v] to [0]\n    end\nelse\n    if <(~timer.hurt) > [0]> then\n        set [ghost v] effect to ((30) * ((round ((~timer.hurt) / (5))) mod (2)))\n    else\n        set [ghost v] effect to (0)\n    end\nend\n\nwhen I receive [change game state v]\nif <(~ID) > [0]> then\n    if <(@game state) = [transition.to_game]> then\n        hide\n        wait (0.1) seconds\n        reset\n        scroll\n    else\n        if < (@game state) contains [transition.to_]?> then\n            stop [other scripts in sprite v]\n            hide\n        else\n            if <(@game state) = [game]> then\n                repeat until <not <(@game state) = [game]>>\n                    if <<(~animation.type) = [walk]> and <<([abs v] of (x position) ) < [220]> and <([abs v] of (y position) ) < [160]>>> then\n                        play sound [Gallop v] until done\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine check_player_is_attacking (dir_of_player)\nif <<(~timer.hurt) = [0]> and <(@player state) = [attack]>> then\n    if <<(([direction v] of [player visual v]) * (dir_of_player)) < [0]> and <<(distance to [player hitbox v]) < [80]> and <([abs v] of (([y position v] of [player hitbox v]) - (y position)) ) < [30]>>> then\n        if <(~timer.hurt) = [0]> then\n            change [~health v] by (-1)\n            set [~timer.hurt v] to [30]\n            set [~timer.attack v] to [30]\n            start sound [Pew v]\n            set [~vel_x v] to ((~FORCE.move) * ((0) - (dir_of_player)))\n            set [~vel_y v] to (~FORCE.move)\n            if <(~health) < [1]> then\n                set [~timer.hurt v] to [100]\n                set [~animation.type v] to [die]\n                set [~health v] to [0.5]\n                start sound [Squeaky Toy v]\n            else\n                set [~animation.type v] to [hurt]\n            end\n        end\n    end\nend\n\ndefine check_is_attacking_player (dir_of_player)\nif <(@player.is_invincible) = [0]> then\n    if <(~timer.attack) = [0]> then\n        switch costume to (attackbox v)\n        if <<touching (player hitbox v)?> and <((direction) * (dir_of_player)) > [0]>> then\n            set [~timer.attack v] to [30]\n            set [~animation.type v] to [attack]\n            start sound [Rip v]\n            set [@player state v] to [hurt]\n            broadcast (change player state v)\n        end\n    end\nend\n\n@objects\n\nwhen flag clicked\ninit\n\ndefine scroll\nif <<([abs v] of (x position) ) < [220]> and <([abs v] of (y position) ) < [160]>> then\n    if <<([abs v] of (((~x) - (@camera x)) - (x position)) ) < [10]> and <([abs v] of (((~y) - (@camera y)) - (y position)) ) < [10]>> then\n        if <not <<(@player state) = [pause]> or <(@player state) = [talk]>>> then\n            update_pos (item ((~ID) + (4)) of [~locations v])\n            camera_magnet (@player state)\n        end\n    end\nend\ngo to x: ((~x) - (@camera x)) y: ((~y) - (@camera y))\nif <<([abs v] of (((~x) - (@camera x)) - (x position)) ) < [10]> and <([abs v] of (((~y) - (@camera y)) - (y position)) ) < [10]>> 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 [~breakable? 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 [~force.push v] to [4]\nset [~vel_x v] to [0]\nset [~vel_y v] to [0]\nset [~x v] to [0]\nset [~y v] to [0]\nset [~is_player_pushing? v] to [0]\nset [~in_water? v] to [0]\nset [~slope.max v] to [2]\nset [@camera x v] to [0]\ndelete all of [~locations v]\nadd location | x: [695] y: [5066] breakable? [0] pushable? [1] costume: [crate] desc: [dojo]\nadd location | x: [1315] y: [4624] breakable? [0] pushable? [1] costume: [crate] desc: [cistern]\nadd location | x: [318] y: [2021] breakable? [0] pushable? [1] costume: [crate] desc: [woods]\n\ndefine add location | x: (x) y: (y) breakable? (b) pushable? (p) costume: (c) desc: (d)\nset [~id v] to ((length of [~locations v]) + (1))\nadd (x) to [~locations v]\nadd (y) to [~locations v]\nadd (b) to [~locations v]\nadd (p) to [~locations v]\nadd (c) to [~locations v]\nswitch costume to (c)\ncreate clone of (_myself_ v)\nset [~id v] to [0]\n\ndefine update_pos (costume)\nif <(~breakable?) = [0]> then\n    switch costume to (join (costume) [_hitbox])\n    if <(~pushable?) = [1]> then\n        update_vec (x position) (([abs v] of (([x position v] of [player hitbox v]) - (x position)) ) / (([x position v] of [player hitbox v]) - (x position)))\n        check_vertical_collision (y position)\n        check_horizontal_collision (x position) (y position) (~vel_x) (([abs v] of (~vel_x) ) / (~vel_x))\n    end\n    switch costume to (costume)\n    check_water_collision\nelse\n    if <(~in_water?) = [1]> then\n        animate [0.25] [5]\n    end\nend\n\nwhen I receive [player action v]\nif <<(~ID) > [0]> and <(distance to [player hitbox v]) < [70]>> then\n    wait until <(@player state) = [attack]>\n    set [~breakable? 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)?> or <touching (ghost floors 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) (abs_y) (vel_x) (dir_vel_x)\nset [~slope v] to [0]\nchange x by (vel_x)\nrepeat until <<not <<touching (level hitbox v)?> or <touching (ghost floors 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 (ghost floors v)?>>>\n        change [~vel_x v] by (1)\n        change x by (((((~vel_x) mod (2)) * (2)) - (1)) * (~vel_x))\n    end\n    set [~vel_x v] to [0]\nelse\n    set [~vel_x v] to ((vel_x) - (((~slope) * (1.5)) * (dir_vel_x)))\nend\nchange [~x v] by ((x position) - (abs_x))\nchange [~y v] by ((y position) - (abs_y))\nif <(costume [name v]) = [ball_hitbox]> then\n    turn right ((x position) - (abs_x)) degrees\nend\ngo to x: (abs_x) y: (abs_y)\nif <(~is_player_pushing?) = [1]> then\n    set [@player.xvel v] to (~vel_x)\n    change [@player.x v] by ((x position) - (abs_x))\n    change [@player.y v] by ((y position) - (abs_y))\nend\n\ndefine reset\nset [~x v] to (item (~ID) of [~locations v])\nset [~y v] to (item ((~ID) + (1)) of [~locations v])\nset [~breakable? v] to (item ((~ID) + (2)) of [~locations v])\nset [~pushable? v] to (item ((~ID) + (3)) of [~locations v])\nswitch costume to (item ((~ID) + (4)) of [~locations v])\nset [~vel_y v] to [0]\nset [~in_water? v] to [0]\nset [~is_player_pushing? v] to [0]\nset [~animation.timer v] to [0]\ngo to [back v] layer\ngo [forward v] (10) layers\n\ndefine update_vec (abs_x) (dir_of_player)\nchange x by (((2.5) * (~FORCE.push)) * (dir_of_player))\nif <<<<<(@Input.LEFT) = [true]> and <(dir_of_player) = [1]>> or <<(@Input.RIGHT) = [true]> and <(dir_of_player) = [-1]>>> and <(@player.yvel) = [0]>> and <touching (player hitbox v)?>> then\n    set [~is_player_pushing? v] to [1]\nelse\n    set [~is_player_pushing? v] to [0]\nend\nset x to (abs_x)\nif <(~is_player_pushing?) = [1]> then\n    set [~vel_x v] to ((~FORCE.push) * (<(@Input.RIGHT) = [true]> - <(@Input.LEFT) = [true]>))\nelse\n    set [~vel_x v] to ((~vel_x) * (~FORCE.friction))\nend\n\nwhen I receive [change game state v]\nif <(~ID) > [0]> then\n    if <(@game state) = [transition.to_game]> then\n        hide\n        wait (0.1) seconds\n        reset\n        scroll\n    else\n        if < (@game state) contains [transition.to_]?> then\n            stop [other scripts in sprite v]\n            hide\n        else\n            if <(@game state) = [game]> then\n                repeat until <not <(@game state) = [game]>>\n                    if <(~is_player_pushing?) = [1]> then\n                        play sound [Ocean Wave v] until done\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine check_water_collision\nif <<(~in_water?) = [0]> and <touching (water v)?>> then\n    set [~in_water? v] to [1]\n    start sound [Plunge v]\nelse\n    if <<(~in_water?) = [1]> and <(~vel_y) = [0]>> then\n        set [~breakable? v] to [1]\n        set [~vel_y v] to [0]\n    end\nend\n\ndefine camera_magnet (player_state)\nif <<(~breakable?) = [0]> and <<(~vel_y) < ((5) * (~FORCE.gravity))> and <(y position) < [0]>>> then\n    set [@player state v] to [camera_magnet]\n    change [@camera x v] by ((0.5) * ((~x) - (@camera x)))\n    change [@camera y v] by ((0.5) * ((~y) - (@camera y)))\nelse\n    if <<<(@player state) = [camera_magnet]> and <(~vel_y) = [0]>> and <(~animation.timer) > [150]>> then\n        set [@player state v] to [camera_return]\n    end\nend\n\ndefine animate (range) (speed)\nset [~animation.timer v] to (((~animation.timer) + (speed)) mod (360))\nchange [~y v] by (([sin v] of (~animation.timer) ) * (range))\n\n@spikes\n\nwhen I receive [tick v]\nif <(~panel_set.row_ID) > [0]> then\n    scroll\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)))))\nupdate_costume\ngo to x: (~x) y: (~y)\nif <<([abs v] of ((~x) - (x position)) ) < [5]> and <([abs v] of ((~y) - (y position)) ) < [5]>> then\n    check_player_collision\nelse\n    hide\nend\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 (join (join (~costume.col_ID) [,]) (~costume.row_ID))\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 [name v]) = (~costume.target_ID)>> then\n        switch costume to (~costume.target_ID)\n        if <not <(costume [name v]) = (~costume.target_ID)>> then\n            switch costume to (null v)\n        end\n    end\n    animate [2] [5]\nelse\n    hide\nend\n\nwhen I receive [change game state v]\nif <(~panel_set.row_ID) > [0]> then\n    if <(@game state) = [transition.to_game]> then\n        wait (0.1) seconds\n        scroll\n        show\n        go to [front v] layer\n        go [backward v] (4) layers\n    else\n        if < (@game state) contains [transition.to_]?> then\n            stop [other scripts in sprite v]\n            hide\n        end\n    end\nend\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 [~animation.timer v] to [0]\nclear graphic effects\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\ndefine check_player_collision\nif <(@player.is_invincible) = [0]> then\n    if <touching (player hitbox v)?> then\n        set [@player state v] to [hurt]\n        broadcast (change player state v)\n    end\nend\n\ndefine animate (range) (speed)\nset [~animation.timer v] to (((~animation.timer) + (speed)) mod (360))\nchange [color v] effect by (([sin v] of (~animation.timer) ) * (range))\n\n@false walls\n\nwhen I receive [tick v]\nif <(~panel_set.row_ID) > [0]> then\n    scroll\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)))))\nupdate_costume\ngo to x: (~x) y: (~y)\nif <<([abs v] of ((~x) - (x position)) ) < [5]> and <([abs v] of ((~y) - (y position)) ) < [5]>> then\n    check_player_collision\nelse\n    hide\nend\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 (join (join (~costume.col_ID) [,]) (~costume.row_ID))\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 [name v]) = (~costume.target_ID)>> then\n        switch costume to (~costume.target_ID)\n        if <not <(costume [name v]) = (~costume.target_ID)>> then\n            switch costume to (null v)\n        end\n    end\nelse\n    hide\nend\n\nwhen I receive [change game state v]\nif <(~panel_set.row_ID) > [0]> then\n    if <(@game state) = [transition.to_game]> then\n        wait (0.1) seconds\n        scroll\n        show\n        go to [front v] layer\n        go [backward v] (4) layers\n    else\n        if < (@game state) contains [transition.to_]?> then\n            stop [other scripts in sprite v]\n            hide\n        end\n    end\nend\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 [~animation.timer v] to [0]\nclear graphic effects\nswitch costume to (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\ndefine check_player_collision\nif <touching (player hitbox v)?> then\n    if <(~animation.timer) = [0]> then\n        set [~animation.timer v] to [1]\n        set [ghost v] effect to (40)\n    end\nelse\n    if <(~animation.timer) = [1]> then\n        set [~animation.timer v] to [0]\n        set [ghost v] effect to (0)\n    end\nend\n\n@ghost floors\n\nwhen I receive [tick v]\nif <(~panel_set.row_ID) > [0]> then\n    scroll\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)))))\nupdate_costume\ngo to x: (~x) y: (~y)\nif <<([abs v] of ((~x) - (x position)) ) < [5]> and <([abs v] of ((~y) - (y position)) ) < [5]>> then\n    show\nelse\n    hide\nend\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 (join (join (~costume.col_ID) [,]) (~costume.row_ID))\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 [name v]) = (~costume.target_ID)>> then\n        switch costume to (~costume.target_ID)\n        if <not <(costume [name v]) = (~costume.target_ID)>> then\n            switch costume to (null v)\n        end\n    end\nelse\n    hide\nend\n\nwhen I receive [change game state v]\nif <(~panel_set.row_ID) > [0]> then\n    if <(@game state) = [transition.to_game]> then\n        wait (0.1) seconds\n        scroll\n        show\n        go to [back v] layer\n    else\n        if < (@game state) contains [transition.to_]?> then\n            stop [other scripts in sprite v]\n            hide\n        end\n    end\nend\n\ndefine init\nhide\nset size to (100) %\nset [ghost v] effect to (50)\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 [~animation.timer v] to [0]\nclear graphic effects\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\n@portals\n\nwhen flag clicked\ninit [-285] [1725]\n\ndefine check_player_dist\nset [~portal.index v] to [-1]\nset [~portal.dist v] to (~portal.MAX_DIST)\nrepeat until <<(~portal.index) > ((length of [~locations v]) - (2))> or <(~portal.dist) < (~portal.MAX_DIST)>>\n    change [~portal.index v] by (2)\n    set [~portal.x v] to (item (~portal.index) of [~locations v])\n    set [~portal.y v] to (item ((~portal.index) + (1)) of [~locations v])\n    set [~portal.to_x v] to (item (~portal.index) of [~destinations v])\n    set [~portal.to_y v] to (item ((~portal.index) + (1)) of [~destinations v])\n    get_dist (~portal.x) (~portal.y) (([x position v] of [player hitbox v]) + (@camera x)) (([y position v] of [player hitbox v]) + (@camera y))\nend\n\ndefine get_dist (x1) (y1) (x2) (y2)\nset [~portal.dist v] to ([sqrt v] of ((((x1) - (x2)) * ((x1) - (x2))) + (((y1) - (y2)) * ((y1) - (y2)))) )\n\nwhen I receive [tick v]\ncheck_player_dist\ncheck teleport <(@Input.ACTION) = [true]> <(item (((~portal.index) + (1)) / (2)) of [~automatic? v]) = [1]>\n\ndefine add portal | x: (x) y: (y) to_x: (to_x) to_y: (to_y) automatic? (auto) 2-way? (2way) desc (d)\nadd (x) to [~locations v]\nadd (y) to [~locations v]\nadd (to_x) to [~destinations v]\nadd (to_y) to [~destinations v]\nadd (auto) to [~automatic? v]\nif <(2way) = [1]> then\n    add (to_x) to [~locations v]\n    add (to_y) to [~locations v]\n    add (x) to [~destinations v]\n    add (y) to [~destinations v]\n    add [0] to [~automatic? v]\nend\n\ndefine init (xmin) (xmax)\nhide\nset size to (100) %\ngo to x: (0) y: (0)\nshow list [~locations v]\nshow list [~destinations v]\nshow list [~automatic? v]\nset [~portal.max_dist v] to [50]\nset [ghost v] effect to (100)\ndelete all of [~locations v]\ndelete all of [~destinations v]\ndelete all of [~automatic? v]\nadd portal | x: [468] y: [5064] to_x: [480] to_y: [961] automatic? [0] 2-way? [1] desc [dojo]\nadd portal | x: [117] y: [602] to_x: [240] to_y: [4345] automatic? [0] 2-way? [1] desc [small house]\nadd portal | x: [484] y: [2460] to_x: [316] to_y: [2921] automatic? [0] 2-way? [1] desc [woods-pagoda tunnel]\nadd portal | x: [1410] y: [3] to_x: [1370] to_y: [5270] automatic? [0] 2-way? [1] desc [well tunnel]\nadd portal | x: (xmin) y: [1020] to_x: [1530] to_y: [2460] automatic? [1] 2-way? [0] desc [NW village to NE woods]\nadd portal | x: (xmax) y: [2460] to_x: [-130] to_y: [1020] automatic? [1] 2-way? [0] desc [NE woods to NW village]\nadd portal | x: (xmin) y: [580] to_x: [1530] to_y: [2020] automatic? [1] 2-way? [0] desc [SW village to SE woods]\nadd portal | x: (xmax) y: [2020] to_x: [-130] to_y: [580] automatic? [1] 2-way? [0] desc [SE woods to SW village]\nadd portal | x: (xmin) y: [60] to_x: [1570] to_y: [1500] automatic? [1] 2-way? [0] desc [well-pond secret tunnel]\nadd portal | x: (xmax) y: [1500] to_x: [-145] to_y: [60] automatic? [1] 2-way? [0] desc [pond-well secret tunnel]\nadd portal | x: (xmax) y: [660] to_x: [-105] to_y: [2100] automatic? [1] 2-way? [0] desc [E village to W woods]\nadd portal | x: (xmin) y: [2100] to_x: [1530] to_y: [660] automatic? [1] 2-way? [0] desc [W woods to E village]\nadd portal | x: (xmin) y: [1500] to_x: [1580] to_y: [4390] automatic? [1] 2-way? [0] desc [pond-cistern secret tunnel]\nadd portal | x: (xmax) y: [4390] to_x: [-150] to_y: [1500] automatic? [1] 2-way? [0] desc [cistern-pond secret tunnel]\n\ndefine check teleport <act_key> <automatic>\nif <(~is_teleporting?) = [1]> then\n    set [ghost v] effect to (0)\n    go to [front v] layer\n    set [~is_teleporting? v] to [0.5]\n    set [@player state v] to [go]\nelse\n    if <(~is_teleporting?) = [0.5]> then\n        wait (0.5) seconds\n        repeat (10)\n            go to [front v] layer\n            change [ghost v] effect by (10)\n        end\n        set [~is_teleporting? v] to [0]\n    else\n        if <(~portal.dist) < (~portal.MAX_DIST)> then\n            if <not <automatic>> then\n                set [@show icon v] to [1]\n            end\n            if <<act_key> or <automatic>> then\n                set [@player state v] to [pause]\n                set [~is_teleporting? v] to [1]\n                set [@checkpt_x v] to (~portal.to_x)\n                set [@checkpt_y v] to (~portal.to_y)\n                set [ghost v] effect to (100)\n                show\n                start sound [Disconnect v]\n                repeat (10)\n                    go to [front v] layer\n                    change [ghost v] effect by (-10)\n                end\n                set [@player.x v] to (~portal.to_x)\n                set [@player.y v] to (~portal.to_y)\n                set [@camera x v] to (~portal.to_x)\n                set [@camera y v] to (~portal.to_y)\n            end\n        end\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]\nset [~angle v] to [0]\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)\nswitch costume to (title v)\nshow\ngo to [front v] layer\ngo [backward v] (1) layers\nset size to (100) %\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 [change game state v]\nif <(@game state) = [transition.to_game]> then\n    stop [other scripts in sprite v]\n    go to x: (0) y: (0)\n    point in direction (90)\n    switch costume to (health3 v)\n    set size to (100) %\n    show\nelse\n    if <(@game state) = [game]> then\n        go to [front v] layer\n    else\n        if <<(@game state) = [transition.to_title]> or <(@game state) = [title]>> then\n            title | wiggle: (10) turn: (0.5) d_size (0.5) d_popup (1) x: (0) y: (50) size: (100)\n        else\n            stop [other scripts in sprite v]\n            if <(costume [name v]) = [title]> then\n                animate_out\n            else\n                hide\n            end\n        end\n    end\nend\n\ndefine animate_out\nrepeat (2)\n    set size to ((0.5) * (size)) %\nend\nhide\n\nwhen I receive [change player state v]\nif <(@player state) = [pause]> then\n    switch costume to (edit v)\n    go to [front v] layer\nend\n\nswitch costume to (title v)\nset size to (100) %\nswitch costume to (thumbnail v)\ngo to x: (0) y: (0)\npoint in direction (90)\nset rotation style [all around v]\nshow\ngo to [front v] layer\n\nwhen I receive [tick v]\nif <not <(@player state) = [pause]>> then\n    if <not <(costume [name v]) = (join [health] (@player.health))>> then\n        switch costume to (join [health] (@player.health))\n        go to [front v] layer\n    end\nend\n\n@leaderboard\n\nwhen flag clicked\nhide\nset [~leaderboard_max_rank v] to [5]\nset [~bounce_vel v] to [10]\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])> or <(item ((~i) + (1)) of [leaderboard v]) = [0]>> 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])> or <(item ((~i) + (1)) of [leaderboard v]) = [0]>> 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        repeat until <not <(length of [leaderboard v]) > ((~leaderboard_max_rank) * (2))>>\n            delete (length of [leaderboard v]) of [leaderboard v]\n        end\n        write_cloud_leaderboard\n        stop [this script v]\n    end\n    change [~i v] by (2)\nend\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\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        change x by ((item ((costume [number v]) - (1)) of [~font_widths v]) * ((size) / (100)))\n    else\n        switch costume to (. v)\n        repeat (3)\n            stamp\n            change x by ((item ((costume [number v]) - (1)) of [~font_widths v]) * ((size) / (100)))\n        end\n        stop [this script v]\n    end\nend\n\nwhen I receive [change game state v]\nif <(@game state) = [transition.to_title]> then\n    stop [other scripts in sprite v]\n    erase all\nelse\n    if <(@game state) = [leaderboard]> then\n        switch costume to (background v)\n        animate_in [0.5] [40] [110]\n        stamp\n        hide\n        print [Your score:] [-135] [-125] [80] [200] [25]\n        if <<(@player state) = [win]> and <(@score.time) > [0]>> then\n            update_leaderboard (username) (@score.time)\n            print (@score.time) [55] [-125] [80] [200] [200]\n        else\n            get_cloud_leaderboard\n            print [-] [55] [-125] [80] [200] [200]\n        end\n        set [~i v] to [0]\n        repeat (~leaderboard_max_rank)\n            change [~i v] by (1)\n            display_leader_entry (~i)\n        end\n    end\nend\n\nwhen [f v] key pressed\nif <(username) = [amylaser]> then\n    switch backdrop to (title v)\n    set_font_widths\n    erase all\n    print [Test 1234567890 quick, brown foxes jump - over the lazy_dog. Hello?!] [-200] [-125] [80] [200] [240]\nend\n\ndefine set_font_widths\ndelete all of [~font_widths v]\nswitch costume to (1 v)\nset size to (100) %\nset [brightness v] effect to (200)\nshow\ngo to [front v] layer\nrepeat until <(costume [name v]) = [space]>\n    erase all\n    go to x: (0) y: (-100)\n    stamp\n    repeat until <not <touching color (#ffffff)?>>\n        change x by (1)\n    end\n    change x by (2)\n    add (x position) to [~font_widths v]\n    next costume\nend\nadd [8] to [~font_widths v]\n\ndefine write_cloud_leaderboard\nencode_name&score (item (1) of [leaderboard v]) (item (2) of [leaderboard v])\nif <not <(☁ leader1) = (~temp)>> then\n    set [☁ leader1 v] to (~temp)\n    wait (0.1) seconds\nend\nencode_name&score (item (3) of [leaderboard v]) (item (4) of [leaderboard v])\nif <not <(☁ leader2) = (~temp)>> then\n    set [☁ leader2 v] to (~temp)\n    wait (0.1) seconds\nend\nencode_name&score (item (5) of [leaderboard v]) (item (6) of [leaderboard v])\nif <not <(☁ leader3) = (~temp)>> then\n    set [☁ leader3 v] to (~temp)\n    wait (0.1) seconds\nend\nencode_name&score (item (7) of [leaderboard v]) (item (8) of [leaderboard v])\nif <not <(☁ leader4) = (~temp)>> then\n    set [☁ leader4 v] to (~temp)\n    wait (0.1) seconds\nend\nencode_name&score (item (9) of [leaderboard v]) (item (10) of [leaderboard v])\nif <not <(☁ leader5) = (~temp)>> then\n    set [☁ leader5 v] to (~temp)\nend\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 [WitherCroxly] [82]\nupdate_leaderboard [goldbread] [82]\nupdate_leaderboard [BoysRUs] [94]\nupdate_leaderboard [2024hagfe14] [94]\nupdate_leaderboard [pizzaisawsome1] [95]\n\ndecode_leader_entry [1313406260522568604942665265131221] [1]\ndecode_leader_entry [1218236272663942662015] [2]\ndecode_leader_entry [131213211315554854535212152015] [3]\ndecode_leader_entry [131563567373485666487066626052122016] [4]\ndecode_leader_entry [131874742468495275226156604867626574742017] [5]\nwrite_cloud_leaderboard\n\nupdate_leaderboard [--Cube_Animator--] [96]\n\n@parallax\n\nwhen flag clicked\ninit\n\nwhen I receive [tick v]\nif <(~col_ID) > [0]> then\n    scroll\n    if <not <(costume [name v]) = (join [level] (@curr_level))>> then\n        switch costume to (join [level] (@curr_level))\n    end\nend\n\nwhen I receive [change game state v]\nif <<(@game state) = [transition.to_game]> or <(@game state) = [game]>> then\n    if <(~col_ID) > [0]> then\n        show\n        go to [back v] layer\n        wait (0.1) seconds\n        scroll\n    else\n        stop [other scripts in sprite v]\n        hide\n    end\nelse\n    if <<not < (@game state) contains [transition.target]?>> and << (@game state) contains [title]?> or < (@game state) contains [level_select]?>>> then\n        title_visuals\n    else\n        stop [other scripts in sprite v]\n        hide\n    end\nend\n\ndefine init\nhide\nswitch costume to (title v)\nset [brightness v] effect to (-10)\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\ndefine title_visuals\nif <(~col_ID) > [0]> then\n    hide\nelse\n    switch costume to (title 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\ndefine scroll\nset x to (((=panel_width) * ((~col_ID) - (1))) - (((=panel_width) / (=level_width_px)) * (@camera x)))\nset y to ((0) - (((=level_height_px) / (=map_height_px)) * ((@camera y) - (((@curr_level) * (=level_height_px)) - ((=panel_height) * (2))))))\n\n@transitions\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset size to (100) %\nhide\n\nwhen I receive [change game state v]\ncheck transition from [transition.target_game] to [transition.to_game] to [game]\ncheck transition from [transition.target_title] to [transition.to_title] to [title]\ncheck transition from [transition.target_leaderboard] to [transition.to_leaderboard] to [leaderboard]\n\ndefine fade in\nset [ghost v] effect to (100)\nshow\nrepeat (10)\n    go to [front v] layer\n    change [ghost v] effect by (-10)\nend\n\ndefine fade out\nset [ghost v] effect to (0)\nshow\nrepeat (10)\n    go to [front v] layer\n    change [ghost v] effect by (10)\nend\nhide\n\ndefine check transition from (start) to (bridge) to (end)\nif <(@game state) = (start)> then\n    fade in\n    set [@game state v] to (bridge)\n    broadcast (change game state v)\nelse\n    if <(@game state) = (bridge)> then\n        wait (1) seconds\n        fade out\n        set [@game state v] to (end)\n        broadcast (change game state v)\n    end\nend\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\nset [@game state v] to [transition.target_title]\nbroadcast (change game state v)\nfade [-1] [10]\nhide\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\nwhen flag clicked\n\nset [@game state v] to [transition.target_title]\nbroadcast (change game state v)\n\n
My first game. I hope that you like it!   :)\nPlease leave a love or a favorite if you enjoyed!\n                                 \n                            || INSTRUCTIONS ||\n   Use the arrow keys to move. Up arrow to jump, right arrow to move right, and left arrow to move left. The goal of the game is to get to the end. \nAvoid all the red / lava. Green, light blue,and pink are portals. They might be helpful . . . or harmful.