Being Red 2 - Platformer


@Stage\n\nwhen flag clicked\nforever\n    play sound [The Cannery v] until done\nend\n\n@Thumbnail\n\nwhen flag clicked\nhide\nforever\n    show\n    set [ghost v] effect to (100)\n    go to x: (0) y: (0)\n    go to [front v] layer\nend\n\nwhen flag clicked\nset [level2 v] to [1]\nforever\n    if <(level2) = [11]> then\n        stop [all v]\n    end\nend\n\n@New Style\n\n@Player\n\nwhen flag clicked\nset [scroll v] to [1]\ngo to x: (-175) y: (-122)\npoint in direction (90)\nset [y-velocity v] to [0]\nset [x-velocity v] to [0]\nhide\nbroadcast (start_game v)\n\ndefine Platform (jump/height) (gravity) (friction) (running speed)\nset rotation style [left-right v]\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    change [x-velocity v] by (running speed)\n    point in direction (90)\nend\nif <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n    change [x-velocity v] by ((running speed) * (-1))\n    point in direction (-90)\nend\nset [x-velocity v] to ((X-Velocity) * (friction))\nchange x by (X-Velocity)\nif <touching (platform v)?> then\n    set [slope v] to [0]\n    repeat until <<(Slope) = [8]> or <not <touching (platform v)?>>>\n        change [slope v] by (1)\n        change y by (1)\n    end\n    if <touching (platform v)?> then\n        change y by ((Slope) * (-1))\n        repeat ([ceiling v] of ([abs v] of (X-Velocity) ) )\n            if <touching (platform v)?> then\n                repeat (10)\n                    change x by ((([abs v] of (X-Velocity) ) / (X-Velocity)) * (-1))\n                end\n            end\n        end\n        set [x-velocity v] to [0]\n    end\nend\nchange y by (Y-Velocity)\nif <touching (platform v)?> then\n    repeat ([ceiling v] of ([abs v] of (Y-Velocity) ) )\n        if <touching (platform v)?> then\n            change y by ((([abs v] of (Y-Velocity) ) / (Y-Velocity)) * (-1))\n        end\n    end\n    if <<(([abs v] of (Y-Velocity) ) / (Y-Velocity)) = [-1]> and <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <key (space v) pressed?>>> then\n        set [y-velocity v] to (jump/height)\n    else\n        set [y-velocity v] to [0]\n    end\nelse\n    change [y-velocity v] by (-1)\nend\nswitch costume to (idle v)\nif <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<key (left arrow v) pressed?> or <key (a v) pressed?>>> then\n    switch costume to (Walk)\nend\nif <(Y-Velocity) > [2]> then\n    switch costume to (jump v)\nend\nif <(Y-Velocity) < [-3]> then\n    switch costume to (fall v)\nend\nif <(scroll) = [2]> then\n    set [x-velocity v] to ((X-Velocity) * (friction))\n    switch costume to (idle v)\n    if <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<key (left arrow v) pressed?> or <key (a v) pressed?>>> then\n        switch costume to (Walk)\n    end\n    if <(Y-Velocity) > [2]> then\n        switch costume to (jump v)\n    end\n    if <(Y-Velocity) < [-3]> then\n        switch costume to (fall v)\n    end\n    set rotation style [left-right v]\n    change [scroll x v] by ((x position) * (-1))\n    change [scroll y v] by ((y position) * (-1))\n    go to x: (0) y: (0)\nend\n\nwhen flag clicked\nset [walk v] to [5]\nforever\n    change [walk v] by (1)\n    if <(Walk) > [8]> then\n        set [walk v] to [5]\n    end\n    wait (0.1) seconds\nend\n\nwhen I receive [start_game v]\nswitch backdrop to (backdrop1 v)\nshow\nset [scroll v] to [1]\nforever\n    Platform (11.5) (-1) (0.7) (3)\nend\n\nwhen flag clicked\nforever\n    if <touching (door v)?> then\n        go to x: (-175) y: (-109)\n        point in direction (90)\n        change [level2 v] by (1)\n        broadcast (scroll set v)\n        set [y-velocity v] to [0]\n        set [x-velocity v] to [0]\n    end\n    if <touching (spikes v)?> then\n        if <(scroll) = [1]> then\n            go to x: (-175) y: (-109)\n            point in direction (90)\n            set [y-velocity v] to [0]\n            set [x-velocity v] to [0]\n        end\n        if <(scroll) = [2]> then\n            go to x: (0) y: (0)\n            point in direction (90)\n            set [y-velocity v] to [0]\n            set [x-velocity v] to [0]\n            set [scroll x v] to [0]\n            set [scroll y v] to [0]\n        end\n    end\nend\n\nwhen I receive [scroll set v]\nif <(level2) = [8]> then\n    go to x: (-175) y: (-109)\nend\n\n@Platform\n\nwhen flag clicked\nset [level2 v] to [1]\nforever\n    go to x: (0) y: (0)\n    switch costume to (level2)\nend\n\nwhen I receive [start_game v]\nhide\nset [space v] to [2]\nshow\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nset [level2 v] to [1]\nset [scroll2 v] to [1]\nforever\n    if <(scroll2) = [2]> then\n        set size to (156) %\n        go to x: (scroll x) y: (scroll y)\n        switch costume to (level2)\n    else\n        set size to (100) %\n        go to x: (0) y: (0)\n        switch costume to (level2)\n    end\nend\n\n@Door\n\nwhen flag clicked\nhide\nset [level v] to [1]\nforever\n    go to x: (0) y: (0)\n    switch costume to (level2)\nend\n\nwhen I receive [start_game v]\nhide\nset [space v] to [2]\nshow\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nset [level2 v] to [1]\nset [scroll2 v] to [1]\nforever\n    if <(scroll2) = [2]> then\n        go to x: (scroll x) y: (scroll y)\n        switch costume to (level2)\n    else\n        go to x: (0) y: (0)\n        switch costume to (level2)\n    end\nend\n\n@Spikes\n\nwhen flag clicked\nset [level2 v] to [1]\nforever\n    go to [back v] layer\n    go to x: (0) y: (0)\n    switch costume to (level2)\nend\n\nwhen flag clicked\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nset [level2 v] to [1]\nset [scroll v] to [1]\n\nwhen I receive [start_game v]\nhide\nset [space v] to [2]\nshow\nforever\n    if <(scroll) = [2]> then\n        go to x: (scroll x) y: (scroll y)\n        switch costume to (level2)\n    else\n        go to x: (0) y: (0)\n        switch costume to (level2)\n    end\nend\n\n@Text/Background\n\nwhen flag clicked\nset [level2 v] to [1]\nforever\n    go to [back v] layer\n    go to x: (0) y: (0)\n    switch costume to (level2)\nend\n\nwhen I receive [start_game v]\nhide\nset [space v] to [2]\nshow\nforever\n    if <(scroll) = [2]> then\n        go to x: (scroll x) y: (scroll y)\n        switch costume to (level2)\n    else\n        go to x: (0) y: (0)\n        switch costume to (level2)\n    end\nend\n\n