Skyscraper (Platformer)

Instructions: The ol' boss has been taken to the top of the unfinished skyscraper by evil bugs. You need to help him!\n\nControls:\n• Arrow Keys to move\n• Up and Down Arrow Keys for ladder movement\n• Up arrow to jump

@Stage\n\nwhen flag clicked\nset [hitboxghost v] to [100]\nswitch backdrop to (titlescreen v)\nwait (3) seconds\nforever\n    if <(Level) < [5]> then\n        switch backdrop to (backdrop1 v)\n    end\n    if <<(Level) = [5]> or <(Level) = [6]>> then\n        switch backdrop to (backdrop2 v)\n    end\n    if <(Level) > [6]> then\n        switch backdrop to (backdrop3 v)\n    end\nend\n\nwhen [z v] key pressed\nrepeat until <not <key (z v) pressed?>>\n    show variable [level v]\n    show variable [musicsector v]\n    show variable [hitboxghost v]\n    show variable [playeryvel v]\n    show variable [cutscene v]\nend\nhide variable [level v]\nhide variable [musicsector v]\nhide variable [playeryvel v]\nhide variable [cutscene v]\nhide variable [hitboxghost v]\n\nwhen flag clicked\nhide variable [☁ besttime v]\nhide variable [☁ mostdeaths v]\nhide variable [☁ bestscore v]\nhide variable [yourtime v]\nhide variable [yourdeaths v]\nhide variable [yourscore v]\nset [yourdeaths v] to [0]\nset [yourscore v] to [0]\nset [yourtime v] to [0]\nset [deaths v] to [0]\nwait (2) seconds\nrepeat until <(CutScene) = [3]>\n    set [yourtime v] to (round (timer))\n    set [yourdeaths v] to (Deaths)\n    set [yourscore v] to (((1000) - (YourTime)) - ((YourDeaths) * (5)))\n    if <(Timer) = [0]> then\n        broadcast (TryAgain v)\n    end\nend\nif <<(☁ BestTime) > [0]> and <(YourTime) < (☁ BestTime)>> then\n    set [☁ besttime v] to (YourTime)\nend\nif <<(☁ MostDeaths) > [0]> and <(☁ MostDeaths) < (YourDeaths)>> then\n    set [☁ mostdeaths v] to (YourDeaths)\nend\nif <<(☁ BestScore) > [0]> and <(☁ BestScore) < (YourScore)>> then\n    set [☁ bestscore v] to (YourScore)\nend\n\nwhen flag clicked\nwait (1) seconds\nwait until <(CutScene) = [0]>\nset [musicsector v] to [1]\nset [prevmusicsector v] to [1]\nrepeat until <not <(CutScene) = [0]>>\n    set [prevmusicsector v] to (MusicSector)\n    broadcast (MusicReset v)\n    if <(MusicSector) = [1]> then\n        start sound [underground-super-mario-world-edit v]\n    end\n    if <(MusicSector) = [2]> then\n        start sound [3-26 Vah Ruta v]\n    end\n    if <(MusicSector) = [3]> then\n        start sound [239-ice-mountain v]\n    end\n    if <(MusicSector) = [4]> then\n        start sound [204-capture-the-grand-star v]\n    end\n    wait until <not <(MusicSector) = (PrevMusicSector)>>\n    stop all sounds\nend\n\nwhen flag clicked\nforever\n    if <not <(CutScene) = [0]>> then\n        set [musicsector v] to [0]\n    else\n        if <<(Level) = [1]> or <(Level) = [2]>> then\n            set [musicsector v] to [1]\n        end\n        if <<<(Level) = [3]> or <(Level) = [4]>> or <<<(Level) = [5]> or <(Level) = [6]>> or <<(Level) = [7]> or <(Level) = [8]>>>> then\n            set [musicsector v] to [2]\n        end\n        if <<(Level) = [9]> or <(Level) = [10]>> then\n            set [musicsector v] to [3]\n        end\n        if <(Level) > [10]> then\n            set [musicsector v] to [4]\n        end\n    end\nend\n\nwhen I receive [musicreset v]\nset [musictimer v] to [0]\n\nwhen flag clicked\nset [musictimer v] to [0]\nrepeat until <(CutScene) = [2]>\n    wait (1) seconds\n    change [musictimer v] by (1)\n    if <<(MusicTimer) > [48]> and <(MusicSector) = [1]>> then\n        set [prevmusicsector v] to [-1]\n    end\n    if <<(MusicTimer) > [210]> and <(MusicSector) = [2]>> then\n        set [prevmusicsector v] to [-1]\n    end\n    if <<(MusicTimer) > [88]> and <(MusicSector) = [3]>> then\n        set [prevmusicsector v] to [-1]\n    end\n    if <<(MusicTimer) > [32]> and <(MusicSector) = [4]>> then\n        set [prevmusicsector v] to [-1]\n    end\nend\n\n@Sprite1\n\n@Worker\n\ndefine TouchGround <up?>\nchange [air v] by (1)\nswitch costume to (hitbox v)\nrepeat until <not <<touching (ground v)?> or <touching (specialground v)?>>>\n    if <up?> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [air v] to [0]\n    end\n    set [playeryvel v] to [0]\n    if <<touching (ladder v)?> and <key (up arrow v) pressed?>> then\n        change y by (-2)\n    end\nend\nswitch costume to (right v)\n\nwhen flag clicked\nforever\n    if <<(x position) > [240]> and <<<(Level) = [1]> or <(Level) = [3]>> or <<(Level) = [5]> or <<(Level) = [7]> or <(Level) = [9]>>>>> then\n        broadcast (loadstage v)\n        set x to (-238)\n        set [level v] to ((Level) + (1))\n    end\n    if <<(x position) < [-240]> and <<<(Level) = [2]> or <(Level) = [4]>> or <<(Level) = [6]> or <<(Level) = [8]> or <(Level) = [10]>>>>> then\n        broadcast (loadstage v)\n        set x to (238)\n        set [level v] to ((Level) - (1))\n    end\n    if <(y position) > [182]> then\n        broadcast (loadstage v)\n        set [level v] to ((Level) + (2))\n        hide\n        wait (0.1) seconds\n        set y to (-170)\n        show\n    end\n    if <(y position) < [-182]> then\n        broadcast (loadstage v)\n        set [level v] to ((Level) - (2))\n        hide\n        wait (0.1) seconds\n        set y to (170)\n        show\n    end\n    if <(Level) = [14]> then\n        set [level v] to [10]\n        go to x: (-160) y: (90)\n        broadcast (loadstage v)\n    end\nend\n\ndefine Walk (direction) (speed)\npoint in direction (direction)\nchange x by (speed)\nset [slope v] to [0]\nrepeat until <<(Slope) = [8]> or <not <<touching (ground v)?> or <touching (specialground v)?>>>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <(Slope) = [8]> then\n    change y by ((0) - (Slope))\n    change x by ((0) - (speed))\nend\n\nwhen flag clicked\nforever\n    if <touching (ladder v)?> then\n        repeat until <not <touching (ladder v)?>>\n            set [playeryvel v] to [0]\n            if <key (up arrow v) pressed?> then\n                change y by (5)\n            end\n            if <key (down arrow v) pressed?> then\n                change y by (-5)\n            end\n        end\n    end\nend\n\nwhen flag clicked\nset size to (30) %\ngo to [front v] layer\ngo [backward v] (2) layers\nhide\nwait (3.5) seconds\nshow\nset rotation style [left-right v]\nif <not <(backdrop [name v]) = [TitleScreen]>> then\n    show\nend\nset [playeryvel v] to [0]\nforever\n    if <(CutScene) = [0]> then\n        if <<(PlayerYVel) < [4]> or <key (up arrow v) pressed?>> then\n            change [playeryvel v] by (-1)\n        else\n            change [playeryvel v] by (-1.5)\n        end\n    end\n    change y by (PlayerYVel)\n    TouchGround <(PlayerYVel) > [0]>\n    TouchDeath\nend\n\nwhen I receive [message1 v]\nwait (0) seconds\nchange y by ((10) - (PlayerYVel))\n\nwhen [up arrow v] key pressed\nif <<(Air) < [3]> and <(CutScene) = [0]>> then\n    if <touching (ladder v)?> then\n        set [playeryvel v] to [0]\n    else\n        set [playeryvel v] to [15]\n    end\nend\n\nwhen [left arrow v] key pressed\nrepeat until <not <key (left arrow v) pressed?>>\n    if <(CutScene) = [0]> then\n        Walk (-90) (-5)\n    end\nend\n\ndefine TouchDeath\nif <<touching (bug v)?> or <touching (lock v)?>> then\n    set [prevmusicsector v] to (MusicSector)\n    change [deaths v] by (1)\n    broadcast (Death v)\n    broadcast (loadstage v)\nend\n\nwhen [right arrow v] key pressed\nrepeat until <not <key (right arrow v) pressed?>>\n    if <(CutScene) = [0]> then\n        Walk (90) (5)\n    end\nend\n\nwhen flag clicked\ngo to [front v] layer\ngo [backward v] (1) layers\nset rotation style [left-right v]\nswitch costume to (right v)\n\nwhen flag clicked\nset [level v] to [2]\npoint in direction (90)\ngo to x: (-150) y: (-60)\nset [oldcpl v] to [2]\nset [newcpl v] to [2]\nset [oldcpx v] to [-150]\nset [newcpx v] to [-150]\nset [oldcpy v] to [-60]\nset [newcpy v] to [-60]\n\nwhen I receive [loadstage v]\nwait until <([abs v] of (PlayerYVel) ) < [1]>\nset [oldcpl v] to (NewCPL)\nset [newcpl v] to (Level)\nset [oldcpx v] to (NewCPX)\nset [newcpx v] to (x position)\nset [oldcpy v] to (NewCPY)\nset [newcpy v] to (y position)\n\nwhen I receive [death v]\nset [level v] to (OldCPL)\ngo to x: (OldCPX) y: (OldCPY)\n\nwhen [d v] key pressed\nbroadcast (Death v)\nbroadcast (loadstage v)\n\nwhen I receive [unlockedcutscene v]\ndelete all of [pastpos v]\nwait (2) seconds\nrepeat (10)\n    add (x position) to [pastpos v]\n    add (y position) to [pastpos v]\n    add (Level) to [pastpos v]\nend\nforever\n    delete (1) of [pastpos v]\n    delete (1) of [pastpos v]\n    delete (1) of [pastpos v]\n    add (x position) to [pastpos v]\n    add (y position) to [pastpos v]\n    add (Level) to [pastpos v]\n    wait (0.02) seconds\nend\n\n@Level\n\nwhen flag clicked\ngo to x: (0) y: (0)\ngo to [back v] layer\nforever\n    switch costume to (Level)\nend\n\nset [level v] to [3]\n\nwhen I receive [unlockedcutscene v]\nwait (2) seconds\nforever\n    go to x: (pick random (-3) to (3)) y: (pick random (-3) to (3))\nend\n\n@Ground\n\nwhen flag clicked\nforever\n    switch costume to (Level)\n    set [ghost v] effect to (HitBoxGhost)\nend\n\n@SpecialGround\n\nwhen flag clicked\nforever\n    go to x: (-30) y: (120)\n    point in direction (((30) * ([cos v] of ((timer) / (0.01)) )) - (-90))\n    if <(Level) = [6]> then\n        switch costume to (Level)\n    else\n        switch costume to (1 v)\n    end\nend\n\n@Ladder\n\nwhen flag clicked\ngo to x: (0) y: (0)\nforever\n    set [ghost v] effect to (HitBoxGhost)\n    switch costume to (Level)\nend\n\n@Lock\n\nwhen flag clicked\nforever\n    next costume\n    wait (0.03) seconds\n    if <<(Level) = [10]> and <(length of [toolsleft v]) > [0]>> then\n        show\n        set [disttolock v] to (distance to [worker v])\n    else\n        set [disttolock v] to [300]\n        hide\n    end\nend\n\n@Clouds\n\nwhen flag clicked\nhide\nrepeat (6)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nset size to (pick random (70) to (170)) %\ngo to x: (pick random (-120) to (120)) y: (pick random (-150) to (150))\nset [ghost v] effect to (60)\nforever\n    move (pick random (-2) to (2)) steps\n    wait (0.5) seconds\n    if <(Level) > [8]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen I receive [loadstage v]\ngo to x: (pick random (-120) to (120)) y: (pick random (-150) to (150))\n\n@Chains\n\nwhen flag clicked\nforever\n    go to x: (-30) y: (120)\n    point in direction (((30) * ([cos v] of ((timer) / (0.01)) )) - (-90))\n    if <(Level) = [6]> then\n        show\n    else\n        hide\n    end\nend\n\n@Cage\n\nwhen flag clicked\nhide\nswitch costume to (closed v)\ngo to [front v] layer\ngo [backward v] (4) layers\nset size to (75) %\ngo to x: (30) y: (-110)\nforever\n    if <(Level) = [12]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen I receive [unlockedcutscene v]\nswitch costume to (open v)\ngo [backward v] (2) layers\n\n@Key\n\nwhen flag clicked\nset [keycollected v] to [0]\nset rotation style [all around v]\ngo to x: (-160) y: (98)\nset size to (30) %\nrepeat until <touching (worker v)?>\n    if <(Level) = [12]> then\n        show\n    else\n        hide\n    end\n    point in direction (((15) * ([cos v] of ((timer) / (0.01)) )) - (-90))\nend\nset [keycollected v] to [1]\nrepeat (25)\n    turn right (15) degrees\n    wait (0) seconds\n    change [ghost v] effect by (4)\nend\nhide\nbroadcast (UnlockedCutscene v)\n\n@Cutscene\n\nwhen flag clicked\ngo to x: (0) y: (0)\nshow\nset [cutscene v] to [1]\nstart sound [1-34 Impa's Story v]\ngo to [front v] layer\nswitch costume to (intro v)\nwait (6) seconds\nswitch costume to (intro2 v)\nwait (5.5) seconds\nstop all sounds\nset [cutscene v] to [0]\nrepeat (20)\n    change [ghost v] effect by (5)\n    wait (0.05) seconds\nend\nhide\nset [ghost v] effect to (0)\n\nwhen I receive [unlockedcutscene v]\nset [cutscene v] to [2]\nswitch costume to (freed v)\nset [ghost v] effect to (100)\nshow\nwait (0.2) seconds\nstart sound [1-41 Watch Out for the Flowers v]\nrepeat (20)\n    change [ghost v] effect by (-5)\n    wait (0.02) seconds\nend\nset [ghost v] effect to (0)\nwait (5) seconds\nswitch costume to (button1 v)\nwait (0.15) seconds\nswitch costume to (button2 v)\nwait (0.15) seconds\nswitch costume to (button3 v)\nwait (0.15) seconds\nswitch costume to (button4 v)\nwait (0.15) seconds\nswitch costume to (button5 v)\nwait (0.8) seconds\nswitch costume to (warn v)\nwait (5) seconds\nset [cutscene v] to [0]\nbroadcast (StartTimer v)\nrepeat (20)\n    change [ghost v] effect by (5)\n    wait (0.02) seconds\nend\nset [ghost v] effect to (0)\nhide\n\nwhen flag clicked\nrepeat until <(CutScene) = [3]>\n    go to [front v] layer\nend\n\nwhen I receive [wincutscene v]\nswitch costume to (white v)\nset [cutscene v] to [3]\nstop all sounds\nstart sound [Demolition of Storms and Knapp Hall2 v]\ngo to [front v] layer\nshow\nwait (0.5) seconds\nrepeat (6)\n    switch costume to (towerdown1 v)\n    wait (0.04) seconds\n    repeat (9)\n        next costume\n        wait (0.04) seconds\n    end\nend\ngo to [front v] layer\nswitch costume to (black v)\nwait (4) seconds\nstop all sounds\nstart sound [1-04 Bonneton v]\nswitch costume to (thanks1 v)\nwait (5.5) seconds\nswitch costume to (thanks2 v)\nwait (6) seconds\nswitch costume to (endscreen v)\nwait (1) seconds\nshow variable [yourtime v]\nif <(☁ BestTime) > [0]> then\n    wait (1) seconds\n    show variable [☁ besttime v]\nend\nwait (1) seconds\nshow variable [yourdeaths v]\nif <(☁ MostDeaths) > [0]> then\n    wait (1) seconds\n    show variable [☁ mostdeaths v]\nend\nwait (1) seconds\nshow variable [yourscore v]\nif <(☁ BestScore) > [0]> then\n    wait (2.5) seconds\n    show variable [☁ bestscore v]\nend\n\nwhen I receive [starttimer v]\nset [musicsector v] to [0]\nstop all sounds\nwait (0.3) seconds\nstart sound [Enter Bowser Jr.  v]\nforever\n    set [musicsector v] to [0]\nend\n\nwhen I receive [tryagain v]\nstop all sounds\n\n@Exit\n\nwhen flag clicked\nhide\n\nwhen I receive [unlockedcutscene v]\nset y to (-95)\nrepeat until <touching (worker v)?>\n    if <(Level) = [3]> then\n        set x to (((2) * ([cos v] of ((timer) / (0.002)) )) - (202))\n        show\n    end\n    if <(Level) = [4]> then\n        set x to (((2) * ([cos v] of ((timer) / (0.002)) )) - (-202))\n        show\n    end\n    if <<(Level) > [4]> or <(Level) < [3]>> then\n        hide\n    end\nend\nbroadcast (WinCutscene v)\n\n@Bug\n\nwhen flag clicked\nset size to (40) %\nforever\n    wait (0) seconds\n    next costume\n    set y to (((8) * ([cos v] of ((timer) / (0.004)) )) - (0))\n    set x to (((20) * ([cos v] of ((timer) / (0.015)) )) - (0))\n    if <<<<(Level) = [6]> or <(Level) = [7]>> or <<(Level) = [10]> or <(Level) = [12]>>> or <<(Level) = [8]> and <(KeyCollected) = [1]>>> then\n        show\n    else\n        hide\n    end\n    if <(Level) = [6]> then\n        change x by (20)\n        change y by (-50)\n    end\n    if <(Level) = [7]> then\n        change x by (-70)\n        change y by (45)\n    end\n    if <(Level) = [10]> then\n        change x by (5)\n        change y by (-70)\n    end\n    if <(Level) = [8]> then\n        change x by (160)\n        change y by (-80)\n    end\n    point towards (worker v)\n    set rotation style [left-right v]\n    turn right (180) degrees\nend\n\nset x to (0)\n\n@Tool\n\nwhen flag clicked\nhide\ndelete all of [toolsleft v]\nadd [1] to [toolsleft v]\nadd [5] to [toolsleft v]\nadd [6] to [toolsleft v]\nadd [7] to [toolsleft v]\nadd [8] to [toolsleft v]\nadd [9] to [toolsleft v]\nset size to (30) %\nforever\n    hide\n    if <<(Level) = [1]> and <[toolsleft v] contains (Level)?>> then\n        switch costume to (screwdriver v)\n        go to x: (25) y: (85)\n        show\n    end\n    if <<(Level) = [5]> and <[toolsleft v] contains (Level)?>> then\n        switch costume to (screwdriver v)\n        go to x: (-200) y: (40)\n        show\n    end\n    if <<(Level) = [6]> and <[toolsleft v] contains (Level)?>> then\n        switch costume to (hammer v)\n        go to x: (90) y: (-10)\n        show\n    end\n    if <<(Level) = [7]> and <[toolsleft v] contains (Level)?>> then\n        switch costume to (hammer v)\n        go to x: (-70) y: (-165)\n        show\n    end\n    if <<(Level) = [8]> and <[toolsleft v] contains (Level)?>> then\n        switch costume to (screwdriver v)\n        go to x: (160) y: (-50)\n        show\n    end\n    if <<(Level) = [9]> and <[toolsleft v] contains (Level)?>> then\n        switch costume to (hammer v)\n        go to x: (25) y: (-100)\n        show\n    end\n    if <not <<<(Level) = [1]> or <<(Level) = [5]> or <(Level) = [6]>>> or <<<(Level) = [7]> or <(Level) = [8]>> or <(Level) = [9]>>>> then\n        hide\n    end\n    point in direction (((15) * ([cos v] of ((timer) / (0.006)) )) - (-90))\n    if <touching (worker v)?> then\n        broadcast (ToolGet v) and wait\n    end\n    set [ghost v] effect to (0)\nend\n\nwhen I receive [toolget v]\ndelete (item # of (Level) in [toolsleft v]) of [toolsleft v]\nrepeat (20)\n    turn right (15) degrees\n    wait (0) seconds\n    change [ghost v] effect by (5)\nend\nhide\n\n@Hostage\n\nwhen flag clicked\nhide\nset size to (30) %\ngo to [back v] layer\ngo [forward v] (4) layers\nset rotation style [left-right v]\n\nwhen I receive [unlockedcutscene v]\nwait (2) seconds\nshow\nforever\n    if <(Level) = (item (3) of [pastpos v])> then\n        show\n    else\n        hide\n    end\n    point towards (worker v)\n    glide (0.02) secs to x: (item (1) of [pastpos v]) y: (item (2) of [pastpos v])\nend\n\n@Textbox\n\nwhen flag clicked\nhide\nset [disttolock v] to [300]\ngo to [front v] layer\nset [ghost v] effect to (10)\ngo to x: (0) y: (0)\nforever\n    if <(DistToLock) < [85]> then\n        show\n    else\n        hide\n    end\nend\n\nwhen I receive [loadstage v]\nrepeat (10)\n    hide\nend\n\n@Countdown\n\nwhen flag clicked\nhide\nset size to (40) %\ngo to x: (0) y: (130)\ngo to [front v] layer\nset [timer v] to [17]\nswitch costume to (17 v)\nset [ghost v] effect to (40)\nforever\n    switch costume to (Timer)\n    if <(Timer) = [0]> then\n        broadcast (TryAgain v)\n    end\nend\n\nwhen I receive [starttimer v]\nset [timer v] to [17]\nshow\nrepeat until <<(CutScene) = [3]> or <(Timer) = [0]>>\n    if <(Timer) < [6]> then\n        set size to (100) %\n        go to x: (0) y: (0)\n    else\n        set size to (40) %\n        go to x: (0) y: (130)\n    end\n    wait (1) seconds\n    change [timer v] by (-1)\nend\nhide\n\nwhen I receive [tryagain v]\nset [timer v] to [17]\nset [oldcpl v] to [12]\nset [oldcpx v] to [-160]\nset [oldcpy v] to [95]\nset [newcpl v] to [12]\nset [newcpx v] to [-160]\nset [newcpy v] to [95]\nbroadcast (Death v)\nbroadcast (StartTimer v)\n\n