The claw machine (a platformer) #games
@Stage\n\nwhen I receive [next level v]\nnext backdrop\nchange [level v] by (1)\n\nwhen I receive [setup v]\nswitch backdrop to (backdrop11 v)\nset [level v] to [1]\n\n@blob\n\nwhen flag clicked\ngo to [back v] layer\nbroadcast (setup v)\nforever\n    if <(grabbed) = [0]> then\n        if <key (left arrow v) pressed?> then\n            change [xv v] by (-1)\n        end\n        if <key (right arrow v) pressed?> then\n            change [xv v] by (1)\n        end\n        set [xv v] to ((xv) * (.8))\n        change x by (xv)\n        if <<touching color (#000000)?> or <touching color (#191919)?>> then\n            change y by (.5)\n            if <<touching color (#000000)?> or <touching color (#191919)?>> then\n                change y by (.5)\n                if <<touching color (#000000)?> or <touching color (#191919)?>> then\n                    change y by (.5)\n                    if <<touching color (#000000)?> or <touching color (#191919)?>> then\n                        change y by (.5)\n                        if <<touching color (#000000)?> or <touching color (#191919)?>> then\n                            change y by (.5)\n                            if <<touching color (#000000)?> or <touching color (#191919)?>> then\n                                change y by (-2.5)\n                                change x by ((xv) * (-1))\n                                set [xv v] to [0]\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)?> or <touching color (#191919)?>> 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)?> or <touching color (#191919)?>> then\n            if <key (up arrow v) pressed?> then\n                set [yv v] to [9]\n            end\n        end\n        change y by (1)\n    else\n        set [xv v] to [0]\n        set [yv v] to [0]\n        go to x: (item (grabbed) of [x v]) y: (item (grabbed) of [y v])\n    end\n    if <<(y position) < [-178]> or <touching color (#ff0000)?>> then\n        broadcast (DEATH v)\n    end\n    if <(x position) > [239]> then\n        broadcast (next level v)\n    end\nend\n\nwhen flag clicked\nset rotation style [left-right v]\nforever\n    if <(grabbed) = [0]> then\n        if <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>> then\n            switch costume to (costume2 v)\n            if <key (left arrow v) pressed?> then\n                point in direction (-90)\n            else\n                point in direction (90)\n            end\n        else\n            switch costume to (costume1 v)\n        end\n    end\nend\n\nwhen I receive [setup v]\nset [teddy grabbed v] to [0]\nset [teddy 2 grabbed v] to [0]\nset [teddy 3 grabbed v] to [0]\nset [grabbed v] to [0]\nset [xv v] to [0]\nset [yv v] to [0]\ngo to x: (-240) y: (-100)\n\nwhen I receive [next level v]\nset [teddy grabbed v] to [0]\nset [teddy 2 grabbed v] to [0]\nset [teddy 3 grabbed v] to [0]\nset [grabbed v] to [0]\nset [xv v] to [0]\nset [yv v] to [0]\ngo to x: (-240) y: (-100)\n\nwhen I receive [death v]\nset [teddy grabbed v] to [0]\nset [teddy 2 grabbed v] to [0]\nset [teddy 3 grabbed v] to [0]\nset [grabbed v] to [0]\nset [xv v] to [0]\nset [yv v] to [0]\ngo to x: (-240) y: (-100)\n\nwhen [z v] key pressed\n\nwhen [r v] key pressed\nwait until <not <key (r v) pressed?>>\nbroadcast (DEATH v)\n\nset x to (240)\n\n@claw\n\nwhen flag clicked\nbroadcast (reset \(claw\) v) and wait\nwait (.01) seconds\nerase all\nhide\nwait until level = [2]\nmake claw at [-90] [180] point in [180]\nwait until level = [3]\nmake claw at [-90] [180] point in [180]\nwait until level = [4]\nmake claw at [-90] [180] point in [180]\nwait until level = [5]\nmake claw at [-90] [180] point in [180]\nwait until level = [6]\nmake claw at [-90] [180] point in [180]\nwait until level = [7]\nmake claw at [-90] [180] point in [180]\nwait until level = [8]\nmake claw at [-90] [180] point in [180]\nmake claw at [-240] [0] point in [90]\nwait until level = [9]\nmake claw at [-90] [180] point in [180]\nmake claw at [240] [0] point in [-90]\nwait until level = [10]\nmake claw at [-90] [180] point in [180]\nwait until level = [11]\nmake claw at [-90] [180] point in [180]\nwait until level = [12]\nmake claw at [-185] [-180] point in [0]\nmake claw at [240] [0] point in [270]\nmake claw at [107] [-180] point in [0]\nmake claw at [0] [180] point in [180]\nwait until level = [13]\n\ndefine make claw at (x) (y) point in (direction)\nadd (x) to [old x v]\nadd (y) to [old y v]\nadd (x) to [x v]\nadd (y) to [y v]\nchange [clone number v] by (1)\nchange [number of claws v] by (1)\nchange [active claw v] by (1)\ngo to x: (x) y: (y)\npoint in direction (direction)\nswitch costume to (top thing v)\nrepeat (3)\n    create clone of (_myself_ v)\n    next costume\nend\nwait (.00001) seconds\n\nwhen I start as a clone\nshow\nif <(costume [number v]) = [1]> then\n    forever\n        if <(clone number) = (active claw)> then\n            if <([abs v] of (direction) ) = [90]> then\n                insert (y position) at (clone number) of [old y v] \n                set y to (item (clone number) of [y v])\n            else\n                set x to (item (clone number) of [x v])\n                insert (x position) at (clone number) of [old x v] \n            end\n        end\n        if <touching color (#000000)?> then\n            broadcast (go back v)\n        end\n    end\nend\nif <(costume [number v]) = [2]> then\n    forever\n        insert (x position) at (clone number) of [old x v] \n        insert (y position) at (clone number) of [old y v] \n        go to x: (item (clone number) of [x v]) y: (item (clone number) of [y v])\n        if <touching color (#000000)?> then\n            broadcast (go back v)\n        end\n    end\nend\nif <(costume [number v]) = [3]> then\n    move (30) steps\n    forever\n        if <(clone number) = (active claw)> then\n            change [claw exists? v] by (1)\n            set [claw highlight dir v] to (direction)\n            set [claw highlight x v] to (x position)\n            set [claw highlight y v] to (y position)\n            set [claw highlight costume v] to (costume [number v])\n            if <key (d v) pressed?> then\n                change x by (5)\n                backwards [-1]\n            end\n            if <key (a v) pressed?> then\n                change x by (-5)\n                backwards [1]\n            end\n            if <key (w v) pressed?> then\n                change y by (5)\n                backwards 2 [-1]\n            end\n            if <key (s v) pressed?> then\n                change y by (-5)\n                backwards 2 [1]\n            end\n            replace item (clone number) of [y v] with (y position)\n            replace item (clone number) of [x v] with (x position)\n            if <key (space v) pressed?> then\n                if <(space pressed) = [0 ]> then\n                    if <(costume [number v]) = [3]> then\n                        switch costume to (claw \(closed\) v)\n                        if <touching (blob v)?> then\n                            set [grabbed v] to (clone number)\n                            wait (.5) seconds\n                        else\n                            if <touching (teddy bear v)?> then\n                                set [teddy grabbed v] to (clone number)\n                                wait (.5) seconds\n                            else\n                                if <touching (teddy bear 2 v)?> then\n                                    set [teddy 2 grabbed v] to (clone number)\n                                    wait (.5) seconds\n                                else\n                                    if <touching (teddy bear 3 v)?> then\n                                        set [teddy 3 grabbed v] to (clone number)\n                                        wait (.5) seconds\n                                    else\n                                        wait (.5) seconds\n                                        switch costume to (claw \(open\) v)\n                                    end\n                                end\n                            end\n                        end\n                    else\n                        switch costume to (claw \(open\) v)\n                        if <(grabbed) = (clone number)> then\n                            set [grabbed v] to [0]\n                        end\n                        if <(teddy grabbed) = (clone number)> then\n                            set [teddy grabbed v] to [0]\n                        end\n                        if <(teddy 2 grabbed) = (clone number)> then\n                            set [teddy 2 grabbed v] to [0]\n                        end\n                        if <(teddy 3 grabbed) = (clone number)> then\n                            set [teddy 3 grabbed v] to [0]\n                        end\n                    end\n                end\n                set [space pressed v] to [1]\n            else\n                set [space pressed v] to [0]\n            end\n        end\n        if <not <<<(grabbed) = (clone number)> or <(teddy grabbed) = (clone number)>> or <<(teddy 2 grabbed) = (clone number)> or <(teddy 3 grabbed) = (clone number)>>>> then\n            switch costume to (claw \(open\) v)\n        end\n    end\nend\n\ndefine backwards (thing)\nif <touching color (#000000)?> then\n    change x by ((5) * (thing))\nend\n\nwhen I receive [reset \(claw\) v]\nif <(clone number) = [0]> then\n    delete all of [x v]\n    delete all of [y v]\n    delete all of [old x v]\n    delete all of [old y v]\n    set [active claw v] to [0]\nelse\n    erase all\n    delete this clone\nend\n\ndefine wait until level = (number)\nset [clone number v] to [0]\nwait until <(level) = (number)>\nset [number of claws v] to [0]\nwait (.0001) seconds\nbroadcast (reset \(claw\) v)\nwait (.0001) seconds\n\ndefine backwards 2 (thing)\nif <touching color (#000000)?> then\n    change y by ((5) * (thing))\nend\n\nwhen flag clicked\nset [active claw v] to [1]\nset [number of claws v] to [1]\nwait (.0001) seconds\nforever\n    if <key (f v) pressed?> then\n        change [active claw v] by (1)\n        wait until <not <key (f v) pressed?>>\n        if <(active claw) > (number of claws)> then\n            change [active claw v] by ((number of claws) * (-1))\n        end\n    end\n    if <key (b v) pressed?> then\n        change [active claw v] by (-1)\n        wait until <not <key (b v) pressed?>>\n        if <(active claw) = [0]> then\n            change [active claw v] by (number of claws)\n        end\n    end\nend\n\nwhen I receive [go back v]\nif <(costume [number v]) = [1]> then\n    if <([abs v] of (direction) ) = [90]> then\n        set y to (item (clone number) of [old y v])\n    else\n        set x to (item (clone number) of [old x v])\n    end\nelse\n    go to x: (item (clone number) of [old x v]) y: (item (clone number) of [old y v])\nend\n\nwhen I start as a clone\nforever\n    go to [front v] layer\nend\n\nwhen I receive [death v]\nwait (.5) seconds\nif <(costume [number v]) = [3]> then\n    repeat until <not <touching color (#000000)?>>\n        move (-5) steps\n    end\nend\n\n@teddy bear\n\nwhen flag clicked\ndelete all of [teddy list v]\nset [hidden v] to [1]\nhide\ngo to [back v] layer\ngo to x: (240) y: (-180)\nforever\n    if <(teddy grabbed) = [0]> then\n        change [teddy yv v] by (-1)\n        change y by (teddy yv)\n        if <<touching color (#000000)?> or <touching color (#191919)?>> then\n            change y by ((teddy yv) * (-1))\n            set [teddy yv v] to [0]\n        end\n    else\n        set [teddy yv v] to [0]\n        go to x: (item (teddy grabbed) of [x v]) y: (item (teddy grabbed) of [y v])\n    end\n    if <(y position) < [-178]> then\n        set [hidden v] to [1]\n        hide\n    end\n    if <<<touching color (#ff0000)?> and <not <touching (blob v)?>>> and <(hidden) = [0]>> then\n        set [burn x v] to (x position)\n        set [burn y v] to (y position)\n        broadcast (burn. v)\n        set [hidden v] to [1]\n        hide\n    end\nend\n\nwhen I receive [death v]\nwait (.01) seconds\ngo to x: (teddy x) y: (teddy y)\nif <[teddy list v] contains (level)?> then\n    set [hidden v] to [0]\n    show\nend\n\ndefine wait until level = (number) go to x: (x) y: (y)\nwait (.3) seconds\nwait until <(level) = (number)>\nadd (level) to [teddy list v]\nset [teddy x v] to (x)\nset [teddy y v] to (y)\ngo to x: (x) y: (y)\nset [hidden v] to [0]\nshow\n\nwhen flag clicked\nwait until level = [4] go to x: [0] y: [0]\nwait until level = [5] go to x: [100] y: [0]\nwait until level = [6] go to x: [-100] y: [0]\nwait until level = [7] go to x: [0] y: [0]\nwait until level = [10] go to x: [-160] y: [20]\nwait until level = [11] go to x: [-160] y: [20]\nwait until level = [12] go to x: [-19] y: [150]\n\nwhen I receive [next level v]\nset [hidden v] to [1]\nhide\n\ngo to x: (143) y: (-146)\n\ngo to x: (240) y: (-180)\n\ngo to x: (190) y: (-149)\n\n@teddy bear 2\n\nwhen flag clicked\ndelete all of [teddy 2 list v]\nset [hidden v] to [1]\nhide\ngo to [back v] layer\ngo to x: (240) y: (-180)\nforever\n    if <(teddy 2 grabbed) = [0]> then\n        change [teddy 2 yv v] by (-1)\n        change y by (teddy 2 yv)\n        if <<touching color (#000000)?> or <touching color (#191919)?>> then\n            change y by ((teddy 2 yv) * (-1))\n            set [teddy 2 yv v] to [0]\n        end\n    else\n        set [teddy 2 yv v] to [0]\n        go to x: (item (teddy 2 grabbed) of [x v]) y: (item (teddy 2 grabbed) of [y v])\n    end\n    if <(y position) < [-178]> then\n        set [hidden v] to [1]\n        hide\n    end\n    if <<<touching color (#ff0000)?> and <not <touching (blob v)?>>> and <(hidden) = [0]>> then\n        set [burn x v] to (x position)\n        set [burn y v] to (y position)\n        broadcast (burn. v)\n        set [hidden v] to [1]\n        hide\n        go to x: (240) y: (-180)\n    end\nend\n\nwhen I receive [death v]\nwait (.01) seconds\ngo to x: (teddy x) y: (teddy y)\nif <[teddy 2 list v] contains (level)?> then\n    set [hidden v] to [0]\n    show\nend\n\ndefine wait until level = (number) go to x: (x) y: (y)\nwait (.3) seconds\nwait until <(level) = (number)>\nadd (level) to [teddy 2 list v]\nset [teddy x v] to (x)\nset [teddy y v] to (y)\ngo to x: (x) y: (y)\nset [hidden v] to [0]\nshow\n\nwhen flag clicked\nwait until level = [4] go to x: [-50] y: [0]\nwait until level = [6] go to x: [-25] y: [0]\nwait until level = [10] go to x: [-190] y: [20]\nwait until level = [11] go to x: [-190] y: [20]\nwait until level = [12] go to x: [65] y: [150]\n\nwhen I receive [next level v]\nset [hidden v] to [1]\nhide\n\n@teddy bear 3\n\nwhen flag clicked\ndelete all of [teddy 3 list v]\nset [hidden v] to [1]\nhide\ngo to [back v] layer\ngo to x: (240) y: (-180)\nforever\n    if <(teddy 3 grabbed) = [0]> then\n        change [teddy 3 yv v] by (-1)\n        change y by (teddy 3 yv)\n        if <<touching color (#000000)?> or <touching color (#191919)?>> then\n            change y by ((teddy 3 yv) * (-1))\n            set [teddy 3 yv v] to [0]\n        end\n    else\n        set [teddy 3 yv v] to [0]\n        go to x: (item (teddy 3 grabbed) of [x v]) y: (item (teddy 3 grabbed) of [y v])\n    end\n    if <(y position) < [-178]> then\n        set [hidden v] to [1]\n        hide\n    end\n    if <<<touching color (#ff0000)?> and <not <touching (blob v)?>>> and <(hidden) = [0]>> then\n        set [burn x v] to (x position)\n        set [burn y v] to (y position)\n        broadcast (burn. v)\n        go to x: (240) y: (-180)\n        set [hidden v] to [1]\n        hide\n    end\nend\n\nwhen I receive [death v]\nwait (.01) seconds\ngo to x: (teddy x) y: (teddy y)\nif <[teddy 3 list v] contains (level)?> then\n    set [hidden v] to [0]\n    show\nend\n\ndefine wait until level = (number) go to x: (x) y: (y)\nwait (.3) seconds\nwait until <(level) = (number)>\nadd (level) to [teddy 3 list v]\nset [teddy x v] to (x)\nset [teddy y v] to (y)\ngo to x: (x) y: (y)\nset [hidden v] to [0]\nshow\n\nwhen flag clicked\nwait until level = [4] go to x: [50] y: [-120]\nwait until level = [6] go to x: [50] y: [0]\nwait until level = [10] go to x: [-130] y: [20]\nwait until level = [12] go to x: [146] y: [150]\n\nwhen I receive [next level v]\nset [hidden v] to [1]\nhide\n\n@burn up\n\nwhen flag clicked\nhide\nswitch costume to (costume1 v)\n\nwhen I receive [burn. v]\ngo to x: (burn x) y: (burn y)\npoint in direction (90)\nswitch costume to (costume1 v)\nset size to (75) %\nshow\nset [random number v] to (((pick random (0) to (1)) - (.5)) * (2))\nrepeat (16)\n    turn right ((pick random (1) to (3)) * (random number)) degrees\n    change x by ((pick random (2) to (4)) * (random number))\n    change y by (3)\n    next costume\n    wait (.0001) seconds\nend\nhide\nswitch costume to (costume1 v)\n\n@button\n\ndefine wait until level = (number)\nwait until <(level) = (number)>\nset [button number v] to [0]\ndelete all of [button list v]\n\nwhen flag clicked\nwait (1) seconds\nhide\ngo to [back v] layer\nwait until level = [5]\nmake a button at x: [0] y: [-132] and a wall at x: [200] y: [-115] direction: [90] reverse? [1]\nwait until level = [6]\nmake a button at x: [-175] y: [-132] and a wall at x: [-100] y: [-115] direction: [90] reverse? [1]\nmake a button at x: [-100] y: [-132] and a wall at x: [-25] y: [-115] direction: [90] reverse? [1]\nmake a button at x: [-25] y: [-132] and a wall at x: [50] y: [-115] direction: [90] reverse? [1]\nmake a button at x: [50] y: [-132] and a wall at x: [220] y: [-115] direction: [90] reverse? [1]\nwait until level = [7]\nmake a button at x: [-40] y: [-131] and a wall at x: [-40] y: [-148] direction: [0] reverse? [1]\nwait until level = [11]\nmake a button at x: [-175] y: [-132] and a wall at x: [-100] y: [32] direction: [90] reverse? [1]\nmake a button at x: [-50] y: [5] and a wall at x: [-25] y: [-115] direction: [90] reverse? [1]\nmake a button at x: [50] y: [-132] and a wall at x: [0] y: [32] direction: [90] reverse? [1]\nmake a button at x: [-50] y: [5] and a wall at x: [200] y: [-115] direction: [90] reverse? [1]\nmake a button at x: [50] y: [5] and a wall at x: [220] y: [-115] direction: [90] reverse? [1]\nwait until level = [12]\nmake a button at x: [-52] y: [-133] and a wall at x: [-110] y: [79] direction: [90] reverse? [1]\nmake a button at x: [20] y: [-133] and a wall at x: [-20] y: [-35] direction: [90] reverse? [1]\nmake a button at x: [20] y: [-133] and a wall at x: [80] y: [-35] direction: [90] reverse? [1]\nmake a button at x: [190] y: [-133] and a wall at x: [30] y: [-40] direction: [0] reverse? [1]\nmake a button at x: [190] y: [-133] and a wall at x: [30] y: [50] direction: [0] reverse? [-1]\nmake a button at x: [190] y: [-133] and a wall at x: [20] y: [140] direction: [90] reverse? [-1]\nmake a button at x: [65] y: [125] and a wall at x: [-52] y: [-75] direction: [0] reverse? [1]\n\ndefine make a button at x: (x) y: (y) and a wall at x: (wx) y: (wy) direction: (d) reverse? (choose)\nadd [0] to [button list v]\nchange [button number v] by (1)\nset [reverse? v] to (choose)\npoint in direction (90)\ngo to x: (x) y: (y)\nswitch costume to (costume1 v)\ncreate clone of (_myself_ v)\npoint in direction (d)\ngo to x: (wx) y: (wy)\nswitch costume to (costume3 v)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nif <(costume [number v]) = [1]> then\n    show\n    forever\n        if <touching color (#191919)?> then\n            switch costume to (costume2 v)\n            replace item (button number) of [button list v] with [1]\n        else\n            switch costume to (costume1 v)\n            replace item (button number) of [button list v] with [0]\n        end\n    end\nend\nif <(costume [number v]) = [3]> then\n    forever\n        if <(reverse?) = [1]> then\n            if <(item (button number) of [button list v]) = [1]> then\n                hide\n            else\n                show\n            end\n        else\n            if <(item (button number) of [button list v]) = [1]> then\n                show\n            else\n                hide\n            end\n        end\n    end\nend\n\nwhen I receive [next level v]\ndelete this clone\n\nwhen [i v] key pressed\n\nturn right (pick random (-360) to (360)) degrees\nmove (30) steps\nsay (reverse?) for (2) seconds\nmove (-30) steps\n\n@thumbnail\n\nwhen flag clicked\nset volume to (10) %\nstart sound [PAC-MAN - MUSIC v]\nset [ghost v] effect to (100)\nforever\n    go to [front v] layer\nend\n\n@words\n\nwhen I receive [setup v]\nswitch costume to (words v)\nforever\n    go to [back v] layer\nend\n\nwhen I receive [next level v]\nnext costume\n\n@claw highlighter\n\nwhen flag clicked\nforever\n    go to [back v] layer\n    if <(old claw thing) = (claw exists?)> then\n        set [claw exists? v] to [1]\n    end\n    set [old claw thing v] to (claw exists?)\n    if <(claw exists?) > [1]> then\n        show\n        point in direction (claw highlight dir)\n        go to x: (claw highlight x) y: (claw highlight y)\n        switch costume to ((claw highlight costume) - (2))\n    else\n        hide\n    end\nend\n\n
arrow keys to move\nwasd to move the claw\nspace to open and close the claw\nf and b to switch between claws\nr to restart\nreminders are in the levels