Cowboy - A Pixel Platformer (Beta 1.0.1)

Instructions: Woo! Top-Loved! If you really enjoyed, follow me! :D\n\nTo-Do List:\n\n[ ] Add more levels\n[ ] Add coins\n[ ] Add crates and barrels\n[ ] Add more enemies\n[ ] Add a health system\n[ ] Add saloons and buildings\n[ ] 100% more potatoes   **Very Important**\n[ ] Add a mini-map (suggested by @Bw24)\n[ ] Add checkpoints (suggested by many)

@Stage\n\nwhen I receive [greenflag v]\nforever\n    play sound [djgl.mp3 v] until done\nend\n\nwhen I receive [start v]\nstop [other scripts in stage v]\nstop all sounds\nforever\n    play sound [df.mp3 v] until done\nend\n\n@Player\n\nset [falling? v] to [12]\n\nset [falling? v] to [0]\n\nset [falling? v] to [0]\n\nset [falling? v] to [12]\n\nwhen I receive [go v]\nInitialPos\nbroadcast (reset v) and wait\nMainLoop\n\ndefine if touching\nif <<<<key (r v) pressed?> or <<touching (enemies v)?> or <touching (obstacles v)?>>> or <(ScrollY) < [-480]>> and <not <(PlayerGhost?) = [1]>>> then\n    set [restart? v] to [1]\nend\n\ndefine None\nif <not <(direction) = (dir)>> then\n    point in direction (dir)\nend\n\ndefine None\nset [slope v] to [1]\nrepeat until <<not <touching (ground v)?>> or <(Slope) > (max)>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <(Slope) > (max)> then\n    change y by (() - (max))\n    change x by (() - (Xv))\n    if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n        if <(Xv) > [0]> then\n            set [xv v] to [-7]\n        else\n            set [xv v] to [7]\n        end\n        set [yv v] to [10]\n    else\n        set [xv v] to [0]\n    end\nend\n\nwhen flag clicked\nhide\n\ndefine Move\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    change [xv v] by (newspeed)\n    set [dir v] to [90]\n    change [frame v] by (0.4)\nelse\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n        change [xv v] by (() - (newspeed))\n        set [dir v] to [-90]\n        change [frame v] by (0.4)\n    else\n        set [frame v] to [0]\n    end\nend\nset [xv v] to ((Xv) * (0.9))\nchange x by (Xv)\nswitch costume to (hitbox v)\nPoint (90)\nif touching\nSlope (5)\nchange [yv v] by (ngravatiy)\nchange y by (Yv)\nif touching\nif <touching (ground v)?> then\n    change y by (() - (Yv))\n    if <<(Yv) < [0]> and <<key (up arrow v) pressed?> or <key (w v) pressed?>>> then\n        set [yv v] to (newjumphight)\n        set [falling? v] to [12]\n    else\n        set [yv v] to [0]\n        set [falling? v] to [0]\n    end\nend\nchange [scrollx v] by (x position)\nchange [scrolly v] by (y position)\ngo to x: (0) y: (0)\nswitch costume to (pixilart-local\(3\) v)\nPoint (dir)\nSet Costume\n\ndefine MainLoop\nforever\n    if <(Restart?) = [1]> then\n        InitialPos\n        set [health v] to [1]\n        set [xv v] to [0]\n        set [yv v] to [0]\n        set [restart? v] to [0]\n    end\n    Move\n    broadcast (position v) and wait\nend\n\ndefine Set Costume\nif <(falling?) < [6]> then\n    if <(frame) = [0]> then\n        switch costume to (stand v)\n    else\n        switch costume to ([floor v] of ((4) + ((frame) mod (8))) )\n    end\nelse\n    if <(Yv) > [0]> then\n        switch costume to (jump_1 v)\n    else\n        switch costume to (fall_1 v)\n    end\nend\n\nwhen I receive [reset v]\nset size to (200) %\nshow\nswitch costume to (pixilart-local\(3\) v)\nset [playerghost? v] to [0]\nset [health v] to [1]\nset [touching range v] to [5]\nset [newspeed v] to [0.8]\nset [newjumphight v] to [15]\nset [xv v] to [0]\nset [yv v] to [0]\ngo to x: (0) y: (0)\nset [ngravatiy v] to [-1]\nset [restart? v] to [0]\n\nInitialPos\n\ndefine if touching\n\ndefine InitialPos\nset [scrollx v] to [-609]\nset [scrolly v] to [257]\n\nwait until <not <touching (enemies v)?>>\n\nswitch costume to (stand v)\n\nwait (1) seconds\n\nif  then\nend\n\nwait until <not >\n\nwait (0.1) seconds\nwait (0.1) seconds\n\nbroadcast (reset v)\n\nif <not <(PlayerGhost?) = [1]>> then\nend\n\nbroadcast (go v)\n\nwhen I receive [start v]\nbroadcast (go v)\n\npoint in direction (90)\nset rotation style [left-right v]\n\nwhen flag clicked\nforever\n    if <touching (sign v)?> then\n        set [touchingsign? v] to [1]\n    else\n        set [touchingsign? v] to [0]\n    end\n    if <touching (sprite5 v)?> then\n        set [touchinghorse? v] to [1]\n    else\n        set [touchinghorse? v] to [0]\n    end\nend\n\n@Ground\n\nwhen flag clicked\nhide\n\nwhen I receive [reset v]\nswitch costume to (costume2 v)\ngo to x: (() - (ScrollX)) y: (() - (ScrollY))\nset size to (300) %\nswitch costume to (costume1 v)\nshow\n\nset size to (300) %\n\nwhen I receive [position v]\ngo to x: (() - (ScrollX)) y: (() - (ScrollY))\n\n@Arms\n\ndefine Move\n\nwhen flag clicked\nforever\nend\n\nset size to (400) %\n\nforever\n    set [what? v] to []\nend\n\nset [falling? v] to [12]\n\nset [falling? v] to [0]\n\nset [falling? v] to [0]\n\nset [falling? v] to [12]\n\nchange [frame v] by (0.3)\nchange [xv v] by (newspeed)\n\nchange [frame v] by (0.3)\n\nchange [xv v] by (() - (newspeed))\n\ndefine None\npoint in direction (dir)\n\nif <not <(direction) = (dir)>> then\nend\n\nif  then\nelse\nend\n\nwhen I receive [start v]\nshow\nforever\n    set rotation style [left-right v]\n    go to x: (0) y: (0)\n    Point ([direction v] of [player v])\n    if <not <key (space v) pressed?>> then\n        switch costume to ([costume name v] of [player v])\n    else\n        switch costume to (shoot v)\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [greenflag v]\nhide\n\nwhen flag clicked\nforever\n    go to [front v] layer\nend\n\nwhen I receive [level complete v]\nhide\n\n@Sprite2\n\ndefine None\nset rotation style [left-right v]\npoint in direction (direction)\n\nwhen I receive [go v]\nforever\n    go to x: (0) y: (0)\n    set size to (200) %\n    if <key (space v) pressed?> then\n        show\n        Aim ([direction v] of [player v])\n    else\n        hide\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [greenflag v]\nhide\n\n@Enemies\n\nwhen flag clicked\nhide\n\nwhen I receive [reset v]\ndelete (all) of [enemyhealth v]\nset rotation style [left-right v]\nset size to (200) %\nset [clone? v] to [1]\nEnemy (165) (153) (3) (165) (5) (3) (1)\nEnemy (333) (489) (3) (333) (222) (3) (2)\nEnemy (-160) (-328) (3) (-27) (-160) (3) (3)\nEnemy (-162) (9) (3) (-162) (-313) (3) (4)\nEnemy (-313) (9) (3) (-162) (-313) (3) (5)\nset [clone? v] to [0]\n\ndefine None\nset [sx v] to (speed)\nset [myx v] to (x)\nset [myy v] to (y)\nset [maxx v] to (maxx)\nset [minx v] to (minx)\nset [enemy# v] to (enemy#)\ninsert (health) at (enemy#) of [enemyhealth v] \ncreate clone of (_myself_ v)\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [greenflag v]\ndelete this clone\n\nwhen I receive [position v]\nif <(Clone?) = [1]> then\n    Position\nend\n\ndefine None\nif <not <(direction) = (dir)>> then\n    point in direction (dir)\nend\n\nwhen I start as a clone\nshow\nforever\n    set [ghost? v] to [0]\n    if <<touching (sprite12 v)?> and <not <(Ghost?) = [1]>>> then\n        wait until <not <touching (sprite12 v)?>>\n        set [ghost? v] to [1]\n        replace item (Enemy#) of [enemyhealth v] with ((item (Enemy#) of [enemyhealth v]) - (1))\n        repeat (2)\n            change [ghost v] effect by (50)\n            wait (0.1) seconds\n            change [ghost v] effect by (-50)\n            wait (0.1) seconds\n        end\n    end\n    if <(item (Enemy#) of [enemyhealth v]) = [0]> then\n        hide\n    end\nend\n\ndefine Position\nif <(sX) > [0]> then\n    Point (90)\nelse\n    Point (-90)\nend\nchange [myx v] by (sX)\nif <<(myX) > (MaxX)> or <(myX) < (MinX)>> then\n    set [sx v] to (() - (sX))\nend\ngo to x: ((myX) - (ScrollX)) y: ((myY) - (ScrollY))\n\n@Outline\n\nwhen I receive [start v]\ngo to [front v] layer\nshow\nforever\n    go to x: (0) y: (0)\nend\n\nwhen flag clicked\nhide\n\n@Tileset\n\n@Parallax Background\n\nchange y by (10)\n\nwhen flag clicked\nhide\n\nwhen I receive [greenflag v]\nhide\n\nwhen I receive [start v]\nshow\nswitch costume to (costume1 v)\nset size to (200) %\nswitch costume to (pixel v)\nforever\n    go to x: ((ScrollX) / (-5)) y: (90)\nend\n\n@Sprite7\n\nwhen I receive [position v]\n\ngo to x: (() - (ScrollX)) y: (() - (ScrollY))\n\n@Obstacles\n\nwhen flag clicked\nhide\n\nwhen I receive [reset v]\nswitch costume to (costume2 v)\ngo to x: (() - (ScrollX)) y: (() - (ScrollY))\nset size to (300) %\nswitch costume to (costume1 v)\nshow\n\nset size to (300) %\n\nwhen I receive [position v]\ngo to x: (() - (ScrollX)) y: (() - (ScrollY))\n\n@Sprite10\n\nwhen flag clicked\n\nforever\n    go to x: (152) y: (138)\n    switch costume to (Health)\nend\n\n@Sprite11\n\n@Sprite12\n\nwhen I start as a clone\nshow\nset rotation style [left-right v]\ngo to x: (0) y: (0)\nset [startscrolly v] to (ScrollY)\nrepeat until <touching (_edge_ v)?>\n    move (10) steps\n    set y to ((startScrollY) - (ScrollY))\nend\ndelete this clone\n\nwhen flag clicked\nhide\nforever\n    if <key (space v) pressed?> then\n        point in direction ([direction v] of [player v])\n        create clone of (_myself_ v)\n        wait until <not <key (space v) pressed?>>\n    end\nend\n\n@Sprite14\n\nwhen I receive [greenflag v]\nset size to (210) %\ngo to [front v] layer\nshow\npoint in direction (90)\ngo to x: (0) y: (240)\nrepeat (10)\n    change y by (((20) - (y position)) * (0.1))\nend\nset [sine v] to [0]\nforever\n    go to x: (0) y: ((([sin v] of (X) ) * (5)) + (80))\n    change [x v] by (2)\nend\n\nbroadcast (Greenflag v)\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nset size to (100) %\n\nwhen I receive [start v]\nrepeat (5)\n    change y by (((240) - (y position)) * (0.1))\nend\nhide\n\n@Sprite9\n\nwhen flag clicked\nhide\n\nshow\n\nwhen I receive [greenflag v]\n\ngo to [front v] layer\n\nturn left (15) degrees\n\nmove (10) steps\n\n@Play Button\n\nwhen I receive [greenflag v]\ngo to [front v] layer\nset size to (210) %\nshow\npoint in direction (90)\ngo to x: (-30) y: (240)\nrepeat (10)\n    change y by (((-130) - (y position)) * (0.1))\nend\nset [sine v] to [0]\n\nwhen flag clicked\nhide\n\nwhen I receive [greenflag v]\nforever\n    if <touching (mouse-pointer v)?> then\n        repeat (4)\n            change size by (((20) - (y position)) * (0.2))\n        end\n        change x by (((-60) - (y position)) * (0.1))\n        wait until <not <touching (mouse-pointer v)?>>\n        repeat (4)\n            change size by (((-20) - (y position)) * (0.2))\n        end\n    end\n    set size to (210) %\n    go to x: (-30) y: (-21)\nend\n\nwhen this sprite clicked\nbroadcast (Start v)\n\nwait (0.1) seconds\n\nwhen I receive [start v]\nstop [other scripts in sprite v]\nrepeat (10)\n    change y by (((240) - (y position)) * (0.1))\nend\nhide\n\n@Intro\n\nwhen flag clicked\nset volume to (100) %\nstart sound [Through The Fire and Flames 8 Bit Cover Tribute to Dragonforce - 8 Bit Universe.mp3 v]\nshow\nswitch costume to (round red large v)\ngo to x: (-150) y: (0)\nstart sound [Whoosh sound effects.mp3 v]\nrepeat until <(round (x position)) = [-100]>\n    change x by (((-100) - (x position)) / (5))\nend\ngo to x: (-100) y: (0)\ncreate clone of (_myself_ v)\nwait (2) seconds\ngo to x: (-100) y: (0)\nrepeat (1)\n    repeat (6)\n        change y by (1)\n    end\n    repeat (3)\n        change y by (2)\n    end\n    repeat (2)\n        change y by (3)\n    end\n    repeat (2)\n        change y by (-3)\n    end\n    repeat (3)\n        change y by (-2)\n    end\n    repeat (6)\n        change y by (-1)\n    end\nend\nrepeat until <(round (x position)) = [-129]>\n    change x by (((-129) - (x position)) / (5))\n    change [ghost v] effect by (10)\nend\ngo to x: (-129) y: (0)\nhide\nrepeat (15)\n    change volume by (-7)\n    wait (0.2) seconds\nend\nbroadcast (Greenflag v)\n\nwhen I start as a clone\nswitch costume to (costume1 v)\ngo to x: (-138) y: (0)\nstart sound [Whoosh sound effects.mp3 v]\nrepeat until <(round (x position)) = [70]>\n    change x by (((70) - (x position)) / (5))\nend\ngo to x: (70) y: (0)\nstart sound [smb3_coin v]\nwait (3) seconds\nstart sound [Whoosh sound effects.mp3 v]\nrepeat until <(round (x position)) = [-25]>\n    change x by (((-25) - (x position)) / (5))\nend\nrepeat (1)\n    repeat (6)\n        change y by (1)\n    end\n    repeat (3)\n        change y by (2)\n    end\n    repeat (2)\n        change y by (3)\n    end\n    repeat (2)\n        change y by (-3)\n    end\n    repeat (3)\n        change y by (-2)\n    end\n    repeat (6)\n        change y by (-1)\n    end\nend\nrepeat until <(round (x position)) = [-300]>\n    change x by (((-300) - (x position)) / (5))\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nrepeat (3)\n    change y by (-1)\nend\n\ngo to x: (-300) y: (0)\nset volume to (100) %\ndelete this clone\n\nstop all sounds\n\nrepeat (3)\n    change y by (2)\nend\nrepeat (2)\n    change y by (3)\nend\nrepeat (2)\n    change y by (3)\nend\nrepeat (3)\n    change y by (2)\nend\n\nwhen I receive [start v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@Sprite15\n\nwhen I receive [greenflag v]\nshow\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nhide\n\n@Sign\n\nwhen I receive [greenflag v]\ndelete this clone\n\ndefine None\n\nEnemy (165) (153) (3) (165) (5) (3) (1)\nEnemy (333) (489) (3) (333) (222) (3) (2)\nEnemy (-160) (-328) (3) (-27) (-160) (3) (3)\nEnemy (-162) (9) (3) (-162) (-313) (3) (4)\nEnemy (-313) (9) (3) (-162) (-313) (3) (5)\n\nwhen flag clicked\nhide\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine None\nset [sx v] to (speed)\nset [myx v] to (x)\nset [myy v] to (y)\nset [maxx v] to (max x)\nset [minx v] to (min x)\nset [enemy# v] to (message #)\ncreate clone of (_myself_ v)\n\nwhen I receive [position v]\nif <(Clone?) = [1]> then\n    Position\nend\n\nwhen I receive [reset v]\ndelete (all) of [enemyhealth v]\nset rotation style [left-right v]\nset size to (200) %\nset [clone? v] to [1]\nSign (-565) (163) (0) (-565) (-565) (1)\nSign (-110) (163) (0) (-110) (-110) (2)\nSign (157) (163) (0) (157) (157) (3)\nSign (542) (499) (0) (542) (542) (4)\nset [clone? v] to [0]\n\nwhen I start as a clone\ngo [backward v] (3) layers\nshow\nforever\n    if <touching (player v)?> then\n        wait until <key (x v) pressed?>\n        broadcast (Text v)\n        set [text# v] to (Enemy#)\n        wait until <not <touching (player v)?>>\n        broadcast (HideTest v)\n    end\nend\n\ndefine Position\nif <(sX) > [0]> then\n    Point (90)\nelse\n    Point (-90)\nend\nchange [myx v] by (sX)\nif <<(myX) > (MaxX)> or <(myX) < (MinX)>> then\n    set [sx v] to (() - (sX))\nend\ngo to x: ((myX) - (ScrollX)) y: ((myY) - (ScrollY))\n\ndefine None\nif <not <(direction) = (dir)>> then\n    point in direction (dir)\nend\n\n@Sprite1\n\ngo to x: (286) y: (118)\n\nwhen flag clicked\nforever\n    repeat until <key (x v) pressed?>\n        if <<(TouchingSign?) = [1]> or <(TouchingHorse?) = [1]>> then\n            show\n        else\n            hide\n        end\n        next costume\n        wait (0.2) seconds\n    end\n    hide\n    wait until <not <<(TouchingSign?) = [1]> or <(TouchingHorse?) = [1]>>>\nend\n\nwait until \n\nwait (0.1) seconds\n\nshow\n\nwait (0.1) seconds\n\nrepeat until <key (x v) pressed?>\nend\n\nhide\n\n@Sprite3\n\nwhen I receive [text v]\nhide\ngo to x: (60) y: (-116)\nset size to (100) %\nshow\nrepeat (10)\n    change size by (((500) - (size)) * (0.2))\nend\n\nwhen I receive [start v]\nhide\n\nwhen flag clicked\nhide\n\nwhen I receive [greenflag v]\nhide\n\nwhen I receive [hidetest v]\nrepeat (10)\n    change size by (((100) - (size)) * (0.2))\nend\nhide\n\n@Sprite4\n\nwhen I receive [text v]\nswitch costume to (Text#)\nhide\ngo to x: (-120) y: (-93)\nset size to (1) %\nshow\nrepeat (10)\n    change size by (((95) - (size)) * (0.2))\nend\n\nwhen I receive [start v]\nhide\n\nwhen flag clicked\nhide\n\nwhen I receive [greenflag v]\nhide\n\nrepeat (10)\n    change size by (((1) - (size)) * (0.2))\nend\nhide\n\nwhen I receive [hidetest v]\ngo to x: (30) y: (-96)\nrepeat (10)\n    change size by (((1) - (size)) * (0.2))\nend\nhide\n\n@Sprite5\n\nwhen flag clicked\nhide\n\ndefine None\nif <not <(direction) = (dir)>> then\n    point in direction (dir)\nend\n\ndefine Position\nif <(sX) > [0]> then\n    Point (90)\nelse\n    Point (-90)\nend\nchange [myx v] by (sX)\nif <<(myX) > (MaxX)> or <(myX) < (MinX)>> then\n    set [sx v] to (() - (sX))\nend\ngo to x: ((myX) - (ScrollX)) y: ((myY) - (ScrollY))\n\nwhen I start as a clone\ngo [backward v] (3) layers\nshow\nforever\n    if <touching (player v)?> then\n        wait until <key (x v) pressed?>\n        broadcast (Level Complete v)\n    end\nend\n\nwhen I receive [position v]\nif <(Clone?) = [1]> then\n    Position\nend\n\nwhen I receive [reset v]\ndelete (all) of [enemyhealth v]\nset rotation style [left-right v]\nset size to (200) %\nset [clone? v] to [1]\nEnd (-612) (-338) (0) (-612) (-612) (1)\nset [clone? v] to [0]\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine None\n\ndefine None\nset [sx v] to (speed)\nset [myx v] to (x)\nset [myy v] to (y)\nset [maxx v] to (max x)\nset [minx v] to (min x)\nset [enemy# v] to (message #)\ncreate clone of (_myself_ v)\n\n@Parallax Background2\n\nchange y by (10)\n\nwhen flag clicked\nhide\n\nwhen I receive [greenflag v]\nhide\n\nwhen I receive [level complete v]\ngo to x: (0) y: (240)\nshow\ngo to [front v] layer\nrepeat (30)\n    change y by (((-10) - (y position)) * (0.1))\nend\n\n@Ground2\n\nwhen flag clicked\nhide\n\nwhen I receive [reset v]\n\nset size to (300) %\n\nwhen I receive [position v]\n\nswitch costume to (costume2 v)\ngo to x: (() - (ScrollX)) y: (() - (ScrollY))\nset size to (300) %\nswitch costume to (costume1 v)\nshow\n\ngo to x: (() - (ScrollX)) y: (() - (ScrollY))\n\n