Dr. Andrew Broad
Sinclair ZX Spectrum
Manic Miner/Jet Set Willy
Collision-Detection and the JSW Guardian-Instance List


This document explains the subtle rules of collision-detection in Manic Miner and Jet Set Willy, and explains how the order of a JSW room's guardian-instance list can affect collision-detection.

N.B. Some people use the word `object' to mean `item', as in the glowing things you collect in MM/JSW. This document uses `object' to mean anything that is drawn on (the playing area of) the screen. Similarly, some people use the word `attribute' to mean the colour-attribute of a character-square on the Spectrum screen, but colour is just one particular attribute. As a computer scientist, I have quite religious views on this: everything's an object (not just items), and objects can have various attributes (not just colour).

Types of Collision-Detection

There are three types of collision-detection in MM/JSW (and Spectrum games in general):

Collision Depends on the Order in which Objects are Drawn

The most important message to take from this document is this: collision is not symmetric. That is to say, it is not strictly correct to speak of two objects colliding with each other. One object collides with a second object - the second object does not collide with the first - and which way round the collision is has some important consequences.

In MM and JSW, objects are drawn in a particular order in each time-frame, and objects that are drawn later can collide with objects that are drawn earlier in that time-frame. "A collides with B" means that B was drawn first, then A was drawn and their pixels (or colour-attributes as the case may be) collided, causing A - not B - to react to the collision.

The order in which objects are drawn in each time-frame (combining MM and JSW) is:

  1. The single-character blocks: background, floor, wall and static nasty; and, in MM: crumbling floor, conveyor, second static nasty, and spare (and `garbage' blocks).
  2. In JSW, the ramp and the conveyor; in MM, the conveyor-animation.
  3. The player. You collide with the blocks that you're touching; collision-detection for the player is colour-based.
  4. The guardians. The guardians are drawn in the order in which they appear in the room's guardian-instance list, so a guardian can collide with anything drawn before it, including guardians which precede it in the guardian-instance list. If a guardian collides with anything, you lose a life. Collision-detection for horizontal and vertical guardians and ropes is pixel-based; for arrows it is both pixel-based and colour-based (white ink).
  5. The items. Collision-detection for items is colour-based: an item is collected if it collides with anything which has white ink, such as the player, white-ink background (as in "Swimming Pool") or white-ink guardians. Note that it's quite safe to put items in the path of a guardian, since it won't collide with them. The exception to this is vertical guardians in MM, which are actually drawn after the items, therefore they can collide with items and kill you.
  6. The portal in MM. Collision-detection for the portal is position-based: when the player's position equals the portal's position, you have completed the room. Again, it is quite safe to put the portal in the path of a guardian.
  7. Hard-wired special objects: Eugene and the Kong-Beast in MM, and Maria in JSW. Collision-detection for these is pixel-based, and they kill you if they collide, but note that they are not technically guardians! Also note that they will kill you if they collide with an item, since items are drawn first! Also the bed and the toilet in JSW (position-based), and the solar beams in MM (colour-based).

It is instructive to pause on the time-frame in which you get killed, to see what has and what hasn't been drawn yet.

The JSW Guardian-Instance List

A JSW room's guardian-instance list needs to be ordered as follows, so that the guardians are drawn in the correct order for collision-detection:

  1. HORIZONTAL/VERTICAL GUARDIANS
  2. ROPE
  3. ARROWS

A rope must be after the horizontal and vertical guardians because it actually uses the ninth byte of the guardian-class (when the guardian-classes for the room's guardian-instances are copied to the 8x8-byte buffer at 33024-33087 at runtime), which can corrupt the following guardian in the guardian-instance list. That's why having two ropes in a room can have strange effects (c.f. "WE PRETTY" in We Pretty), but a solution is to insert a dummy guardian-instance between the two ropes (e.g. of an undefined guardian-class). Thanks to John Elliott (Message 398 of the Manic Miner and Jet Set Willy Yahoo! Group) and Geoff Eddy (the jclop documentation) for this information.

Arrows must be after all other guardian-instances so that they're drawn last and the other guardians don't collide with them. For example, a vertical guardian collides with an arrow in We Pretty's "SKYLIFE A V I A T I O N AVATAR", which kills you, because the arrow is drawn first (I kept it in because I liked the time limit :-)) - if the arrow were drawn after the VG, the arrow would not collide with the VG unless the VG had white ink (an arrow kills you iff it pixel-collides with something on a white-ink character-square, which also explains why you can avoid arrows by standing in floor blocks).

Arrows must even be after the rope, because if an arrow is drawn first then the rope will collide with the arrow and pick you up (because the arrow is white?). An example of this is "Into the sky" in Richard Hallas's Join the Jet-Set! In this room, the arrow doesn't collide with Willy, presumably because the rope is so far off-centre, but such collisions often have fatal consequences. Putting the arrow after the rope fixes "Into the sky", but note that there is a danger of an arrow pixel-colliding with a white-ink rope (a rope has the same colour-attribute as the room's background, since ropes are drawn but not coloured) and killing you!

Ropes use pixel-based collision-detection too - a rope's on-pixels can collide with any on-pixel already printed on the screen - i.e. from the 8x8 blocks, Willy, or any guardians preceding it in the room's guardian-instance list. If a rope-pixel collides with another on-pixel, the rope picks up Willy at the point of collision - regardless of his position on the screen. If this happens to be near the top of the screen, Willy is `teleported' to the room above. A rope can pass through blocks of any type without effect if its pixels do not collide with the blocks' on-pixels.


Email me