Demon's Journey -  A Scrolling Platformer


@Stage\n\nwhen I receive [start animation v]\nforever\n    play sound [Seventeen v] until done\nend\n\n@Blank\n\n@Flash\n\nwhen I receive [green flag v]\nrepeat (10)\n    change [ghost v] effect by (17)\nend\n\nwhen I receive [tick v]\ngo to [front v] layer\n\n@Thumbnail\n\nwhen flag clicked\nset [ghost v] effect to (100)\nforever\n    go to [front v] layer\nend\n\n@Intro\n\nwhen flag clicked\nstart sound [Three Days Grace - Fallen Angel Clip v]\nswitch costume to (1 v)\nrepeat (4)\n    wait (0.1) seconds\n    next costume\nend\nswitch costume to (6 v)\nwait (0.5) seconds\nrepeat (5)\n    next costume\nend\nrepeat (7)\n    wait (0.01) seconds\n    next costume\n    wait (0.01) seconds\nend\nswitch costume to (19 v)\nrepeat (8)\n    next costume\nend\nwait (1.5) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nbroadcast (Intro Ended v)\n\n@Start Menu\n\nwhen I receive [menu started v]\nhide\n\nwhen I receive [intro ended v]\nshow\n\n@Press Start\n\nwhen this sprite clicked\nchange [start clicked # v] by (1)\nif <(Start Clicked #) = [1]> then\n    hide\n    broadcast (Start Animation v)\n    broadcast (Menu started v)\nelse\n    if <(Start Clicked #) = [2]> then\n        hide\n        broadcast (Play Game v) and wait\n    end\nend\n\nwhen I receive [intro ended v]\nset [start clicked # v] to [0]\nswitch costume to (press start v)\ngo to x: (0) y: (-130)\nshow\ngo to [front v] layer\nforever\n    if <touching (mouse-pointer v)?> then\n        set size to (55) %\n        wait (0.5) seconds\n    else\n        set size to (45) %\n    end\nend\n\nwhen I receive [show start v]\nshow\nswitch costume to (press start2 v)\ngo to x: (0) y: (100)\n\nwhen flag clicked\nhide\n\n@Player\n\nwhen flag clicked\nbroadcast (Green Flag v) and wait\n\nbroadcast (Play Game v) and wait\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\n\nwhen I receive [play game v]\nset [level v] to [1]\nforever\n    broadcast (Reset v) and wait\n    broadcast (Setup v) and wait\n    Game On\n    repeat until <(EXIT) > []>\n        Tick\n        broadcast (Tick v) and wait\n    end\n    if <(EXIT) = [win]> then\n        Game - Win\n    else\n        Game - Die\n    end\nend\n\ndefine Game On\nset [y v] to [0]\nset [x v] to [0]\nset [sx v] to [0]\nset [sy v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nset [ghost v] effect to (0)\nset size to (100) %\nshow\n\ndefine Tick\nif <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n    change [sx v] by (-2)\nend\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    change [sx v] by (2)\nend\nset [sx v] to ((sx) * (0.8))\nif <([abs v] of (sx) ) > [0.9]> then\n    Change Player x by (round (sx))\nend\nif <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n    if <(in air) < [4]> then\n        set [sy v] to [17]\n    end\nend\nif <(sy) > [-20]> then\n    change [sy v] by (-2)\nend\nChange Player y by (sy)\nTest - Die\nset [scroll x v] to (x)\nif <(SCROLL X) < [0]> then\n    set [scroll x v] to [0]\nend\nchange [scroll y v] by (round (((y) - (SCROLL Y)) / (9)))\nif <(SCROLL Y) < [0]> then\n    set [scroll y v] to [0]\nend\nPosition\nif <(y) < [-180]> then\n    set [exit v] to [die]\nend\n\ndefine Change Player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\nPosition\nrepeat until <not <touching (platforms v)?>>\n    if <(sy) > [0]> then\n        change [y v] by (-1)\n    else\n        change [y v] by (1)\n        set [in air v] to [0]\n    end\n    Position\n    set [sy v] to [0]\nend\n\ndefine Position\ngo to x: ((x) - (SCROLL X)) y: ((y) - (SCROLL Y))\n\ndefine Change Player x by (sx)\nchange [x v] by (sx)\nPosition\nif <touching (platforms v)?> then\n    repeat (12)\n        change [y v] by (1)\n        Position\n        if <not <touching (platforms v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    if <key (up arrow v) pressed?> then\n        if <(sx) > [0]> then\n            set [sx v] to [-16]\n        else\n            set [sx v] to [16]\n        end\n        set [in air v] to [0]\n    else\n        set [sx v] to [0]\n    end\n    repeat until <not <touching (platforms v)?>>\n        if <(sx) > [0]> then\n            change [x v] by (-1)\n        else\n            change [x v] by (1)\n        end\n        Position\n    end\nend\n\ndefine Game - Die\nset [exit v] to []\nrepeat (5)\n    hide\n    wait (.1) seconds\n    show\n    wait (0.1) seconds\nend\nhide\nwait (0.5) seconds\n\ndefine Test - Die\nif <touching (danger v)?> then\n    set [exit v] to [die]\nend\n\ndefine Game - Win\nrepeat (50)\n    point towards (exit v)\n    turn right (65) degrees\n    move ((distance to [exit v]) / (2)) steps\n    change size by (-1)\n    change [ghost v] effect by (2)\nend\nhide\nchange [level v] by (1)\nwait (1) seconds\n\nwhen I receive [end game v]\nhide\n\n@Platforms\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1 1 v)\n    Clone at x: [360] y: [0]\n    Clone at x: [360] y: [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2 1 v)\n        Clone at x: [-5] y: [220]\n        Clone at x: [400] y: [150]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (level 3 1 v)\n            Clone at x: [480] y: [0]\n            Clone at x: [450] y: [1000]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (end v)\n                broadcast (End Animation v)\n                broadcast (End Game v)\n                hide\n            end\n        end\n    end\nend\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nnext costume\nnext costume\n\ncreate clone of (_myself_ v)\n\nClone at x: [700] y: [-180]\nClone at x: [6] y: [-30]\n\nClone at x: [450] y: [1000]\n\n@DANGER\n\nwhen I receive [green flag v]\nhide\n\nshow\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1 1 v)\n    Clone at x: [360] y: [0]\n    Clone at x: [360] y: [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2 1 v)\n        Clone at x: [-5] y: [-5]\n    else\n        switch costume to (level 3 1  v)\n        Clone at x: [1200] y: [350]\n        Clone at x: [450] y: [1000]\n    end\nend\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nforever\n    go to [front v] layer\nend\n\n@Key Collector\n\nwhen I receive [tick v]\nswitch costume to (letter (1) of (COLLECTED))\n\nwhen flag clicked\nhide\n\nwhen I receive [play game v]\nshow\n\n@Key\n\nwhen I receive [green flag v]\nhide\n\nshow\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <touching (player v)?> then\n    change [collected v] by (1)\n    start sound [Door Unlocking v]\n    if <(COLLECTED) = (COLLECTED MAX)> then\n        broadcast (Open Portal v)\n    end\n    delete this clone\nend\n\nwhen I receive [setup v]\nhide\nset [collected max v] to [0]\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (key v)\n    Clone at x: [450] y: [90]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (key v)\n        Clone at x: [400] y: [240]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (key v)\n            Clone at x: [200] y: [340]\n        end\n        set [x v] to [-9999999999]\n    end\n    set [x v] to [-9999999999]\nend\nset [x v] to [-9999999999]\n\ncreate clone of (_myself_ v)\n\nnext costume\nnext costume\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\nset [x v] to (x)\nset [y v] to (y)\nchange [collected max v] by (1)\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nforever\n    hide variable [collected v]\nend\n\n@Exit\n\nwhen I receive [green flag v]\nhide\n\nshow\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <<touching (player v)?> and <(costume [number v]) = [2]>> then\n    set [exit v] to [win]\nend\n\nwhen I receive [setup v]\nhide\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (closed v)\n    Clone at x: [922] y: [21]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (closed v)\n        Clone at x: [-115] y: [350]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (closed v)\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (closed v)\n            end\n        end\n    end\nend\n\nClone at x: [920] y: [-28]\n\ncreate clone of (_myself_ v)\n\nnext costume\nnext costume\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\nset [x v] to (x)\nset [y v] to (y)\n\nwhen I receive [open portal v]\nswitch costume to (open v)\n\nClone at x: [99] y: [250]\n\nhide\n\n@Love, Fav, Follow\n\nwhen flag clicked\nhide\n\nwhen I receive [end animation v]\nhide\n\nwhen I receive [play game v]\nrepeat (100)\n    set [ghost v] effect to (0)\n    set [pixelate v] effect to (0)\n    show\n    wait (5) seconds\n    repeat (10)\n        change [pixelate v] effect by (10)\n        change [ghost v] effect by (10)\n    end\n    hide\n    wait (15) seconds\nend\n\nforever\n    go to [front v] layer\n    go to [front v] layer\nend\n\n@Animation\n\nwhen flag clicked\nset [end game v] to [not sent]\nhide\n\nwhen I receive [start animation v]\nshow\nswitch costume to (start; 1 v)\nrepeat (5)\n    next costume\nend\nrepeat (8)\n    wait (0.01) seconds\n    next costume\nend\nrepeat (11)\n    next costume\nend\nwait (1) seconds\nrepeat (4)\n    wait (0.01) seconds\n    next costume\nend\nwait (1) seconds\nrepeat (8)\n    next costume\nend\nswitch costume to (start; 38 v)\nswitch costume to (start; 38 v)\nbroadcast (Show Start v)\n\nwhen I receive [play game v]\nhide\n\nwhen I receive [end animation v]\nset [end game v] to [sent]\ngo to [front v] layer\ngo to [front v] layer\nswitch costume to (end; 1 v)\nshow\nnext costume\nwait (1) seconds\nrepeat (8)\n    next costume\nend\nrepeat (14)\n    wait (0.01) seconds\n    next costume\nend\nswitch costume to (end; 24 v)\nwait (8) seconds\nstop [all v]\n\n