Running on Fumes: How To Create an Endless Runner Within GB Studio’s Limits

One random day, you wake up, pour yourself that first cup of coffee, and the very first thought that crosses your mind is: how could I make an endless runner in GB Studio? No, that’s just me? Well, with that idea in my head and a small game jam organized by some friends as an excuse, I decided to challenge myself to build a working prototype in just one weekend.

An endless runner lets the player move through an infinitely scrolling environment, creating the illusion of a world that never ends. This concept immediately clashes with one of GB Studio’s limitations: backgrounds can’t exceed 2,040 px in width or height. You could teleport the player back to the start of the scene repeatedly to sell the illusion, but that sprite warp is rarely pixel-perfect. Worse, the environment would repeat visually, which is exactly what we want to avoid. So, it’s time to get creative.

Pre-Cinematic Animation Tricks to Fool the Human Eye

Background animation is the key to creating a sense of movement on a static screen. To achieve this, we need a tileset explicitly designed for the effect. Since GB Studio tiles are 8×8 px, we can create an eight-frame roll where the image shifts by one pixel per frame in the desired direction. Think of those pre-cinema optical toys that tricked the eye with looping image sequences, making static drawings appear to move. Combine this with an idle animation for your player character sprite that looks like running, and the illusion is complete.

To implement this in GB Studio, we can rely on the [Replace Tile from Sequence] script inside an actor’s On Update tab. Using an auxiliary variable, we cycle through the frames on every update.

There is, however, a catch. Updating game elements every frame is computationally expensive, especially when you stack multiple events on update. This can seriously impact performance if you’re not careful. It’s even more noticeable when targeting the original Game Boy: the Sharp SM83 CPU runs at 4.19 MHz, while Color Only mode doubles that to 8.38 MHz.

I had already run into this issue in a previous project. In Monster Peak, there’s a short action sequence where you control a boat rushing through rapids and dodging obstacles. To simulate movement, I used the same animated background trick on a brick wall. Placing the tile replacement inside an on update caused a noticeable slowdown, but the solution was simple: reduce the refresh rate by adding a 5 ms wait event after each call. The wall moved more slowly, but it was more than enough visually. In Color Only mode, as we’ll see later, these slowdowns are much easier to manage.

Random Enemy Generation

Now for the fun part. Any self-respecting endless runner needs an endless stream of obstacles, generated randomly and indefinitely. The trick is to spawn enemies outside the camera’s view and move them, via an on-update event, in the direction of travel. Once they exit the screen on the opposite side, they’re disabled and reset to their starting position.

In Too Many Croquetas, I used two invisible helper actors to keep things simple and run in parallel On Update logic:

  • One actor handles the [Replace Tile from Sequence] script logic that animates the ground and creates the movement illusion.
  • The other controls the game flow itself: enemy spawning, randomization and item generation.

The core loop works like this:

  1. Wait a few seconds only when the stage starts.
  2. Generate a random number to decide which enemy will appear next and store it in a variable.
  3. If the selected enemy is the same as the previous one, reroll until it’s different.
  4. Initialize the chosen enemy actor using a switch controlled by the random variable.
  5. Increment the enemy spawn counter.
  6. Spawn a specific enemy type whenever the counter is a multiple of five to add variety.
  7. Spawn an item at a random horizontal position every eight cycles.
  8. Store the current random value for comparison in the next iteration.

All of this is fine-tuned using a couple of wait events to control the pacing. Remember: no more than 20 actors on screen at once, and no more than 10 sprite tiles visible on the same scanline.

As for enemies, I chose to create individual actors for each type, since my game design ensures that two identical enemies never appear on screen at the same time. If that’s not the case for your project, you’ll want a “universal” enemy actor that changes its properties based on the enemy type it represents, and then reserve as many instances as your scene allows.

Speed Is Everything

As mentioned earlier, the illusion of movement comes from updating the background tiles every frame, roughly 60 times per second (technically 59.72 Hz on Game Boy, but we won’t get picky). This is crucial when matching enemy movement speed to the scrolling effect. For example, a static obstacle must move at Movement Speed 1 (1 pixel per frame) to stay visually locked to the moving ground rather than drifting at a different speed.

Of course, this can be tweaked. If you add a 0.01-second [Wait] event to the On-Update sequence that controls tile swapping, the ground will update at half speed, around 30 frames per second. This simulates slower movement and gives you more room to play with enemy behavior and interactions.

In my prototype, there are flying enemies that shoot projectiles at random. Their on-update loop looks like this: move left > pick a random horizontal position and fire > keep moving until leaving the screen. Be careful not to overload the game flow with too many simultaneous events, because even in Color Only mode, too much happening at once can cause slowdowns.

Runners of Every Kind

Everything described here assumes a side-scrolling runner using a platformer scene, but the system is extremely flexible. The same principles apply to top down 2D, adventure, or shoot ’em up scenes, with either horizontal or vertical movement. This means you can recreate genre classics like Cannabalt or Jetpack Joyride, but also experiment with downhill skiing games, driving games or anything else that fits the endless runner formula.

Naturally, this approach does limit terrain variation, especially things like slopes or multiple ground heights in platformers. Advanced developers can explore complex systems involving teleportation and camera adjustments within a single scene, or clever actor tricks that turn actors into pits, ramps or other hazards.

As always, the real joy of Game Boy development lies in overcoming tight constraints. Making a game with limited resources isn’t a drawback… it’s where the magic happens!

Back To Top