top of page
  • Writer's pictureBruce

Let's create a Grabber

Updated: May 15, 2021

Grabber's are fun, right, like in a seaside amusement arcade, hurl coins into the grabber and leave disappointed. But a Grabber might be fun in your game, perhaps use it to move items around, or grab an enemy and drop him into a fiery pit of doom.

I created this script for Episode 3 of Cocoa2: 24 Hour Parsley People, but I've simplified it here so that you should be able to easily adapt it for your own games.

Once you are up and running, it should look something like this...

Here's what we'll need to create:

  1. A 2 frame Sprite for the Grabber itself

  2. A Sprite for the Grabber Controls

  3. Some Script for the Player

  4. Script for the Grabber

  5. Script for the sprited that can be Grabbed.

  1. Grabber Sprite

Here's the one I used, we need two frames, Frame 0 shows the grabber closed:

And Frame 1 shows the Grabber Open:

2. Grabber Controls

We're also going to need a Sprite for the Controls of the Grabbing machine, when our player collides with the controls they will then be able to control the grabber...I went for a joystick kinda thing...

3. The Player Script.

I'm assuming you are writing a side-on standard platform game or adventure here, so you probably have a load of script for your player already. What we need to do is use a variable which will determine which mode the player is in, either Normal Mode, or Grabber Mode.

In my example I'm going to use C to store the value of the Mode.

So when C=1 the player is in Normal Mode and he can run and jump as normal, and when C = 2, the player is in Grabber mode, the player no longer moves, but the Grabber does instead.

So my player Script will, at a high-level, look something like:

IF C = 1 ; normal mode all the normal stuff


IF C = 2 all the grabber stuff


The next thing I need is a variable to store the different things that the Grabber can do, I've called them Grabber Statuses, and I'm using the variable M.

There are quite a few statuses!

M = 0 ; Resets the Grabber so it has returned to its starting position

M = 10 ; move the Grabber to the left

M = 11 ; move the grabber to the right

M = 12 ; the grabber goes up but has not grabbed anything

M = 13 ; the Grabber goes down but has not grabbed anything

M = 15 ; the Grabber has grabbed something and is going up

M = 19 ; the Grabber has reached the top and has something attached

M = 20 ; the grabber goes left and has something grabbed

M= 21 ; the grabber goes right and and has something grabbed

M = 23 ; the grabber goes down and has something attached

So, in your player script, wrap everything you've done so far inside:

IF C = 1 ; normal mode


Then beneath that we'll add our Grabber script (brace's a big one!):

4. The Grabber Script

OK, so that will control the Grabber. But we need to add some code for Grabber too. In effect the Grabber needs to be visible on the screen, but not doing anything, until the player touches the Grabber controls. So, we'll use a different sprite type and initial set the Grabber to this one, then when the player collides with the controls, we'll trigger the Grabber to change its Sprite Type to O (player), thereby allowing the player to control it.

I'm going to use Type 8

Pretty simple, if C = 2, the player is in Grabber mode, so change the grabbers sprite type to 0.

5. The Grabber Controls Script

This is also straightforward, the Grabber Controls Sprite is stationary, it's basically a switch, touch it and stuff happens, the player cant move, instead the player now controls the grabber:

6. Some script for Sprites that can be Grabbed

In Cocoa2:24 Hour Parsley People I made a bunch of sprites 'Grabable' with different consequences, in this simplified version we'll stick to just one.

It will need a variable ( a local one is fine....I'm going to use DIRECTION) that will tell us whether or not the item has been grabbed. Then, based on the current value of M (remember that from the beginning?) we'll know which way the Grabber is going so that the Grabbed Item will move in tandem with it....magic!

So, when DIRECTION = 1, the sprite has been grabbed, in your sprite event add:

...obviously you'll need to tweak this for the correct IMAGE numbers for your game!

Finally, we need to add some code to the player script that will enable the player to return to Normal Mode, by exiting the Grabber Controls, so we'll add this to the bottom of the Player Event, then, and only when the Grabber is nit in action, the player can press the Fire button to release himself from the Grabber Controls:

Finally, add your Grabber to your screen using the SPRITEPOSITIONS editor, remember to initially set your Grabber to the inactive TYPE (in my example above the Grabber is a TYPE 8 until it is made active, at which point it becomes a TYPE 0 (Player event)

And that's it!.

So, the rules of this mechanic are:

  1. Player touches controls

  2. Player becomes inactive

  3. Grabber becomes active

  4. Press left the grabber moves across the crane to the left, to keep it interesting, like a grabber machine it will keep moving left until we press either right or down (even if I release left!). Same with the Right and Down movements

  5. The Grabber needs to hit a grabbable item within a hit box, not to much to the left or keep it challenging!

  6. The grabber and grabbed item must return to the top of the crane to then be able to move right or left

  7. If the grabber reaches the left edge or right edge or is otherwise impeded it will drop whatever it had grabbed!

  8. Player presses down to drop the grabbed item in the desired location.

  9. Player presses Fire when the Grabber is not in motion, to exit the Grabber Controls and return to Normal Mode

Once you've got it up and running, try and adapt it to add more fun's some examples from Cocoa 2: 24 Hour Parsley People

237 views0 comments

Recent Posts

See All


Want to support my work?....Buy my games!


Hello, I'm Bruce and I write games for old 8bit computers using Jonathan Cauldwell's excellent Multi-Platform Arcade Games Designer (MPAGD)

I've written a few successful* games for the Sinclair ZX Spectrum and MSX platforms that have been (largely) well received including Twenty Four Hour Parsley People scoring a 10 out of 10 on Planeta Sinclair.

In my blog I am sharing lots of the code that I wrote for my games, in a way that you can use in your own games.   I've commented it so that you'll learn some of the techniques I use to create interesting new mechanics and help your games stand out from the pack.

MPAGD includes lots of standard scripts, they're great to get you started, but if you're new (or just rusty) when it comes to writing code, hopefully my tutorials will help you get started and  turn your imagination into awesome 8 bit games!

All my code is free to use and do with as you please, but if you find them useful please feel free to buy me a coffee ...or better still - buy or download my games :)

*successful is a very relative term in 8bit computer games

bottom of page