platformer

Instructions: Try to reach the end.\nTo read the signs press e

@Stage\n\n@Player\n\ndefine Move - in steps  (steps)\nchange [falling v] by (1)\nrepeat (steps)\n    set [last value v] to (x position)\n    change x by ((speed x) / (steps))\n    Check If Touching Solid \n    if <(touching) > [0]> then\n        Collide X slope or Wall?\n    end\n    set [last value v] to (y position)\n    change y by ((speed y) / (steps))\n    Check If Touching Solid \n    if <(touching) > [0]> then\n        Collide Y- Celling or Floor\n    end\nend\n\ndefine Check If Touching Solid \nif <<touching (level v)?> or <touching (platforms v)?>> then\n    set [touching v] to [1]\nelse\n    set [touching v] to [0]\nend\n\nwhen I receive [tick - player v]\nMoved By Moving Platforms\nswitch backdrop to <touching (level v)?>\nControls - Up and Down \nControls - Left and Right \nMove - in steps  (([abs v] of (speed x) ) + ([abs v] of (speed y) ))\nSet Costume\n\ndefine Controls - Up and Down \nif <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n    if <<(wall slide) > [0]> and <(jumping) = [0]>> then\n        start sound [Jump v]\n        set [jumping v] to [1]\n        set [falling v] to [3]\n        set [wall slide v] to [0]\n        turn right (180) degrees\n        set [speed x v] to (((direction) / (90)) * (7))\n        set [long jump v] to [12]\n    end\n    if <<(falling) < [3]> and <(jumping) = [0]>> then\n        start sound [Jump v]\n        set [jumping v] to [1]\n        set [falling v] to [3]\n    end\n    if <<(jumping) > [0]> and <(jumping) < (JUMP DURATION)>> then\n        change [jumping v] by (1)\n        set [speed y v] to (JUMP FORCE)\n    end\nelse\n    set [jumping v] to [0]\nend\nchange [speed y v] by (GRAVITY)\nif <(wall slide) > [0]> then\n    Check can wall slide\n    if <(speed y) < [0]> then\n        set [speed y v] to ((speed y) * (0.6))\n    end\nend\n\ndefine Controls - Left and Right \nif <(long jump) > [0]> then\n    change [long jump v] by (-1)\n    stop [this script v]\nend\nset [key x v] to (<<key (right arrow v) pressed?> or <key (d v) pressed?>> - <<key (left arrow v) pressed?> or <key (a v) pressed?>>)\nif <(KEY X) = [0]> then\n    if <<(falling) > [2]> and <(wall slide) < [1]>> then\n        set [speed x v] to ((speed x) * (0.98))\n        stop [this script v]\n    end\n    if <([abs v] of (speed x) ) < [1]> then\n        set [frame v] to [0]\n        set [speed x v] to [0]\n    else\n        change [frame v] by (0.5)\n    end\nelse\n    change [speed x v] by ((KEY X) * (ACCELARATION))\n    point in direction ((KEY X) * (90))\n    change [frame v] by (1)\nend\nset [speed x v] to ((speed x) * (RESISTANCE))\n\ndefine Reset and Begin level\nshow\nset [invulnerable v] to [0]\nset [level # v] to [1]\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [falling v] to [99]\nset [long jump v] to [0]\nset [wall slide v] to [0]\nset [jumping v] to [0]\npoint in direction (90)\nBegin Level #  (SPAWN SCENE) Got to x, y : (SPAWN X) (SPAWN Y)\n\ngo to [front v] layer\n\nwhen I receive [game loop v]\nset [ghost v] effect to (0)\nforever\n    broadcast (Tick - first v)\n    broadcast (Tick Platforms v)\n    broadcast (Tick - Player v)\n    broadcast (Tick  - Last v)\nend\n\nwhen I receive [tick  - last v]\nif <(x position) > [233]> then\n    Begin Level #  ((Level #) + (1)) Got to x, y : [-233] []\nend\nif <(x position) < [-233]> then\n    Begin Level #  ((Level #) + (-1)) Got to x, y : [233] []\nend\nif <(y position) > [180]> then\n    Begin Level #  ((Level #) + (100)) Got to x, y : [] [-160]\nend\nif <(y position) < [-180]> then\n    Begin Level #  ((Level #) + (-100)) Got to x, y : [] [180]\nend\nif <touching (danger v)?> then\n    broadcast (Lose life v)\nend\n\ndefine Begin Level #  (level #) Got to x, y : (x) (y)\nset [level # v] to (level #)\nif <(x) > []> then\n    set x to (x)\nend\nif <(y) > []> then\n    set y to (y)\nend\nbroadcast (About to change scene v)\nbroadcast (change level v)\nstop [other scripts in sprite v]\nwait (0) seconds\nswitch costume to (hitbox v2 v)\nset rotation style [don't rotate v]\nif <(x) > []> then\n    Fix Collision in direction  [0]\nelse\n    Fix Collision in direction  [90]\nend\nSet Costume\nbroadcast (game loop v)\n\ndefine Fix Collision in direction  (dir)\nset [temp v] to (direction)\nset [distance v] to [1]\npoint in direction (dir)\nrepeat (128)\n    Check If Touching Solid \n    if <(touching) < [1]> then\n        point in direction (temp)\n        stop [this script v]\n    end\n    move (distance) steps\n    turn right (180) degrees\n    change [distance v] by (1)\nend\n\nwhen I receive [tick - first v]\nswitch costume to (hitbox v2 v)\nset rotation style [don't rotate v]\nset [platform dx v] to []\nset [platform dy v] to []\n\ndefine Set Costume\nset rotation style [left-right v]\nif <(wall slide) > [0]> then\n    switch costume to (hangon01 v)\n    stop [this script v]\nend\nif <(falling) > [1]> then\n    if <(speed y) > [0]> then\n        switch costume to (jump01 v)\n    else\n        switch costume to (run_j2 v)\n    end\n    stop [this script v]\nend\nif <(frame) > [0]> then\n    switch costume to ((1) + ([floor v] of ((frame) mod (16)) ))\nelse\n    switch costume to (hit angle 0 v)\n    repeat (5)\n        Check If Touching Solid \n        if <(touching) < [1]> then\n            switch costume to ((costume [number v]) + (5))\n            stop [this script v]\n        end\n        next costume\n    end\n    switch costume to (stand v)\nend\n\ndefine Collide X slope or Wall?\nCheck can wall slide\nchange y by (1)\nCheck If Touching Solid \nif <(touching) > [0]> then\n    change y by (1)\n    Check If Touching Solid \n    if <(touching) > [0]> then\n        change y by (-2)\n        set x to (last value)\n        set [speed x v] to [0]\n        stop [this script v]\n    end\n    set [speed x v] to ((speed x) * (0.8))\nend\nset [speed x v] to ((speed x) * (0.95))\nSlip\n\ndefine Collide Y- Celling or Floor\nset y to (last value)\nif <(speed y) > [0]> then\n    set [speed y v] to [0]\n    stop [this script v]\nend\nif <(falling) > [0]> then\n    set [falling v] to [0]\n    Slip\nend\nset [speed y v] to ((speed y) * (0.8))\n\ndefine Slip\nchange y by (-2)\nchange x by (1)\nCheck If Touching Solid \nif <(touching) < [1]> then\n    set [falling v] to [9]\n    change [speed x v] by (1)\n    stop [this script v]\nend\nchange x by (-2)\nCheck If Touching Solid \nif <(touching) < [1]> then\n    set [falling v] to [9]\n    change [speed x v] by (-1)\n    stop [this script v]\nend\nchange y by (2)\nchange x by (1)\n\ndefine Check can wall slide\nif <(falling) < [2]> then\n    set [wall slide v] to [0]\n    stop [this script v]\nend\nswitch costume to (hitbox wallslide v)\nset rotation style [left-right v]\nCheck If Touching Solid \nset [wall slide v] to (touching)\nswitch costume to (hitbox v2 v)\nset rotation style [don't rotate v]\n\nwhen I receive [lose life v]\nset [invulnerable v] to [1]\nstop [other scripts in sprite v]\nstart sound [Oops v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nwait (0.5) seconds\nchange [lives v] by (-1)\nif <(Lives) > [0]> then\n    Reset and Begin level\nelse\n    broadcast (Game over v)\nend\n\ndefine Moved By Moving Platforms\nchange x by (Platform dx)\nchange y by (Platform dy)\nCheck If Touching Solid \nif <(touching) > [0]> then\n    Find Closest Space to (x position) (y position) max [16]\n    if <(touching) > [0]> then\n        broadcast (Lose life v)\n    end\nend\n\ndefine Find Closest Space to (x) (y) max (max)\nset [temp v] to (direction)\nset [distance v] to [1]\npoint in direction (0)\nrepeat (max)\n    repeat (16)\n        go to x: (x) y: (y)\n        move (distance) steps\n        Check If Touching Solid \n        if <(touching) < [1]> then\n            point in direction (temp)\n            stop [this script v]\n        end\n        turn right (22.5) degrees\n    end\n    change [distance v] by (1)\nend\ngo to x: (x) y: (y)\npoint in direction (temp)\n\nwhen flag clicked\nhide\nbroadcast (Main Menu v)\n\nwhen I receive [you won v]\ngo to [back v] layer\n\nwhen I receive [start game v]\nset [gravity v] to [-1.5]\nset [jump force v] to [12]\nset [jump duration v] to [6]\nset [accelaration v] to [1.5]\nset [resistance v] to [0.8]\nbroadcast (Reset game v) and wait\nbroadcast (Setup v) and wait\nset [lives v] to [3]\nset [spawn scene v] to [1]\nset [spawn x v] to [-150]\nset [spawn y v] to [30]\nReset and Begin level\n\nwhen I receive [player - bounce v]\nset [speed y v] to [15]\n\n@Enemy\n\nwhen flag clicked\ngo to [front v] layer\nswitch costume to (red1 v)\nset rotation style [left-right v]\nhide\n\nwhen I receive [change level v]\nif <(Level #) = [1]> then\n    Spawn [Red] at [-7] [5] dir [-90]\nend\nif <(Level #) = [18]> then\n    Spawn [Red] at [152] [-61] dir [-90]\n    Spawn [Red] at [-145] [-6] dir [90]\nend\nif <(Level #) = [22]> then\n    Spawn [Red] at [48] [11] dir [-90]\nend\nif <(Level #) = [27]> then\n    Spawn [Red] at [40] [-18] dir [-90]\n    Spawn [Red] at [70] [19] dir [90]\nend\nif <(Level #) = [30]> then\n    Spawn [Red] at [-16] [-144] dir [-90]\nend\nif <(Level #) = [34]> then\n    Spawn [Red] at [108] [-73] dir [-90]\nend\nif <(Level #) = [140]> then\n    Spawn [Red] at [-51] [77] dir [90]\nend\nif <(Level #) = [142]> then\n    if <([x position v] of [player v]) < [0]> then\n        Spawn [Red] at [160] [-77] dir [-90]\n    else\n        Spawn [Red] at [-55] [-77] dir [90]\n    end\nend\nif <(Level #) = [145]> then\n    Spawn [Red] at [46] [-138] dir [-90]\nend\n\nwhen I start as a clone\nshow\nset [speed y v] to [0]\nset [frame v] to [0]\nforever\n    switch costume to (red1 v)\n    set rotation style [don't rotate v]\n    Move - Down\n    Move - Left or Right\n    change [frame v] by (0.33)\n    switch costume to ((1) + (([floor v] of (frame) ) mod (4)))\n    set rotation style [left-right v]\n    if <<(INVULNERABLE) = [0]> and <touching (player v)?>> then\n        Touching Player\n    end\nend\n\nwhen I receive [about to change scene v]\ndelete this clone\n\ndefine Move - Down\nchange [speed y v] by (-1)\nchange y by (speed y)\nrepeat until <not <touching (level v)?>>\n    change y by (1)\n    set [speed y v] to [0]\nend\n\ndefine Move - Left or Right\nmove (2) steps\nrepeat (4)\n    if <not <<touching (level v)?> or <touching (_edge_ v)?>>> then\n        if <not <<touching (safe sones v)?> or <touching (platforms v)?>>> then\n            stop [this script v]\n        end\n    end\n    change y by (1)\nend\nchange y by (-4)\nmove (-2) steps\nturn right (180) degrees\n\ndefine Touching Player\nif <([speed y v] of [player v]) < [-3]> then\n    broadcast (Player - Bounce v)\n    start sound [squish v]\n    switch costume to (red squish v)\n    wait (0.3) seconds\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\n    delete this clone\nend\nbroadcast (Lose life v)\n\ndefine Spawn (type) at (x) (y) dir (dir)\ngo to x: (x) y: (y)\npoint in direction (dir)\ncreate clone of (_myself_ v)\n\n@level\n\ndefine Stamp Shadow\nchange y by (-18)\nset [brightness v] effect to (-100)\nset [ghost v] effect to (78)\nstamp\nclear graphic effects\nchange y by (18)\n\ndefine Stamp Outline\nset rotation style [don't rotate v]\nset [brightness v] effect to (-100)\nrepeat (8)\n    move (4) steps\n    stamp\n    move (-4) steps\n    turn right (45) degrees\nend\nclear graphic effects\n\nwhen flag clicked\ngo to x: (0) y: (0)\ngo to [back v] layer\n\nerase all\n\nwhen I receive [change level v]\nshow\ngo to [back v] layer\nswitch costume to (join [level] (Level #))\nerase all\nStamp Outline\nStamp Shadow\n\nwhen flag clicked\nhide\n\n@Safe sones\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\n\nwhen I receive [change level v]\ngo to [back v] layer\nshow\nset [ghost v] effect to (100)\nswitch costume to (blank v)\nswitch costume to (join [level] (Level #))\n\nwhen flag clicked\nhide\n\nwhen I receive [start game v]\nforever\n    go to [back v] layer\nend\n\n@Danger\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\n\nwhen I receive [change level v]\ngo to [back v] layer\nshow\nswitch costume to (blank v)\nswitch costume to (join [level] (Level #))\nif <(Level #) = [14]> then\n    forever\n        set y to ((5) * ([sin v] of ((timer) * (360)) ))\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [start game v]\nforever\n    go to [back v] layer\nend\n\n@platforms\n\nwhen I receive [change level v]\nhide\nswitch costume to (moving platforms v)\ngo to [back v] layer\nif <(Level #) = [3]> then\n    Door at [75] [-18] key [Key 1]\nend\nif <(Level #) = [7]> then\n    Door at [77] [24] key [Key 2]\nend\nif <(Level #) = [108]> then\n    Door at [228] [110] key [Key 3]\nend\nif <(Level #) = [21]> then\n    Door at [-103] [-32] key [Key 4]\nend\nif <(Level #) = [146]> then\n    go to [back v] layer\n    Door at [0] [-13] key [Key 5]\nend\n\ndefine Animate Platform\npoint in direction (90)\ngo to x: (-55) y: (-65)\nforever\n    glide (2) secs to x: (55) y: (-65)\n    wait (1) seconds\n    glide (2) secs to x: (-55) y: (-65)\n    wait (1) seconds\nend\n\ndefine Tick x: (new x) y: (new y)\nif <(new x) > (Last y)> then\n    change y by (1)\nelse\n    set y to ((Last y) + (1))\nend\nif <touching (player v)?> then\n    set [platform dx v] to ((new x) - (Last x))\n    set [platform dy v] to ((new y) - (Last y))\nend\ngo to x: (new x) y: (new y)\n\nwhen I receive [tick platforms v]\nTick x: (x position) y: (y position)\nset [last x v] to (x position)\nset [last y v] to (y position)\n\ndefine ANIMATE 2\ngo to x: (0) y: (-30)\npoint in direction (90)\ngo to [back v] layer\nforever\n    glide (1.5) secs to x: (135) y: (68)\n    wait (1) seconds\n    glide (1.5) secs to x: (0) y: (-30)\n    wait (0.5) seconds\nend\n\nif <(Level #) = [2]> then\n\ndefine Door at (x) (y) key (key name)\nshow\nswitch costume to (key name)\ngo to x: (x) y: (y)\nforever\n    wait until <touching (player v)?>\n    go to [back v] layer\n    if <[collected v] contains (key name)?> then\n        start sound [Door Open v]\n        repeat (24)\n            change y by (4)\n        end\n        wait (1) seconds\n        start sound [Door Open v]\n        repeat (24)\n            change y by (-4)\n        end\n        start sound [Door smash v]\n    else\n        start sound [Closed v]\n    end\n    wait until <not <touching (player v)?>>\nend\n\nwhen flag clicked\nhide\n\n@Collectables\n\nwhen I receive [change level v]\nif <(Level #) = (my scene)> then\n    show\nelse\n    hide\nend\n\nwhen I start as a clone\nrepeat until <touching (player v)?>\n    change y by ((0.5) * ([sin v] of (frame) ))\n    change [frame v] by (5)\nend\nset [my scene v] to []\nif <(costume [name v]) = [Apple]> then\n    start sound [crunch v]\n    change [apples v] by (1)\nelse\n    if <(costume [name v]) = [Life]> then\n        if <(Lives) < [3]> then\n            start sound [Diamond v]\n            change [lives v] by (1)\n        end\n    end\n    if < (costume [name v]) contains [Key]?> then\n        start sound [Key v]\n    end\n    if <(costume [name v]) = [Checkpoints]> then\n        start sound [Flag v]\n        set [spawn scene v] to (Level #)\n        set [spawn x v] to ([x position v] of [player v])\n        set [spawn y v] to ([y position v] of [player v])\n    else\n        add (costume [name v]) to [collected v]\n    end\n    if <(costume [name v]) = [Star]> then\n        broadcast (You won v)\n    end\n    if <(costume [name v]) = [Diamond]> then\n        start sound [Diamond v]\n        change [apples v] by (5)\n    end\nend\nrepeat (20)\n    change y by (2)\n    change [ghost v] effect by (5)\nend\nhide\n\nwhen I receive [setup v]\ndelete all of [collected v]\nset [frame v] to [0]\nset [apples v] to [0]\nhide\nPlace [Apple] Scene [1] xy [155] [-25]\nPlace [Apple] Scene [1] xy [-65] [10]\nPlace [Apple] Scene [2] xy [-23] [-43]\nPlace [Key 1] Scene [2] xy [120] [-88]\nPlace [Key 2] Scene [106] xy [-61] [-130]\nPlace [Key 3] Scene [106] xy [-191] [-63]\nPlace [Diamond] Scene [106] xy [135] [-23]\nPlace [Apple] Scene [7] xy [-175] [-80]\nPlace [Apple] Scene [7] xy [-125] [-80]\nPlace [Apple] Scene [7] xy [200] [-50]\nPlace [Checkpoints] Scene [4] xy [195] [-90]\nPlace [Checkpoints] Scene [11] xy [50] [-16]\nPlace [Life] Scene [16] xy [154] [-18]\nPlace [Checkpoints] Scene [19] xy [17] [-88]\nPlace [Key 4] Scene [20] xy [-13] [-95]\nPlace [Diamond] Scene [21] xy [76] [-62]\nPlace [Checkpoints] Scene [143] xy [16] [51]\nPlace [Key 5] Scene [145] xy [96] [-106]\nPlace [Star] Scene [48] xy [-156] [34]\n\ndefine Place (costume name) Scene (scene) xy (x) (y)\nset [my scene v] to (scene)\nswitch costume to (costume name)\ngo to x: (x) y: (y)\ncreate clone of (_myself_ v)\nset [my scene v] to []\n\nwhen I receive [reset game v]\ndelete this clone\n\n@Main Menu\n\nwhen I receive [main menu v]\ngo to [front v] layer\nshow\nforever\n    if <touching (mouse-pointer v)?> then\n        change size by ((0.2) * ((120) - (size)))\n    else\n        change size by ((0.2) * ((100) - (size)))\n    end\n    if <<touching (mouse-pointer v)?> and <mouse down?>> then\n        hide\n        broadcast (Start game v)\n        wait until <not <mouse down?>>\n    end\nend\n\nwhen flag clicked\nswitch costume to (play v)\ngo to [front v] layer\nshow\n\nwhen I receive [start game v]\nhide\nstop [other scripts in sprite v]\n\nwhen I receive [reset game v]\ndelete this clone\n\n@Dialogue\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\n\nwhen I start as a clone\nif <not < (costume [name v]) contains [Speaker]?>> then\n    if <(effect) = []> then\n        go to x: (((textpos) * (10)) - (190)) y: (((ty) * (-15)) - (105))\n        wait until <(textdelay) = [0]>\n        wait until <key (space v) pressed?>\n        wait until <not <key (space v) pressed?>>\n        delete this clone\n    end\n    if <(effect) = [wavy]> then\n        set [effect v] to [0]\n        repeat until <(textdelay) = [0]>\n            go to x: (((textpos) * (10)) - (190)) y: (((ty) * (-15)) - (105))\n            change x by (([cos v] of ((effect) * (15)) ) * (2))\n            change y by (([sin v] of ((effect) * (15)) ) * (2))\n            change [effect v] by (1)\n        end\n        repeat until <key (space v) pressed?>\n            go to x: (((textpos) * (10)) - (190)) y: (((ty) * (-15)) - (105))\n            change x by (([cos v] of ((effect) * (15)) ) * (2))\n            change y by (([sin v] of ((effect) * (15)) ) * (2))\n            change [effect v] by (1)\n        end\n        repeat until <not <key (space v) pressed?>>\n            go to x: (((textpos) * (10)) - (190)) y: (((ty) * (-15)) - (105))\n            change x by (([cos v] of ((effect) * (15)) ) * (2))\n            change y by (([sin v] of ((effect) * (15)) ) * (2))\n            change [effect v] by (1)\n        end\n        delete this clone\n    end\n    if <(effect) = [shaky]> then\n        repeat until <(textdelay) = [0]>\n            go to x: (((textpos) * (10)) - (190)) y: (((ty) * (-15)) - (105))\n            change x by (pick random (1) to (-1))\n            change y by (pick random (1) to (-1))\n        end\n        repeat until <key (space v) pressed?>\n            go to x: (((textpos) * (10)) - (190)) y: (((ty) * (-15)) - (105))\n            change x by (pick random (1) to (-1))\n            change y by (pick random (1) to (-1))\n        end\n        repeat until <not <key (space v) pressed?>>\n            go to x: (((textpos) * (10)) - (190)) y: (((ty) * (-15)) - (105))\n            change x by (pick random (1) to (-1))\n            change y by (pick random (1) to (-1))\n        end\n        delete this clone\n    end\nend\nif < (costume [name v]) contains [Speaker]?> then\n    go to x: (0) y: (0)\n    set [ghost v] effect to (100)\n    repeat (10)\n        change [ghost v] effect by (-10)\n    end\nend\n\ndefine Dialogue (text) (effect) (voice) (newspeaker?)\nset [t v] to [0]\nset [textpos v] to [0]\nset [textdelay v] to [1]\nset [ty v] to [0]\nset [effect v] to (effect)\nset [textlength v] to (length of (text))\nshow\nswitch costume to (textbox v)\nrepeat until <(t) = (length of (text))>\n    change [t v] by (1)\n    if <(letter (t) of (text)) = [|]> then\n        change [ty v] by (1)\n        set [textpos v] to [0]\n    end\n    if <(letter (t) of (text)) = [\]> then\n        switch costume to (textbox v)\n        wait (0.1) seconds\n    end\n    if <not <<(letter (t) of (text)) = [|]> or <(letter (t) of (text)) = [\]>>> then\n        switch costume to (letter (t) of (text))\n        create clone of (_myself_ v)\n        go [backward v] (1) layers\n        if <not <(letter (t) of (text)) = [ ]>> then\n            start sound (voice)\n        end\n        if <[thin text v] contains (letter (t) of (text))?> then\n            change [textpos v] by (0.5)\n        else\n            change [textpos v] by (1)\n        end\n    end\n    switch costume to (textbox v)\n    if <key (space v) pressed?> then\n        TextSkip (text) (effect) (voice) (newspeaker?)\n    end\nend\nwait until <not <key (space v) pressed?>>\nset [textdelay v] to [0]\nwait (0) seconds\nwait until <key (space v) pressed?>\nwait until <not <key (space v) pressed?>>\nhide\n\nif <not <(speaker) = [none]>> then\n    switch costume to (join [Speaker] (join (speaker) (expression)))\n    if <(newspeaker?) = [1]> then\n        broadcast (speakerdelete v)\n        create clone of (_myself_ v)\n    end\nend\n\ndefine TextSkip (text) (effect) (voice) (newspeaker?)\nrepeat until <(t) = (length of (text))>\n    change [t v] by (1)\n    if <(letter (t) of (text)) = [|]> then\n        change [ty v] by (1)\n        set [textpos v] to [0]\n    end\n    if <(letter (t) of (text)) = [\]> then\n        switch costume to (textbox v)\n        repeat (3)\n            wait (0) seconds\n        end\n    end\n    if <not <<(letter (t) of (text)) = [|]> or <(letter (t) of (text)) = [\]>>> then\n        switch costume to (letter (t) of (text))\n        create clone of (_myself_ v)\n        go [backward v] (1) layers\n        if <not <(letter (t) of (text)) = [ ]>> then\n            start sound (voice)\n        end\n        if <[thin text v] contains (letter (t) of (text))?> then\n            change [textpos v] by (0.5)\n        else\n            change [textpos v] by (1)\n        end\n    end\n    switch costume to (textbox v)\nend\n\nwhen I receive [text v]\nif <(Level #) = [1]> then\n    Dialogue [Hey Scratch Cat] [] [1] [1]\n    Dialogue [Welcome to the under ground!] [] [1] [1]\n    Dialogue [I will be there sometimes to guide you.] [] [1] [1]\n    Dialogue [Good luck.] [] [1] [1]\nend\nif <(Level #) = [2]> then\n    Dialogue [Collect apples. Get the keys to open|doors!] [] [1] [1]\nend\n\n@APPLES COUNTER\n\nwhen flag clicked\ngo to [back v] layer\nhide\n\ndefine setup\nhide\nswitch costume to (9 v)\nset size to (200) %\ngo to x: (0) y: (153)\nset [index v] to [1]\nrepeat (5)\n    create clone of (_myself_ v)\n    change x by ((size) / (2))\n    change [index v] by (1)\nend\n\nwhen I start as a clone\nshow\nforever\n    change costume to (letter (index) of (APPLES))\n    set x to ((((index) - (0.5)) - ((length of (APPLES)) / (2))) * ((size) / (11)))\n    change size by ((0.2) * ((200) - (size)))\nend\n\ndefine change costume to (costume)\nif <not <(costume) = (costume [name v])>> then\n    switch costume to (costume)\n    set size to (220) %\nend\n\nwhen I receive [start game v]\nsetup\n\n@text appear\n\nwhen flag clicked\nswitch costume to (text v)\nhide\n\nwhen I receive [start game v]\nforever\n    if <<(Level #) = [1]> or <(Level #) = [2]>> then\n        if <(Level #) = [1]> then\n            go to x: (-108) y: (10)\n            show\n        end\n        if <(Level #) = [2]> then\n            show\n            go to x: (34) y: (-51)\n        end\n    else\n        hide\n    end\nend\n\nwhen I receive [change level v]\nforever\n    if <touching (player v)?> then\n        if <key (e v) pressed?> then\n            broadcast (Text v)\n            stop [this script v]\n        end\n    end\nend\n\n@HP\n\nwhen flag clicked\ngo to x: (-180) y: (155)\nhide\n\nwhen I receive [lose life v]\ngo to x: (-180) y: (155)\nrepeat (10)\n    go to x: ((-180) + (pick random (1) to (-1))) y: ((159) + (pick random (1) to (-1)))\nend\ngo to x: (-180) y: (155)\n\nwhen I receive [start game v]\nshow\nforever\n    if <(Lives) = [0]> then\n        switch costume to (0 v)\n    end\n    if <(Lives) = [1]> then\n        switch costume to (1 v)\n    end\n    if <(Lives) = [2]> then\n        switch costume to (2 v)\n    end\n    if <(Lives) = [3]> then\n        switch costume to (3 v)\n    end\nend\n\n@Transitions\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nset [layers - background v] to [5]\ngo to [front v] layer\n\ngo to x: (0) y: (0)\ngo to [front v] layer\nswitch costume to (mini v)\nset size to (1116) %\nswitch costume to (mask #5 v)\nshow\nrepeat (4)\n    switch costume to (mini v)\n    set size to ((size) / (1.2)) %\n    switch costume to (mask #5 v)\nend\nrepeat (3)\n    switch costume to (mini v)\n    set size to ((size) / (1.2)) %\n    switch costume to (mask #4 v)\nend\nrepeat (2)\n    switch costume to (mini v)\n    set size to ((size) / (1.2)) %\n    switch costume to (mask #3 v)\nend\nrepeat (2)\n    switch costume to (mini v)\n    set size to ((size) / (1.2)) %\n    switch costume to (mask #2 v)\nend\nswitch costume to (mini v)\nset size to (250) %\nrepeat (5)\n    switch costume to (mini v)\n    set size to ((size) / (1.2)) %\n    switch costume to (mask #1 v)\nend\nswitch costume to (black v)\nset size to (100) %\nwait (0.5) seconds\nbroadcast (Start v)\n\nwhen I receive [start v]\ngo to x: (0) y: (0)\ngo to [front v] layer\nswitch costume to (black v)\nset size to (100) %\nshow\nrepeat (5)\n    switch costume to (mini v)\n    set size to ((size) * (1.2)) %\n    switch costume to (mask #1 v)\nend\nset size to ((size) * (0.5)) %\nrepeat (2)\n    switch costume to (mini v)\n    set size to ((size) * (1.2)) %\n    switch costume to (mask #2 v)\nend\nrepeat (2)\n    switch costume to (mini v)\n    set size to ((size) * (1.2)) %\n    switch costume to (mask #3 v)\nend\nrepeat (3)\n    switch costume to (mini v)\n    set size to ((size) * (1.2)) %\n    switch costume to (mask #4 v)\nend\nrepeat (5)\n    switch costume to (mini v)\n    set size to ((size) * (1.2)) %\n    switch costume to (mask #5 v)\nend\nhide\n\nwhen I receive [start game v]\ngo to [front v] layer\nbroadcast (Start v)\n\n@Splash Screen\n\nwhen flag clicked\nswitch costume to (main menu v)\ngo to [front v] layer\nshow\ngo to x: (0) y: (0)\n\nwhen I receive [game over v]\ngo to x: (0) y: (0)\nswitch costume to (game over v)\ngo to [front v] layer\nshow\nbroadcast (Main Menu v)\n\nwhen I receive [start game v]\nhide\n\nwhen I receive [you won v]\nstop all sounds\nswitch costume to (you won v)\nwait (0) seconds\nshow\ngo to [front v] layer\nset x to (0)\nset y to (500)\nrepeat (10)\n    set y to ((y position) / (2))\nend\nwait (1) seconds\nstop [all v]\n\ngo to x: (0) y: (0)\nswitch costume to (you won v)\ngo to [front v] layer\nshow\n\n@Splash image\n\ndefine Stamp Shadow\nchange y by (-18)\nset [brightness v] effect to (-100)\nset [ghost v] effect to (78)\nstamp\nclear graphic effects\nchange y by (18)\n\ndefine Stamp Outline\nset rotation style [don't rotate v]\nset [brightness v] effect to (-100)\nrepeat (8)\n    move (4) steps\n    stamp\n    move (-4) steps\n    turn right (45) degrees\nend\nclear graphic effects\n\nwhen flag clicked\ngo to [back v] layer\nshow\nerase all\nStamp Outline\nStamp Shadow\ngo to x: (0) y: (0)\n\nwhen I receive [start game v]\nhide\n\n@TB\n\nshow\ngo to [front v] layer\n\nwhen flag clicked\nhide\nset [ghost v] effect to (100)\n\n