Platformer Powerups


@Stage\n\nwhen flag clicked\nforever\n    if <([costume # v] of [text v]) = [5]> then\n        switch backdrop to (backdrop2 v)\n    else\n        switch backdrop to (backdrop1 v)\n    end\nend\n\nwhen flag clicked\nforever\n    play sound [Coldplay - Paradise \(Official Video\) v] until done\nend\n\n@Intro\n\nswitch costume to (costume1 v)\nforever\n    if <(Level) = [3]> then\n        go to x: (0) y: (0)\n        show\n    else\n        hide\n    end\nend\n\nforever\n    if <touching (1. spring v)?> then\n        set [speed y v] to [28]\n        broadcast (Bounce v)\n        wait until <not <touching (1. spring v)?>>\n    end\nend\n\nforever\n    if <touching (2. speed v)?> then\n        set [speed x v] to ((speed x) * (20))\n        broadcast (Speed v)\n        wait until <not <touching (2. speed v)?>>\n    end\nend\n\nforever\n    if <touching (3. water v)?> then\n        set [speed y v] to ((speed y) / (2))\n        if <key (up arrow v) pressed?> then\n            change [speed y v] by (3)\n        end\n    end\nend\n\nswitch costume to (costume1 v)\nforever\n    go to (character v)\n    go to [back v] layer\n    show\nend\n\nforever\n    if <<touching (ground v)?> or <touching (5. door v)?>> then\n        set [touch v] to [9]\n    else\n        set [touch v] to [0]\n    end\nend\n\nforever\n    if <touching (5. key v)?> then\n        broadcast (Unlock v)\n    end\nend\n\nwhen I receive [unlock v]\nhide\n\nswitch costume to (costume1 v)\nforever\n    if <(Level) = [2]> then\n        go to x: (0) y: (0)\n        show\n    else\n        hide\n    end\nend\n\nforever\n    if <mouse down?> then\n        go to (mouse-pointer v)\n        set pen color to (#218cd0)\n        pen down\n    else\n        pen up\n    end\nend\n\nwhen [space v] key pressed\n\nforever\n    if <touching color (#3373c3)?> then\n        set [touch v] to [9]\n    else\n        set [touch v] to [0]\n    end\nend\n\nforever\n    if <touching (7. shield v)?> then\n        if <(Shield) = [n]> then\n            broadcast (Shield v)\n            set [7. shield v] to [y]\n        end\n    end\nend\n\nforever\n    if <<touching (7. spikes v)?> or <touching (8. enemies v)?>> then\n        if <<(Shield) = [y]> and <key (z v) pressed?>> then\n    end\nend\n\nforever\n    if <touching (8. sword v)?> then\n        if <(Sword) = [n]> then\n            broadcast (Sword v)\n            set [sword v] to [y]\n        end\n    end\nend\n\nerase all\n\nforever\n    if <touching (9. ladder v)?> then\n        if <key (up arrow v) pressed?> then\n            change [speed y v] by (0.7)\n        end\n    end\nend\n\ndefine Get Touching <check platform?>\nif <<touching (ground v)?> or <touching (5. door v)?>> then\n    set [touch v] to [9]\nelse\n    if <<check platform?> and <touching (platforms v)?>> then\n        set [touch v] to [1]\n    else\n        set [touch v] to [0]\n    end\nend\n\n@Character\n\ndefine Controls - Left and Right\nset [speed x v] to ((speed x) * (0.7))\nif <key (left arrow v) pressed?> then\n    change [speed x v] by (-1.5)\nend\nif <key (right arrow v) pressed?> then\n    change [speed x v] by (1.5)\nend\n\ndefine Walk (direction) (speed) max steep (max steep)\npoint in direction (direction)\nchange x by (speed)\nchange [frame v] by (([abs v] of (speed) ) / (8))\nset [slope v] to [0]\nGet Touching <(in platforrm) = [1]>\nrepeat until <<(slope) = (max steep)> or <(touch) = [0]>>\n    change y by (1)\n    change [slope v] by (1)\n    Get Touching <(in platforrm) = [1]>\nend\nif <(slope) = (max steep)> then\n    change x by ((0) - (speed))\n    change y by ((0) - (slope))\n    if <<(touch) = [1]> and <(in platforrm) = [1]>> then\n        set [in platforrm v] to [2]\n        Walk (direction) (speed) max steep (max steep)\n        if <(speed x) = [0]> then\n            set [in platforrm v] to [1]\n        end\n    else\n        if <<<key (up arrow v) pressed?> and <([abs v] of (speed) ) > [3.5]>> and <(touch) > [1]>> then\n            set [speed x v] to ((-1.2) * (speed))\n            set [speed y v] to [11]\n            set [falling? v] to [6]\n            set [wall jump v] to [15]\n        else\n            set [speed x v] to [0]\n        end\n    end\nend\n\ndefine Controls - Jump, Crouch\nif <key (up arrow v) pressed?> then\n    if <<(jump key) = [0]> and <(falling?) < [3]>> then\n        set [speed y v] to [14]\n        set [falling? v] to [6]\n        set [jump key v] to [1]\n    end\nelse\n    set [jump key v] to [0]\nend\nif <key (down arrow v) pressed?> then\n    set [in platforrm v] to [2]\nend\n\ndefine Gravity\nif <<(speed y) < [4]> or <key (up arrow v) pressed?>> then\n    change [speed y v] by (-1)\nelse\n    change [speed y v] by (-2)\nend\nchange y by (speed y)\nchange [falling? v] by (1)\n\ndefine Check Hit Ceiling / Floor <up?>\nGet Touching \nif <(touch) = [0]> then\n    set [in platforrm v] to [1]\nelse\n    if <<up?> and <(touch) = [1]>> then\n        set [in platforrm v] to [2]\n    end\nend\nrepeat until <(touch) < (in platforrm)>\n    if <up?> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling? v] to [0]\n    end\n    Get Touching <not <up?>>\n    set [speed y v] to [0]\nend\n\ndefine Reset Level\nset size to (100) %\nset rotation style [left-right v]\ngo to x: (-146) y: (200)\nreset timer\nshow\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [falling? v] to [10]\nset [in platforrm v] to [1]\nset [frame v] to [0]\nset [wall jump v] to [0]\n\ndefine Set Costume\nif <(falling?) < [6]> then\n    if <(frame) = [0]> then\n        switch costume to (stand_1 v)\n    else\n        switch costume to ([floor v] of ((4) + ((frame) mod (8))) )\n    end\nelse\n    if <(speed y) > [0]> then\n        switch costume to (jump_1 v)\n    else\n        switch costume to (fall_1 v)\n    end\nend\n\nwhen flag clicked\nReset Level\nforever\n    switch costume to (hitbox v)\n    Controls - Jump, Crouch\n    Gravity\n    Check Hit Ceiling / Floor <(speed y) > [0]>\n    if <(y position) < [-189]> then\n        Reset Level\n    end\n    if <(wall jump) > [0]> then\n        change [wall jump v] by (-1)\n    else\n        Controls - Left and Right\n    end\n    if <(speed x) < [-0.5]> then\n        Walk (-90) (speed x) max steep (([ceiling v] of ([abs v] of ((speed x) * (1.3)) ) ) + (1))\n    else\n        if <(speed x) > [0.5]> then\n            Walk (90) (speed x) max steep (([ceiling v] of ([abs v] of ((speed x) * (1.3)) ) ) + (1))\n        else\n            set [frame v] to [0]\n        end\n    end\n    Set Costume\n    broadcast (tick v) and wait\nend\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    if <[-175] > (y position)> then\n        Reset Level\n        broadcast (Reset v)\n    end\n    if <<touching (7. spikes v)?> or <touching (8. enemies v)?>> then\n        if <<(Shield) = [y]> and <key (z v) pressed?>> then\n    end\nend\n\nwhen flag clicked\nset [level v] to [1]\nforever\n    if <touching (portal v)?> then\n        if <(Level) = [11]> then\n            Reset Level\n            set [level v] to [1]\n            broadcast (Restart v)\n        else\n            Reset Level\n            change [level v] by (1)\n            broadcast (Next Level v)\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (5. key v)?> then\n        broadcast (Unlock v)\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (7. shield v)?> then\n        if <(Shield) = [n]> then\n            broadcast (Shield v)\n            set [shield v] to [y]\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (8. sword v)?> then\n        if <(Sword) = [n]> then\n            broadcast (Sword v)\n            set [sword v] to [y]\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (9. ladder v)?> then\n        if <key (up arrow v) pressed?> then\n            change [speed y v] by (0.7)\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (3. water v)?> then\n        set [speed y v] to ((speed y) / (2))\n        if <key (up arrow v) pressed?> then\n            change [speed y v] by (3)\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (2. speed v)?> then\n        set [speed x v] to ((speed x) * (20))\n        broadcast (Speed v)\n        wait until <not <touching (2. speed v)?>>\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (1. spring v)?> then\n        set [speed y v] to [28]\n        broadcast (Bounce v)\n        wait until <not <touching (1. spring v)?>>\n    end\nend\n\ndefine Get Touching <check platform?>\nif <<<touching (ground v)?> or <touching color (#208cd0)?>> or <touching (5. door v)?>> then\n    set [touch v] to [9]\nelse\n    if <<check platform?> and <touching (platforms v)?>> then\n        set [touch v] to [1]\n    else\n        set [touch v] to [0]\n    end\nend\n\n@Ground\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nwhen I receive [next level v]\nnext costume\n\nwhen I receive [restart v]\nswitch costume to (costume1 v)\n\n@Text\n\nwhen flag clicked\nswitch costume to (intro v)\n\nwhen I receive [next level v]\nnext costume\n\nwhen I receive [restart v]\nswitch costume to (intro v)\n\n@Portal\n\nwhen flag clicked\ngo to x: (214) y: (-99)\nforever\n    set [ghost v] effect to (Ghost)\nend\n\ndefine Ghost Effect\nset [ghost v] to [0]\nforever\n    repeat (40)\n        change [ghost v] by (2)\n    end\n    repeat (40)\n        change [ghost v] by (-2)\n    end\nend\n\nwhen flag clicked\nGhost Effect\n\nwhen flag clicked\nforever\n    glide (1) secs to x: (214) y: ((y position) + (10))\n    glide (1) secs to x: (214) y: ((y position) - (10))\nend\n\n@1. Spring\n\nwhen I receive [bounce v]\nswitch costume to (costume1 v)\nrepeat (4)\n    next costume\nend\nrepeat (4)\n    switch costume to ((costume [number v]) - (1))\nend\n\nwhen flag clicked\nswitch costume to (costume1 v)\nforever\n    if <(Level) = [2]> then\n        go to x: (0) y: (0)\n        show\n    else\n        hide\n    end\nend\n\n@2. Speed\n\nwhen I receive [speed v]\nswitch costume to (costume1 v)\nrepeat (4)\n    change [brightness v] effect by (10)\nend\nrepeat (4)\n    change [brightness v] effect by (-10)\nend\n\nwhen flag clicked\nswitch costume to (costume1 v)\nforever\n    if <(Level) = [3]> then\n        go to x: (0) y: (0)\n        show\n    else\n        hide\n    end\nend\n\n@3. Water\n\nwhen flag clicked\nswitch costume to (costume1 v)\nforever\n    if <(Level) = [4]> then\n        go to x: (0) y: (0)\n        go to [back v] layer\n        show\n    else\n        hide\n    end\nend\n\n@4.  Darkness\n\ngo to x: (0) y: (0)\n\nwhen flag clicked\nswitch costume to (costume1 v)\nforever\n    if <(Level) = [5]> then\n        go to (character v)\n        go to [back v] layer\n        show\n    else\n        hide\n    end\nend\n\n@5. Key\n\nwhen flag clicked\nforever\n    repeat (20)\n        change y by (1)\n    end\n    wait (0.1) seconds\n    repeat (20)\n        change y by (-1)\n    end\n    wait (0.1) seconds\nend\n\nwhen I receive [next level v]\nif <(Level) = [6]> then\n    show\nend\n\nwhen I receive [unlock v]\nhide\n\nwhen I receive [reset v]\nif <(Level) = [6]> then\n    show\nend\n\nwhen flag clicked\nhide\nclear graphic effects\nswitch costume to (costume1 v)\ngo to x: (0) y: (0)\n\n@5. Door\n\nwhen I receive [reset v]\nif <(Level) = [6]> then\n    show\nend\n\nwhen I receive [next level v]\nif <(Level) = [6]> then\n    show\nend\n\nwhen I receive [unlock v]\nhide\n\nwhen flag clicked\nswitch costume to (costume1 v)\nclear graphic effects\nhide\ngo to x: (0) y: (0)\n\n@6. Draw\n\nwhen flag clicked\nerase all\nset pen size to (10)\nforever\n    if <(Level) = [7]> then\n        if <mouse down?> then\n            go to (mouse-pointer v)\n            set pen color to (#218cd0)\n            pen down\n        else\n            pen up\n        end\n    else\n        erase all\n    end\nend\n\nwhen [space v] key pressed\nerase all\n\n@7. Shield\n\nwhen I receive [shield v]\nhide\n\nwhen I receive [reset v]\nif <(Level) = [8]> then\n    show\n    set [shield v] to [n]\n    go to x: (-110) y: (-100)\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [8]> then\n        if <(Shield) = [y]> then\n            if <key (z v) pressed?> then\n                go to (character v)\n                show\n            end\n        end\n    end\nend\n\nwhen flag clicked\nset [shield v] to [n]\nswitch costume to (costume1 v)\nforever\n    if <not <(Level) = [8]>> then\n        hide\n    end\n    if <(Level) = [8]> then\n        if <(Shield) = [y]> then\n            if <key (z v) pressed?> then\n                show\n                wait (3) seconds\n                hide\n                set [shield v] to [n]\n            end\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [8]> then\n    switch costume to (costume1 v)\n    show\n    go to x: (-110) y: (-100)\nelse\n    hide\nend\n\n@7. Spikes\n\nwhen flag clicked\nforever\n    if <(Level) = [8]> then\n        switch costume to (costume1 v)\n        show\n    else\n        hide\n    end\nend\n\n@8. Sword\n\nwhen flag clicked\nset [sword v] to [n]\nswitch costume to (costume1 v)\nforever\n    if <not <(Level) = [9]>> then\n        hide\n    end\n    if <(Level) = [9]> then\n        if <(Sword) = [y]> then\n            if <key (s v) pressed?> then\n                go to x: (([x position v] of [character v]) + (10)) y: (([y position v] of [character v]) + (10))\n                show\n                switch costume to (costume1 v)\n                repeat (5)\n                    next costume\n                end\n                hide\n                wait until <not <key (s v) pressed?>>\n            end\n        end\n    end\nend\n\nwhen I receive [sword v]\nhide\n\nwhen I receive [reset v]\nif <(Level) = [9]> then\n    set [sword v] to [n]\n    switch costume to (costume1 v)\n    show\n    go to x: (-92) y: (-94)\nend\n\nwhen I receive [next level v]\nif <(Level) = [9]> then\n    switch costume to (costume1 v)\n    show\n    go to x: (-92) y: (-94)\nend\n\n@8. Enemies\n\nwhen flag clicked\nhide\nforever\n    glide (1.5) secs to x: (30) y: (-112)\n    glide (1.5) secs to x: (121) y: (-112)\nend\n\nwhen flag clicked\nforever\n    if <touching (8. sword v)?> then\n        if <(Sword) = [y]> then\n            hide\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [9]> then\n    switch costume to (costume1 v)\n    show\nelse\n    hide\nend\n\n@9. Ladder\n\nwhen flag clicked\nswitch costume to (costume1 v)\nforever\n    if <(Level) = [10]> then\n        go to x: (0) y: (0)\n        go to [back v] layer\n        show\n    else\n        hide\n    end\nend\n\n@Sprite1\n\n@Thumbnail\n\nwhen flag clicked\nhide\n\n