Christmas Journey // A platformer

Instructions: Use arrow keys or WASD keys to move. Avoid saws and spikes. Reach the flag to move on to the next level. Have Fun!!! Comment your fastest time and how many deaths if you didn't skip. All levels are possible. My fastest record is 55.04 and 6 deaths.

@Stage\n\nwhen flag clicked\nset [music v] to [Yes]\nset [snow v] to [Yes]\nset [sound v] to [Yes]\n\nwhen flag clicked\nforever\n    play sound [music v] until done\nend\n\nwhen flag clicked\nset volume to (50) %\nforever\n    if <(Music) = [Yes]> then\n        set volume to (50) %\n    else\n        set volume to (0) %\n    end\nend\n\nwhen flag clicked\nswitch backdrop to (winter landscape v)\n\n@Calculate Time\n\nwhen I receive [start v]\nset [timer v] to [0]\nforever\n    if <(LEVEL) < [13]> then\n        set [timer v] to (timer)\n    end\nend\n\nwhen I receive [start v]\nset [time v] to [1]\nforever\n    change [time v] by (1)\nend\n\nwhen I receive [skipped v]\nforever\n    set [timer v] to [Skipped]\nend\n\n@Snow\n\nwhen I start as a clone\nshow\nset size to (pick random (60) to (90)) %\ngo to x: (pick random (-240) to (240)) y: (220)\nrepeat (4)\n    change [ghost v] effect by (-20)\nend\nrepeat (2)\n    change y by (-5)\n    change x by (G_Wind)\nend\nrepeat until <<<touching (main v)?> or <<touching (spikes v)?> or <<touching (ground v)?> or <touching (goal v)?>>>> or <touching (_edge_ v)?>>\n    change y by (-5)\n    change x by (G_Wind)\nend\nrepeat (10)\n    if <not <touching color (#ffffff)?>> then\n        change y by (-2)\n        change x by ((G_Wind) / (2.5))\n    end\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nwhen I receive [start v]\nhide\nset [ghost v] effect to (100)\ngo to x: (-240) y: (240)\nforever\n    if <(Snow) = [yes]> then\n        create clone of (_myself_ v)\n        wait (pick random (0.005) to (0.01)) seconds\n    end\nend\n\nwhen I receive [start v]\nforever\n    if <(Snow) = [Yes]> then\n        set [g_wind v] to (pick random (-1) to (1))\n    end\nend\n\n@Trampoline\n\nwhen flag clicked\nhide\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Place Clone At (x) (y)\nset [x v] to (x)\nset [y v] to (y)\nshow\ncreate clone of (_myself_ v)\nswitch costume to (trampoline3 v)\n\nwhen I receive [setup v]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [5]> then\n    Place Clone At [-140] [-123.8]\nend\nif <(LEVEL) = [9]> then\n    Place Clone At [45] [-123.8]\n    Place Clone At [182] [-123.8]\nend\nhide\nset [x v] to [-99999]\n\nwhen I start as a clone\ngo to x: (x) y: (y)\nforever\n    if <touching (main v)?> then\n        broadcast (Bounce v)\n        repeat (3)\n            next costume\n        end\n        switch costume to (trampoline v)\n    end\nend\n\n@Green Flag\n\ndefine Place Clone At (x) (y)\nset [x v] to (x)\nset [y v] to (y)\nshow\ncreate clone of (_myself_ v)\n\nwhen I receive [setup v]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    Place Clone At [210] [-107]\nend\nif <(LEVEL) = [2]> then\n    Place Clone At [210] [55]\nend\nif <(LEVEL) = [3]> then\n    Place Clone At [210] [127]\nend\nif <(LEVEL) = [4]> then\n    Place Clone At [210] [-107]\nend\nif <(LEVEL) = [5]> then\n    Place Clone At [210] [150]\nend\nif <(LEVEL) = [6]> then\n    Place Clone At [-203] [155]\nend\nif <(LEVEL) = [7]> then\n    Place Clone At [210] [140]\nend\nif <(LEVEL) = [8]> then\n    Place Clone At [210] [145]\nend\nif <(LEVEL) = [9]> then\n    Place Clone At [60] [60]\nend\nif <(LEVEL) = [10]> then\n    Place Clone At [210] [-110]\nend\nif <(LEVEL) = [11]> then\n    Place Clone At [192] [-110]\nend\nif <(LEVEL) = [12]> then\n    Place Clone At [210] [110]\nend\nhide\nset [x v] to [-99999999]\n\nwhen flag clicked\nhide\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I start as a clone\ngo to x: (x) y: (y)\ngo to [front v] layer\ngo [backward v] (10) layers\n\n@Ground\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nshow\ngo to x: (0) y: (0)\nforever\n    if <(LEVEL) < [14]> then\n        switch costume to (LEVEL)\n    end\nend\n\n@Spikes\n\ndefine Place Clone At (x) (y)\nset [x v] to (x)\nset [y v] to (y)\nshow\ncreate clone of (_myself_ v)\n\nwhen I receive [setup v]\nset [x v] to [0]\nset [y v] to [0]\nswitch costume to (1 v)\nif <(LEVEL) = [1]> then\n    Place Clone At [-5] [-116.5]\nend\nif <(LEVEL) = [2]> then\n    Place Clone At [130] [45]\nend\nif <(LEVEL) = [6]> then\n    Place Clone At [47] [105]\nend\nif <(LEVEL) = [7]> then\n    Place Clone At [112] [-122]\nend\nif <(LEVEL) = [8]> then\n    Place Clone At [34] [-122]\n    Place Clone At [149] [-122]\nend\nif <(LEVEL) = [9]> then\n    switch costume to (2 v)\n    Place Clone At [63] [-37.8]\nend\nif <(LEVEL) = [10]> then\n    switch costume to (3 v)\n    Place Clone At [57] [-85]\nend\nhide\nset [x v] to [-99999999]\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I start as a clone\ngo to x: (x) y: (y)\n\nwhen I receive [start v]\npoint in direction (90)\ngo to [front v] layer\nhide\n\n@Main\n\ndefine ResetPlayer\ngo to x: (-200) y: (0)\nset [g_isplayerdead? v] to [No]\nset [g_velocity v] to [0]\nset [g_onground v] to [0]\nset [g_gravity v] to [-1]\nset [jumping v] to [0]\n\ndefine MovementControl\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    set [g_speedx v] to [7]\nend\nif <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n    set [g_speedx v] to [-7]\nend\nset [g_speedx v] to ((G_SpeedX) * (0.8))\nif <([abs v] of (G_SpeedX) ) > [0.9]> then\n    MovePlayer (round (G_SpeedX))\nend\n\ndefine Jumping\nif <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n    if <(G_onGround) > [0]> then\n        set [g_onground v] to [0]\n        set [jumping v] to [1]\n        set [g_velocity v] to [15]\n    end\nend\n\nwhen I receive [startgame v]\nshow\nrepeat until <(G_isPlayerDead?) = [Yes]>\n    broadcast (startAllControl v)\n    broadcast (checkPlatformDetection v)\n    broadcast (checkPlayerPosition v)\nend\n\nwhen I receive [startallcontrol v]\nMovementControl\nJumping\nif <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n    change [g_velocity v] by (G_Gravity)\nelse\n    change [g_velocity v] by ((G_Gravity) * (2))\nend\nchange y by (G_Velocity)\n\ndefine CheckHitGround <isjumping?>\nrepeat until <not <touching (ground v)?>>\n    if <isjumping?> then\n        change y by (-1)\n        set [g_velocity v] to [0]\n    else\n        change y by (1)\n        set [g_velocity v] to [0]\n        set [g_onground v] to [1]\n        if <(Jumping) = [1]> then\n            set [jumping v] to [0]\n        end\n    end\nend\n\nwhen I receive [checkplatformdetection v]\nCheckHitGround <(G_Velocity) > [0]>\n\ndefine MovePlayer (sx)\nchange x by (sx)\nset [deviation v] to [0]\nrepeat until <<(deviation) = [8]> or <not <touching (ground v)?>>>\n    change y by (1)\n    change [deviation v] by (1)\nend\nif <touching (ground v)?> then\n    if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n        if <(sx) > [0]> then\n            set [g_speedx v] to [-16]\n        else\n            set [g_speedx v] to [16]\n        end\n        set [g_onground v] to [0]\n        set [jumping v] to [1]\n        set [g_velocity v] to [10]\n        change x by (G_SpeedX)\n    else\n        set [g_speedx v] to [0]\n    end\nend\nif <(deviation) = [8]> then\n    change x by ((0) - (sx))\n    change y by ((0) - (deviation))\nend\n\nwhen I receive [checkplayerposition v]\nforever\n    if <<<touching (spikes v)?> or <(y position) < [-170]>> or <touching (saws v)?>> then\n        broadcast (Die v)\n    end\n    if <<touching (green flag v)?> and <(LEVEL) < [13]>> then\n        change [level v] by (1)\n        broadcast (startNewLevel v)\n    end\n    if <(G_isPlayerDead?) = [Yes]> then\n        broadcast (Die v)\n        wait (0.1) seconds\n        ResetPlayer\n        broadcast (startGame v)\n    end\nend\n\nwhen I receive [die v]\nif <(G_isPlayerDead?) = [No]> then\n    set [g_isplayerdead? v] to [Yes]\n    change [deaths v] by (1)\nend\n\nwhen I receive [startnewlevel v]\nResetPlayer\nbroadcast (startGame v)\n\nwhen I receive [startnewlevel v]\nbroadcast (Reset v) and wait\nbroadcast (Setup v) and wait\n\nwhen [m v] key pressed\nset [g_mouseposition v] to (join (mouse x) (join [ ,] (mouse y)))\nshow variable [g_mouseposition v]\n\nwhen I receive [bounce v]\nset [g_velocity v] to [30]\n\nif <<(TIMER) < (item (3) of [high score table v])> or <(length of [high score table v]) = [2]>> then\n    insert (join (TIMER) (join [:] (username))) at (3) of [high score table v] \n    stop [this script v]\nend\nif <<(TIMER) < (item (4) of [high score table v])> or <(length of [high score table v]) = [3]>> then\n    insert (join (TIMER) (join [:] (username))) at (4) of [high score table v] \n    stop [this script v]\nend\nif <<(TIMER) < (item (5) of [high score table v])> or <(length of [high score table v]) = [4]>> then\n    insert (join (TIMER) (join [:] (username))) at (5) of [high score table v] \n    stop [this script v]\nend\n\nwhen I receive [start v]\nset size to (60) %\nset [ghost v] effect to (100)\nset [level v] to [1]\nset [deaths v] to [0]\nshow variable [deaths v]\nshow variable [timer v]\nshow variable [level v]\nResetPlayer\nbroadcast (startGame v)\nbroadcast (startNewLevel v)\n\nwhen flag clicked\nhide\n\n@Player\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nshow\ngo to [front v] layer\npoint in direction (90)\nforever\n    go to (main v)\nend\n\nwhen I receive [start v]\nforever\n    if <not <<key (up arrow v) pressed?> or <<key (right arrow v) pressed?> or <key (left arrow v) pressed?>>>> then\n        switch costume to (player5 v)\n    end\nend\n\nwhen I receive [start v]\nforever\n    if <<key (w v) pressed?> or <<key (space v) pressed?> or <key (up arrow v) pressed?>>> then\n        switch costume to (player6 v)\n    end\n    if <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n        switch costume to (player2 v)\n    end\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        switch costume to (player v)\n    end\n    if <key (down arrow v) pressed?> then\n        switch costume to (player v)\n    end\n    if <<key (left arrow v) pressed?> and <key (up arrow v) pressed?>> then\n        switch costume to (player3 v)\n    end\n    if <<key (right arrow v) pressed?> and <key (up arrow v) pressed?>> then\n        switch costume to (player4 v)\n    end\nend\n\nwhen I receive [die v]\nrepeat (4)\n    change [ghost v] effect by (25)\nend\nclear graphic effects\nshow\n\n@Thumb\n\nwhen flag clicked\nshow\nswitch costume to (1 v)\nforever\n    go to [front v] layer\n    set [ghost v] effect to (100)\nend\n\n@Menu\n\ndefine Create a clone at x: (x) y: (y)\ngo to x: (x) y: (y)\nchange [clone# v] by (1)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nshow\nforever\n    if <(clone#) = [1]> then\n        switch costume to (text v)\n    end\n    if <(clone#) = [2]> then\n        switch costume to (button v)\n    end\n    if <(clone#) = [3]> then\n        if <(Music) = [Yes]> then\n            switch costume to (musicon v)\n        else\n            switch costume to (musicoff v)\n        end\n    end\n    if <(clone#) = [4]> then\n        if <(Sound) = [Yes]> then\n            switch costume to (soundon v)\n        else\n            switch costume to (soundoff v)\n        end\n    end\n    if <(clone#) = [5]> then\n        if <(Snow) = [Yes]> then\n            switch costume to (snowon v)\n        else\n            switch costume to (snowoff v)\n        end\n    end\nend\n\nwhen I start as a clone\nshow\nforever\n    if <touching (mouse-pointer v)?> then\n        if <(clone#) = [2]> then\n            Change Size By [110]\n        end\n        if <mouse down?> then\n            if <not <(clone#) = [1]>> then\n                if <(clone#) = [2]> then\n                    if <(Sound) = [Yes]> then\n                        start sound [click v]\n                    end\n                else\n                    if <(Sound) = [Yes]> then\n                        start sound [click2 v]\n                    end\n                end\n            end\n            if <(clone#) = [2]> then\n                broadcast (Start v)\n                delete this clone\n            end\n            if <(clone#) = [3]> then\n                if <(Music) = [Yes]> then\n                    set [music v] to [No]\n                else\n                    set [music v] to [Yes]\n                end\n            end\n            if <(clone#) = [4]> then\n                if <(Sound) = [Yes]> then\n                    set [sound v] to [No]\n                else\n                    set [sound v] to [Yes]\n                end\n            end\n            if <(clone#) = [5]> then\n                if <(Snow) = [Yes]> then\n                    set [snow v] to [No]\n                else\n                    set [snow v] to [Yes]\n                end\n            end\n            wait until <not <mouse down?>>\n        end\n    else\n        if <not <(clone#) > [2]>> then\n            Change Size By [95]\n        else\n            Change Size By [90]\n        end\n    end\nend\n\nwhen I receive [start v]\nhide\ndelete this clone\n\ndefine Change Size By (size)\nchange size by (((size) - (size)) / (4))\n\nwhen I start as a clone\nforever\n    if <(clone#) = [1]> then\n        set size to (100) %\n        wait (0.5) seconds\n    end\nend\n\nwhen flag clicked\nhide variable [level v]\nhide variable [timer v]\nhide variable [deaths v]\nhide\nset size to (100) %\nset [clone# v] to [0]\nCreate a clone at x: [0] y: [80]\nCreate a clone at x: [6] y: [-69]\nset size to (90) %\nCreate a clone at x: [0] y: [-131]\nCreate a clone at x: [-131] y: [-131]\nCreate a clone at x: [127] y: [-131]\nset size to (100) %\nshow\nforever\n    go to x: (0) y: (0)\n    switch costume to (bg v)\n    go to [back v] layer\nend\n\n@Saws\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Create A Clone At x: (x) y: (y) Speed: (speed) Distance: (distance)\nset [x v] to (x)\nset [y v] to (y)\nset [speed v] to (speed)\nset [distance v] to (distance)\ngo to [back v] layer\ncreate clone of (_myself_ v)\n\nwhen I receive [setup v]\nhide\nswitch costume to (saw v)\nset size to (135) %\nset [type v] to [1]\nif <(LEVEL) = [11]> then\n    Create A Clone At x: [-80] y: [-140] Speed: [3] Distance: [1]\n    Create A Clone At x: [80] y: [-140] Speed: [3] Distance: [1]\nend\nif <(LEVEL) = [12]> then\n    Create A Clone At x: [-50] y: [-140] Speed: [3] Distance: [100]\n    set [type v] to [2]\n    Create A Clone At x: [182] y: [-30] Speed: [3] Distance: [50]\nend\n\nwhen I start as a clone\nshow\nforever\n    turn right (8) degrees\n    if <(type) = [1]> then\n        go to x: ((x) + (([cos v] of ((Time) * (speed)) ) * (distance))) y: (y)\n    else\n        go to x: (x) y: ((y) + (([cos v] of ((Time) * (speed)) ) * (distance)))\n    end\nend\n\n@Skip\n\nwhen flag clicked\nhide\n\nwhen this sprite clicked\nchange [level v] by (1)\nbroadcast (startNewLevel v)\nbroadcast (Skipped v)\n\nwhen I receive [start v]\nshow\nswitch costume to (costume1 v)\ngo to x: (-196) y: (-154)\nforever\n    if <touching (mouse-pointer v)?> then\n        set [brightness v] effect to (10)\n    else\n        set [brightness v] effect to (0)\n    end\nend\n\nwhen I receive [start v]\nwait until <(LEVEL) = [18]>\nhide\n\n@Clouds\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nset [side v] to (pick random (1) to (2))\nshow\nset [ghost v] effect to (pick random (20) to (25))\ngo to [back v] layer\nswitch costume to (pick random (1) to (2))\nif <(side) = [1]> then\n    go to x: (300) y: (pick random (150) to (100))\n    repeat until <(x position) < [-290]>\n        go to [back v] layer\n        change x by (-0.5)\n    end\n    delete this clone\nend\nif <(side) = [2]> then\n    go to x: (-300) y: (pick random (150) to (100))\n    repeat until <(x position) > [270]>\n        go to [back v] layer\n        change x by (0.5)\n    end\n    delete this clone\nend\n\nwhen I receive [start v]\nforever\n    create clone of (_myself_ v)\n    wait (pick random (30) to (45)) seconds\nend\n\n