Mobile Platformer

Instructions: Down on joystick to attack, this is my second project ever!

@Stage\n\nwhen flag clicked\nswitch backdrop to (backdrop1 v)\n\n@ground\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [level v] to [Intro]\nset [ghost v] effect to (0)\nwait (1) seconds\nrepeat (25)\n    change [ghost v] effect by (4)\nend\nset [level v] to [1]\nset [ghost v] effect to (0)\n\nwhen flag clicked\nforever\n    switch costume to (Level)\nend\n\nwhen this sprite clicked\nif <(Level) = [Settings]> then\n    set [level v] to (Old Level)\nend\n\n@Joystick\n\nwhen flag clicked\nforever\n    if <<mouse down?> and <<(distance to [mouse-pointer v]) < [400]> and <[20] < (distance to [mouse-pointer v])>>> then\n        point towards (mouse-pointer v)\n        switch costume to (joystick move v)\n    else\n        switch costume to (joystick rest v)\n    end\nend\n\nwhen flag clicked\nset [joystick size v] to [50]\nforever\n    set size to ((2) * (Joystick Size)) %\n    if <([costume name v] of [ground v]) = [Settings]> then\n        set drag mode [draggable v]\n        show variable [joystick size v]\n        show\n    else\n        set drag mode [not draggable v]\n        hide variable [joystick size v]\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [Intro]> then\n        hide\n    else\n        set [ghost v] effect to (50)\n        show\n    end\nend\n\nwhen backdrop switches to [backdrop1 v]\nforever\n    if <mouse down?> then\n        show\n        go to (mouse-pointer v)\n        wait until <not <mouse down?>>\n    else\n        hide\n    end\nend\n\n@player\n\ndefine platform physics (jump height) (gravity) (friction) (movement speed) (wall jump vm) (wall jump hm)\nchange y by (y vel)\nif <touching (ground v)?> then\n    repeat ([abs v] of (y vel) )\n        if <touching (ground v)?> then\n            change y by ((-1) * (([abs v] of (y vel) ) / (y vel)))\n        end\n    end\n    if <<key (up arrow v) pressed?> or <<<([costume name v] of [joystick v]) = [Joystick Move]> and <<([direction v] of [joystick v]) < [50]> and <[-50] < ([direction v] of [joystick v])>>> and <not <(y vel) > [0]>>>> then\n        set [y vel v] to (jump height)\n    else\n        set [y vel v] to [0]\n    end\nelse\n    change [y vel v] by (gravity)\nend\nif <<key (right arrow v) pressed?> or <<([costume name v] of [joystick v]) = [Joystick Move]> and <<([direction v] of [joystick v]) < [179]> and <[1] < ([direction v] of [joystick v])>>>> then\n    change [x vel v] by (movement speed)\nend\nif <<key (right arrow v) pressed?> or <<([costume name v] of [joystick v]) = [Joystick Move]> and <<([direction v] of [joystick v]) < [-1]> and <[-179] < ([direction v] of [joystick v])>>>> then\n    change [x vel v] by ((-1) * (movement speed))\nend\nchange x by (x vel)\nif <touching (ground v)?> then\n    set [old y v] to (y position)\n    repeat (([abs v] of (x vel) ) + (1))\n        if <touching (ground v)?> then\n            change y by (1)\n        end\n    end\n    if <touching (ground v)?> then\n        set y to (old y)\n        repeat ([ceiling v] of ([abs v] of (x vel) ) )\n            if <touching (ground v)?> then\n                change x by ((-1) * (([abs v] of (x vel) ) / (x vel)))\n            end\n        end\n        if <<([costume name v] of [joystick v]) = [Joystick Move]> and <<([direction v] of [joystick v]) < [50]> and <[-50] < ([direction v] of [joystick v])>>> then\n            if <(x vel) < [0]> then\n                set [x vel v] to [0]\n                if <<([costume name v] of [joystick v]) = [Joystick Move]> and <<([direction v] of [joystick v]) < [-1]> and <[-179] < ([direction v] of [joystick v])>>> then\n                    set [x vel v] to (wall jump hm)\n                    set [y vel v] to (wall jump vm)\n                end\n            else\n                set [x vel v] to [0]\n                if <<([costume name v] of [joystick v]) = [Joystick Move]> and <<([direction v] of [joystick v]) < [179]> and <[1] < ([direction v] of [joystick v])>>> then\n                    set [x vel v] to ((-1) * (wall jump hm))\n                    set [y vel v] to (wall jump vm)\n                end\n            end\n        end\n    end\nend\nset [x vel v] to ((x vel) * (friction))\n\nwhen flag clicked\ngo to x: (-180) y: (-50)\nshow\nset [y vel v] to [0]\nset [x vel v] to [0]\nforever\n    platform physics (12) (-1) (0.9) (1) (8) (8)\nend\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    if <[230] < (x position)> then\n        broadcast (Level Complete v)\n        wait (0.1) seconds\n        go to x: (-180) y: (-50)\n        set [y vel v] to [0]\n        set [x vel v] to [0]\n        change [level v] by (1)\n    end\n    if <(y position) < [-180]> then\n        broadcast (Dead v)\n        set [y vel v] to [0]\n        set [x vel v] to [0]\n        go to x: (-180) y: (-50)\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [Intro]> then\n        hide\n    else\n        show\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching color (#ff0000)?> then\n        broadcast (Dead v)\n    end\nend\n\nwhen flag clicked\nforever\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nset [ghost v] effect to (25)\nrepeat (3)\n    change [color v] effect by (25)\nend\ndelete this clone\n\nwhen flag clicked\nforever\n    wait until <<([costume name v] of [joystick v]) = [Joystick Move]> and <<([direction v] of [joystick v]) < [50]> and <[-50] < ([direction v] of [joystick v])>>>\n    wait until <<([costume name v] of [joystick v]) = [Joystick Move]> and <<([direction v] of [joystick v]) < [-120]> or <[120] < ([direction v] of [joystick v])>>>\n    switch costume to (attack v)\n    set [y vel v] to [20]\n    wait (0.1) seconds\n    set [y vel v] to [-20]\n    wait until <(Ground Touching?) = [Yes]>\n    broadcast (Slam v)\n    wait (0.5) seconds\n    switch costume to (costume1 v)\nend\n\nwhen flag clicked\nforever\n    if <<touching (sprite1 v)?> and <(costume [name v]) = [costume1]>> then\n        broadcast (Dead v)\n    end\nend\n\n@Settings\n\nwhen flag clicked\ngo to x: (220) y: (165)\nset size to (50) %\nforever\n    go to [front v] layer\n    if <(Level) = [Intro]> then\n        hide\n    else\n        show\n    end\n    if <touching (mouse-pointer v)?> then\n        set size to (50) %\n    else\n        set size to (40) %\n    end\nend\n\nwhen this sprite clicked\nset [old level v] to (Level)\nset [level v] to [Settings]\n\n@Slam\n\nwhen flag clicked\nhide\n\nwhen I receive [slam v]\ngo to (player v)\nset size to (50) %\ngo to [back v] layer\nshow\nrepeat (5)\n    change size by (10)\nend\nhide\n\n@Bottom\n\nwhen flag clicked\nforever\n    go to (player v)\n    set [ghost v] effect to (100)\n    if <touching (ground v)?> then\n        set [ground touching? v] to [Yes]\n    else\n        set [ground touching? v] to [No]\n    end\nend\n\n@Sprite1\n\nwhen flag clicked\ngo to x: (-198) y: (-48)\nforever\n    set size to (50) %\n    if <([x position v] of [player v]) > (x position)> then\n        change [xv v] by (1)\n    else\n        if <([x position v] of [player v]) < (x position)> then\n            change [xv v] by (-1)\n        end\n    end\n    set [xv v] to ((Xv) * (0.9))\n    change x by (Xv)\n    if <touching color (#000000)?> then\n        change y by (1)\n        if <touching color (#000000)?> then\n            change y by (1)\n            if <touching color (#000000)?> then\n                change y by (1)\n                if <touching color (#000000)?> then\n                    change y by (1)\n                    if <touching color (#000000)?> then\n                        change y by (1)\n                        if <touching color (#000000)?> then\n                            change x by ((Xv) * (-1))\n                            change y by (-5)\n                            if <([x position v] of [player v]) > (pick random (1) to (-300))> then\n                                if <not <touching color (#00ff55)?>> then\n                                    \n                                        set [xv v] to [-5]\n                                    else\n                                        set [xv v] to [5]\n                                    end\n                                    set [yv v] to [10]\n                                end\n                            else\n                                set [xv v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    change [yv v] by (-1)\n    change y by (Yv)\n    if <touching color (#000000)?> then\n        change y by ((Yv) * (-1))\n        set [yv v] to [0]\n    end\n    change y by (-1)\n    if <touching color (#000000)?> then\n        if <touching color (#000000)?> then\n            set [yv v] to [15]\n        end\n    end\n    change y by (1)\nend\n\nwhen flag clicked\ngo to x: (-198) y: (-48)\nforever\n    if <(Level) = [2]> then\n        show\n        go to x: (200) y: (150)\n        wait until <not <(Level) = [2]>>\n    else\n        hide\n        go to x: (1000) y: (1000)\n    end\nend\n\nwhen flag clicked\ngo to x: (-198) y: (-48)\nforever\n    if <<touching (slam v)?> or <<([costume name v] of [player v]) = [Attack]> and <touching (player v)?>>> then\n        go to x: (200) y: (150)\n    end\nend\n\n