Skip to content

How spheres work?

jakubg1 edited this page Aug 22, 2024 · 5 revisions

One of the fundamental elements of any sphere-matcher game - and as such - this engine, is that the balls are rolling along a certain path. But how is it done on a more technical level? I will try to explain it here.

Keep in mind that this is not an exhaustive article - you can disable or enable lots of behaviors not mentioned here! Look into game documentation (specifically, gameplay.json for more details!)

Grouping

The most important piece of knowledge about OpenSMCE is about how spheres are organized in the code - and there are actually quite a few classes involved into this process. These include:

  • Sphere Chains - Trains of spheres. They always have one vise by default, and can merge when one collides with the other. They contain one or more...
  • Sphere Groups - These are groups of spheres which move together and cannot be split by themselves. You can split a Sphere Group into two by destroying one or more balls in the middle - then, the both halves become their own sphere groups. They can of course merge, too! Each Sphere Group contains one or more...
  • Spheres - These are fundamental for the game and the easiest to visualize. They're just... spheres, that's all there is to it. However, they can have some interesting properties we'll look into later.

We also need to talk about ordering, because it's wacky.

  • Sphere Chains are ordered front to back.
  • Sphere Groups are also ordered front to back.
  • But, Spheres are ordered back to front.

By "front" we mean closer to the path's exit point, while "back" means closer to the path's spawn point.

You of course look for a clear picture, aren't you? We've got you covered: obraz

Sphere Chains are highlighted in green, Sphere Groups are yellow.

Vise

Vises (sometimes called Scarabs) are special spheres which appear at the end of each Sphere Chain. They are pushing spheres to the deadly end of the path (in Luxor, that's a pyramid). Or are they? They are in fact not! In OpenSMCE, it's not the presence of a vise that determines whether the spheres can move on their own - it's hardcoded to be the last Sphere Group of a Sphere Chain. This makes sense as in games where there aren't any Vises, like in Zuma, the last ball pushes the entire train forward.

Vises don't match with any other spheres and are destroyed when all other spheres in its Chain are destroyed, or when two Sphere Chains merge.

Magnetization

Another mysterious word. What does it mean? Well, in Luxor, as well as many other similar games, if there are two sphere groups which have spheres of matching color towards each other's end, one of them will start rolling back and eventually collide. That's how chain reactions (or, if you prefer Zuma vocabulary - combos) work!

The Vise can pull Sphere Groups towards itself if it's alone, too.

The force which pulls a sphere group back because of these sphere colors is hereby called magnetization. There is a function specifically for that, in the code!

Appending

Appending? Yes, that's what happens when you shoot a sphere at some more spheres on the path and it collides with them. We will not look into sphere shooting today, but the appending bit is important here.

First of all, let's make some mess. Basically, when it hits the Spheres, the Shot Sphere adds a new Sphere to the Sphere Group, but it does not itself disappear. So, for a brief moment, you have both an actual sphere, and a Shot Sphere which has not yet despawned! (Actually, it exists just because the shooter is waiting until the next ball is ready.) By the way, what's drawn is the actual sphere. The Shot Sphere stops rendering once it hits Spheres on its path.

And now the important bit. The process ends when the Sphere fully forms, we say it becomes mature. All Spheres are mature by default, they have normal hitboxes and behave like any other sphere. If it's not mature, that means it's been just added to its group via a Shot Sphere.

Sphere Effects

What are Sphere Effects? They are temporary (or permanent) effects which can be applied to a Sphere or a particular number of Spheres. Each Sphere can have multiple effects at the same time, but they cannot have the same effect applied more than once.

Depending on how the effect is configured, a number of things can happen, such as:

  • The sphere can infect its neighbors with the same effect (within the same Sphere Group).
  • The sphere can be destroyed after a certain period of time (Poison).
  • The sphere can stop the whole Sphere Group it is within (Freeze).
  • The sphere can become fragile and be destroyed when a Shot Sphere passes through it (Freeze).

There is also a special sphere effect called a match sphere effect. This is a sphere effect which is inflicted by the game when the spheres normally match. Yes, they are not outright destroyed, they are applied a sphere effect first! However, as the sphere effect is applied just before its effects are applied (on the same frame [EXCEPT MAYBE IF IT'S THE LAST ONE IT STAYS LONGER FOR ONE FRAME, HUH?]), there is essentially no difference whatsoever. Instead, as a bonus, you can configure the match behavior to do something else, for example keep the spheres frozen for a moment before they are destroyed!

Sphere Effect Groups

Even more intense vocabulary! What are Sphere Effect Groups? Unfortunately I haven't added a way to visualize that in Debug Mode... Perhaps I should. Anyways, they are stored per Path, and each Sphere, if it has a particular Sphere Effect, contributes to a single Effect Group. These exist to make a distinction between two different infection effects, even if they visually merge with each other.

When spheres with an Effect are destroyed, they can be destroyed alone, alongside the same Effect Group or alongside the same Effect. The second one is important in the Poison powerup - even if the infections merge, they will still be counted separately. Each Sphere Effect Group has also a cause sphere - that sphere is determined by whichever sphere has started the infection, and as such the entire group. And it determines the way points are calculated and - probably most notably - which font color is used for the score that's displayed when that group gets destroyed.

And by the way, match effects create their own effect groups too.

... To be continued ...

Clone this wiki locally