Draw || A Platformer || #All #Games
@Stage\n\nwhen flag clicked\nplay sound [pop v] until done\n\n@Sprite2\n\nwhen backdrop switches to [backdrop1 v]\n\n@level\n\nwhen flag clicked\nset [apples v] to [0]\ngo to x: (0) y: (0)\ngo to [back v] layer\nforever\n    go [forward v] (1) layers\nend\n\nwhen I receive [change sceene v]\nswitch costume to (join [Scene] (Scene #))\nerase all\nstamp outline\nstamp shadow\n\ndefine stamp outline\nset rotation style [don't rotate v]\nset [brightness v] effect to (-100)\nrepeat (8)\n    move (3) steps\n    stamp\n    move (-3) steps\n    turn right (45) degrees\nend\nclear graphic effects\n\ndefine stamp shadow\nset [brightness v] effect to (-100)\nset [ghost v] effect to (90)\nchange y by (-20)\nstamp\nchange y by (20)\nclear graphic effects\n\ngo to [front v] layer\n\n@danger\n\nwhen flag clicked\ngo to x: (0) y: (0)\nforever\n    go to [back v] layer\nend\n\nwhen I receive [change sceene v]\nswitch costume to (scene1 v)\nswitch costume to (join [Scene] (Scene #))\n\n@all lava here\n\nwhen flag clicked\nshow\nset [health v] to [20]\ngo to x: (0) y: (0)\ngo to [back v] layer\n\nwhen I receive [change sceene v]\nswitch costume to (blank v)\nswitch costume to (join [Scene] (Scene #))\nforever\n    set y to ((3) * ([sin v] of ((timer) * (180)) ))\n    if <(Scene #) = [3]> then\n        set y to ((4) * ([sin v] of ((timer) * (180)) ))\n    end\n    if <(Scene #) = [5]> then\n        if <key (l v) pressed?> then\n            change [health v] by (-1)\n        end\n        move (-1) steps\n        set y to ((4) * ([sin v] of ((timer) * (180)) ))\n        wait (0.5) seconds\n        if <(HEalth) = [0]> then\n            hide\n        end\n    end\nend\n\nwhen flag clicked\nwait until <(Scene #) = [5]>\nbroadcast (gg v)\n\nwhen I receive [gg v]\nask [Click L to defeat the boss just type anything for this to go away heads up click l 20 times to defeat it ] and wait\n\ngo to [back v] layer\n\n@Platform\n\nwhen I receive [change sceene v]\nhide\nif <(Scene #) = [2]> then\n    show\n    Animate platform\nend\nif <(Scene #) = [4]> then\n    show\n    hello rick\nend\n\ndefine Animate platform\nswitch costume to (costume1 v)\ngo to x: (-93) y: (-15)\nforever\n    glide (2) secs to x: (129) y: (-4)\n    glide (2) secs to x: (-96) y: (-15)\nend\n\nwhen I receive [tick platform v]\nrick (x position) (y position)\nset [last x v] to (x position)\nset [last y v] to (y position)\n\ndefine rick (new x) (new y)\nif <(new y) > (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\ndefine hello rick\nswitch costume to (costume2 v)\ngo to x: (-56) y: (-8)\nforever\n    glide (1) secs to x: (-3) y: (-5)\n    wait (1) seconds\n    glide (1) secs to x: (-3) y: (90)\n    wait (1) seconds\n    glide (1) secs to x: (87) y: (92)\n    wait (1) seconds\n    glide (1) secs to x: (161) y: (8)\n    wait (1) seconds\n    glide (1) secs to x: (-51) y: (-8)\n    wait (1) seconds\nend\n\n@Apple\n\nwhen I receive [change sceene v]\nif <(Scene #) = (My scene)> then\n    show\nelse\n    hide\nend\n\nwhen I start as a clone\nwait until <touching (player v)?>\nchange [apples v] by (1)\nset [my scene v] to []\nstart sound [Chomp v]\nhide\n\nwhen I receive [setup v]\nhide\nset [my scene v] to [1]\nswitch costume to (apple v)\ngo to x: (167) y: (-23)\ncreate clone of (_myself_ v)\ngo to x: (-60) y: (38)\ncreate clone of (_myself_ v)\ngo to x: (pick random (-227) to (220)) y: (51)\ncreate clone of (_myself_ v)\nset [my scene v] to [2]\nrepeat (3)\n    create clone of (_myself_ v)\nend\ngo to x: (pick random (-227) to (220)) y: (51)\n\n@Sprite1\n\nwhen this sprite clicked\nif <<(apples) = [2]> or <(apples) > [2]>> then\n    change [apples v] by (-2)\n    set [c v] to [3]\n    hide\nend\n\nwhen flag clicked\nshow\nset [c v] to [0]\ngo to x: (202) y: (150)\nforever\n    go to [front v] layer\nend\n\n@Player\n\ndefine check touching solid\nif <<touching (level v)?> or <touching (platform v)?>> then\n    set [player: touching v] to [1]\nelse\n    set [player: touching v] to [0]\nend\n\ndefine move in steps (steps)\nchange [player: falling v] by (1)\nrepeat (steps)\n    set [player: last value v] to (x position)\n    change x by ((Player: speed x) / (steps))\n    check touching solid\n    if <(Player: touching) > [0]> then\n        Collide x slope or walk\n    end\n    set [player: last value v] to (y position)\n    change y by ((Player: speed y) / (steps))\n    check touching solid\n    if <(Player: touching) > [0]> then\n        collide y celing or floor\n    end\nend\n\ndefine Slip\nchange y by (-2)\nchange x by (1)\ncheck touching solid\nif <(Player: touching) < [1]> then\n    set [player: falling v] to [9]\n    change [player: speed x v] by (1)\n    stop [this script v]\nend\nchange x by (-2)\ncheck touching solid\nif <(Player: touching) < [1]> then\n    set [player: falling v] to [9]\n    change [player: speed x v] by (-1)\n    stop [this script v]\nend\nchange y by (2)\nchange x by (1)\n\ndefine collide y celing or floor\nset y to (Player: last value)\nif <(Player: speed y) > [0]> then\n    set [player: speed y v] to [0]\n    stop [this script v]\nend\nif <(Player: falling) > [0]> then\n    set [player: falling v] to [0]\n    Slip\nend\nset [player: speed y v] to ((Player: speed y) * (0.8))\n\ndefine Collide x slope or walk\nchange y by (1)\ncheck touching solid\nif <(Player: touching) > [0]> then\n    change y by (1)\n    check touching solid\n    if <(Player: touching) > [0]> then\n        change y by (-2)\n        set x to (Player: last value)\n        set [player: speed x v] to [0]\n        stop [this script v]\n    end\n    set [player: speed x v] to ((Player: speed x) * (0.8))\nend\nset [player: speed x v] to ((Player: speed x) * (0.95))\nSlip\n\ndefine reset and begin level\ngo to x: (-114) y: (-25)\nset [aainvunruble v] to [0]\nset [player: speed y v] to [0]\nset [player: speed x v] to [0]\nset [player: falling v] to [99]\npoint in direction (90)\nbegin scene # (current scene) got to x [-207]\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 controls up and down\nif <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <(stick y) > [0.5]>> then\n    if <(Player: falling) < [3]> then\n        set [jumping v] to [1]\n        set [player: speed y v] to (JUMP FOrce)\n    end\nend\nchange [player: speed y v] by (gravity)\n\ndefine begin scene # (scene #) got to x (x)\nset [scene # v] to (scene #)\nset x to (x)\nbroadcast (about to change sceen v)\nbroadcast (Change sceene v)\nstop [other scripts in sprite v]\nwait (0) seconds\nswitch costume to (hitbox v2 v)\nset rotation style [don't rotate v]\nfix collisions [0]\nbroadcast (game loop v)\n\nwhen I receive [tick-last v]\nif <(x position) > [235]> then\n    begin scene # ((Scene #) + (1)) got to x [-235]\nend\nif <(x position) < [-235]> then\n    begin scene # ((Scene #) + (-1)) got to x [235]\nend\nif <<touching (danger v)?> or <touching (all lava here v)?>> then\n    broadcast (lose life v)\nend\n\nwhen I receive [game loop v]\nset [ghost v] effect to (0)\nforever\n    broadcast (tick first v)\n    broadcast (Tick platform v)\n    broadcast (tick-player v)\n    broadcast (tick-last v)\nend\n\ndefine fix collisions (dir)\nset [temp v] to (direction)\nset [distance v] to [1]\npoint in direction (dir)\nrepeat (64)\n    check touching solid\n    if <(Player: 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 flag clicked\ngo to x: (-114) y: (-25)\nset [current scene v] to [1]\nset [gravity v] to [-1.5]\nset [resitance v] to [0.8]\nset [accceleration v] to [1.5]\nset [jump force v] to [12]\nbroadcast (setup v) and wait\nreset and begin level\n\nwhen I receive [tick-player v]\nMoved by moving platform\nswitch backdrop to <touching (level v)?>\ncontrols up and down\ncontrol right and left\nmove in steps (([abs v] of (Player: speed y) ) + ([abs v] of (Player: speed x) ))\nset costume\n\ndefine set costume\nset rotation style [left-right v]\nif <(Player: falling) > [1]> then\n    if <(Player: 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 touching solid\n        if <(Player: 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 control right and left\nset [key x v] to (<<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <(stick x) > [0.5]>> - <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <(stick x) < [-0.5]>>)\nif <(key x) = [0]> then\n    if <(Player: falling) > [2]> then\n        set [player: speed x v] to ((Player: speed x) * (0.98))\n        stop [this script v]\n    end\n    if <([abs v] of (Player: speed x) ) < [1]> then\n        set [frame v] to [0]\n        set [player: speed x v] to [0]\n    else\n        change [frame v] by (0.5)\n    end\nelse\n    change [player: speed x v] by ((key x) * (accceleration))\n    point in direction ((key x) * (90))\n    change [frame v] by (1)\nend\nset [player: speed x v] to ((Player: speed x) * (resitance))\n\nwhen I receive [lose life v]\nset [aainvunruble v] to [1]\nstop [other scripts in sprite v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nset [current scene v] to (Scene #)\nwait (0.5) seconds\nreset and begin level\n\ndefine Moved by moving platform\nchange x by (Platform Dx)\nchange y by (Platform Dy)\ncheck touching solid\nif <(touching) > [0]> then\n    find closesdt (x position) (y position) maz [16]\n    broadcast (lose life v)\nend\n\nif <(touching) > [0]> then\n\ndefine find closesdt (x) (y) maz (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 touching solid\n        if <(Player: 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\nfind closesdt (x position) (y position) maz [100]\n\nwhen [up arrow v] key pressed\nforever\n    if <(c) > [2]> then\n        set [jump force v] to ((12) + (c))\n    else\n        set [jump force v] to [12]\n    end\nend\n\nwhen I receive [f v]\nset [player: speed y v] to [15]\n\n@enemy\n\nwhen flag clicked\nset rotation style [left-right v]\nhide\n\nwhen I receive [change sceene v]\nif <(Scene #) = [1]> then\n    go to x: (168) y: (-47)\n    point in direction (-90)\n    create clone of (_myself_ v)\nend\nif <(Scene #) = [1]> then\n    go to x: (150) y: (-47)\n    point in direction (-90)\n    create clone of (_myself_ v)\nend\nif <(Scene #) = [2]> then\n    go to x: (168) y: (-47)\n    point in direction (-90)\n    create clone of (_myself_ v)\nend\nif <(Scene #) = [2]> then\n    go to x: (150) y: (-47)\n    point in direction (-90)\n    create clone of (_myself_ v)\nend\nif <(Scene #) = [5]> then\n    go to x: (168) y: (-47)\n    point in direction (-90)\n    create clone of (_myself_ v)\nend\nif <(Scene #) = [5]> then\n    go to x: (145) y: (-47)\n    point in direction (-90)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nshow\nset [spped 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-right-left\n    Move-down\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 <touching (player v)?> then\n        touching player\n    end\nend\n\nwhen I receive [about to change sceen v]\ndelete this clone\n\ndefine Move-down\nchange [spped y v] by (-1)\nchange y by (spped y)\nrepeat until <not <touching (level v)?>>\n    change y by (1)\n    set [spped y v] to [0]\nend\n\ndefine move-right-left\nmove (2) steps\nrepeat (4)\n    if <not <<touching (level v)?> or <touching (_edge_ v)?>>> then\n        stop [this script v]\n    end\n    change y by (1)\nend\nchange y by (-4)\nmove (-2) steps\nturn right (180) degrees\n\ndefine touching player\nif <([player: speed y v] of [player v]) < [-3]> then\n    broadcast (f 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\nwhen I receive [f v]\nset [aainvunruble v] to [0]\n\n@control stick\n\nwhen flag clicked\ngo to x: (-177) y: (-127)\nset [myself v] to [control stick]\nset [max stick v] to [25]\nswitch costume to (base v)\nshow\nset [ghost v] effect to (50)\ncreate clone of (_myself_ v)\nforever\n    go to [front v] layer\nend\n\nwhen I start as a clone\nswitch costume to (stick v)\nshow\nset [ghost v] effect to (25)\nstick drag\nforever\n    go [forward v] (1) layers\n    set [stick power v] to []\n    set [stick x v] to [0]\n    set [stick y v] to [0]\n    repeat until <mouse down?>\n        go to (myself)\n    end\n    if <(distance to [mouse-pointer v]) < (size)> then\n        stick drag\n    else\n        wait until <not <mouse down?>>\n    end\nend\n\ndefine stick drag\nrepeat until <not <mouse down?>>\n    go to (mouse-pointer v)\n    point towards (myself)\n    turn right (180) degrees\n    set [stick direction v] to (direction)\n    set [stick power v] to (distance to [(myself) v])\n    if <(stick power) > (max stick)> then\n        move ((max stick) - (stick power)) steps\n        set [stick power v] to (max stick)\n    end\n    set [stick power v] to ((stick power) / (max stick))\n    set [stick x v] to ((stick power) * ([sin v] of (stick direction) ))\n    set [stick y v] to ((stick power) * ([cos v] of (stick direction) ))\nend\n\nforever\n\n
New game Out! :D https://scratch.mit.edu/projects/584943855\n\nUse your arrow keys to jump over forks, water and the oven Use the toaster to get over objects. \n\nThanks @-Xaf- For the music Thanks @A_wire for the platformer engine Fork by @_G-l-i-t-c-h_