AFRAID - Platformer

Instructions: WASD, Space, Arrow keys or touch to move the player.\nRed bad\nPurple good, sometimes\nBlue good

@Stage\n\nwhen flag clicked\nbroadcast (ResetPlayer v)\nset [time v] to [0]\nhide variable [time v]\nforever\n    if <(Level) < [10]> then\n        change [time v] by (timer)\n    end\n    reset timer\n    if <[9] < (Level)> then\n        show variable [time v]\n    end\nend\n\nwhen [timer v] > (1)\nbroadcast (Show.Thumbnail v)\n\nwhen flag clicked\nset volume to (30) %\nforever\n    play sound [Only Piano - Loneliness v] until done\nend\n\n@Player\n\nwhen I receive [resetplayer v]\ngo to x: (-200) y: (-75)\nset [ghost v] effect to (0)\nset size to (125) %\nshow\nset [player.xv v] to [0]\nset [player.yv v] to [0]\nset [player.jumpforce v] to [12]\nset [player.walljumpxforce v] to [10]\nset [player.walljumpyforce v] to [12]\nforever\n    set [player.ycoll v] to [0]\n    set [player.wall v] to [0]\n    switch costume to (r v)\n    go to [front v] layer\n    ChangeXv\n    change x by (player.xv)\n    CheckForCollosion\n    if <(collision) = [1]> then\n        if <(player.xv) > [0]> then\n            set [player.wall v] to [right]\n        else\n            set [player.wall v] to [left]\n        end\n        CheckForWall [5]\n    end\n    ChangYv\n    change y by (player.yv)\n    CheckForCollosion\n    if <(collision) = [1]> then\n        ChangeY ((player.yv) / ([abs v] of (player.yv) ))\n    end\n    if <<<<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <key (space v) pressed?>> or <mouse down?>> and <not <(player.ycoll) = [ceiling]>>> then\n        JumpCheck\n    end\n    set [player.x v] to (x position)\n    set [player.y v] to (y position)\n    if <(y position) < [-170]> then\n        broadcast (ResetPlayer v)\n        broadcast (Sound.Death v)\n    end\n    switch costume to (player.direction)\nend\n\ndefine CheckForWall (length)\nrepeat (length)\n    CheckForCollosion\n    if <(collision) = [1]> then\n        change y by (1)\n    end\nend\nCheckForCollosion\nif <(collision) = [1]> then\n    change y by (() - (length))\n    if <(player.xv) > [0]> then\n        ChangeX ([ceiling v] of ((player.xv) / ([abs v] of (player.xv) )) )\n    else\n        ChangeX ([floor v] of ((player.xv) / ([abs v] of (player.xv) )) )\n    end\nend\n\ndefine ChangeY (power)\nif <(power) > [0]> then\n    set [player.ycoll v] to [ceiling]\nelse\n    set [player.ycoll v] to [ground]\nend\nrepeat ([abs v] of (player.yv) )\n    CheckForCollosion\n    if <(collision) = [1]> then\n        change y by (() - (power))\n    end\nend\nset [player.yv v] to [0]\n\ndefine ChangeX (power)\nrepeat ([abs v] of (player.xv) )\n    CheckForCollosion\n    if <(collision) = [1]> then\n        change x by (() - (power))\n    end\nend\nset [player.xv v] to [0]\n\ndefine ChangeXv\nif <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<(Player.X) > (mouse x)> and <mouse down?>>> then\n    change [player.xv v] by (-1)\n    set [player.direction v] to [L]\nend\nif <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<(mouse x) > (Player.X)> and <mouse down?>>> then\n    change [player.xv v] by (1)\n    set [player.direction v] to [R]\nend\nset [player.xv v] to ((player.xv) * (0.85))\n\ndefine ChangYv\nchange [player.yv v] by (-1)\nif <not <(player.yv) > [-20]>> then\n    set [player.yv v] to [-20]\nend\n\ndefine JumpCheck\nif <(player.ycoll) = [ground]> then\n    change [player.yv v] by (player.jumpforce)\nelse\n    if <(player.wall) = [right]> then\n        change [player.xv v] by (() - (player.WallJumpXForce))\n        set [player.yv v] to (player.WallJumpYForce)\n    end\n    if <(player.wall) = [left]> then\n        change [player.xv v] by (player.WallJumpXForce)\n        set [player.yv v] to (player.WallJumpYForce)\n    end\nend\n\ndefine CheckForCollosion\nset [collision v] to [0]\nif <touching (level v)?> then\n    if <touching color (#ff8080)?> then\n        broadcast (ResetPlayer v)\n        broadcast (Sound.Death v)\n    else\n        if <touching color (#000000)?> then\n            set [collision v] to [1]\n        else\n            if <touching color (#ffa4f1)?> then\n                change [player.y v] by (() - (player.yv))\n                set [player.yv v] to ((player.jumpforce) * (1.5))\n                if <<<<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <key (space v) pressed?>> or <mouse down?>> and <not <(player.ycoll) = [ceiling]>>> then\n                    change [player.yv v] by ((player.jumpforce) / (3))\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [show.thumbnail v]\nhide\n\n@PlayerLight\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    go [backward v] (2) layers\n    go to x: (Player.X) y: (Player.Y)\nend\n\nwhen I receive [resetplayer v]\nshow\n\nwhen I receive [show.thumbnail v]\nhide\n\n@Level\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    go [backward v] (1) layers\n    switch costume to (Level)\nend\n\nchange [level v] by (1)\n\n@LevelFinish\n\nwhen flag clicked\nset [level v] to [1]\nforever\n    set [color v] effect to (0)\n    switch costume to (hitbox v)\n    go to [front v] layer\n    turn right (2) degrees\n    go to x: (200) y: (-100)\n    if <<touching (player v)?> and <(Level) < [10]>> then\n        change [level v] by (1)\n        broadcast (ResetPlayer v)\n        wait until <(Player.X) < [0]>\n    end\n    switch costume to (finsh v)\nend\n\n@Thumbnail\n\nwhen flag clicked\nhide\n\nwhen I receive [show.thumbnail v]\ngo to x: (0) y: (0)\nswitch costume to (costume1 v)\nset [color v] effect to (-100)\nset [ghost v] effect to (0)\ngo to [front v] layer\nshow\nhide variable [time v]\nbroadcast (Show.Thumbnail v)\n\n