Game Dev Diary: Run Baby Run v0.03

Game Dev Diary: Run Baby Run v0.03

Now let me just point out a few things here before I begin:

  • Yes, it has been a long time since I did any game dev stuff
  • No, I have no idea if I’ll finish this
  • Run Baby Run is the best game ever

When I was doing Asset Reuse Invaders, the level table I developed for the invaders made me wonder if I could use the same thing to create a level map for a maze. Then I thought, what if I used the levels from Run Baby Run? Then I thought: what if I remade Run Baby Run?

Then 12 year old me’s brain exploded.

I looked into it a bit further, and found that the levels on the Spectrum original were 32 “tiles” wide, and 22 tiles high. On the Spectrum, each tile is 8×8 pixels, but if I use 4×4 tiles, then 32 tiles fit exactly into the 128 pixel wide PICO-8 display.

I had to do it. Or at least try. The normal mapping method used by PICO-8 relies on 8×8 pixel tiles, so I had to create my own – reusing what I’d learned from the level table structure of my invaders game.

function make_levels()
 levels[2] = {
  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
  {1,1,1,0,0,1,1,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,1,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,1},
  {1,1,1,0,0,1,1,1,1,1,1,1,1,1,0,0,1,1,0,0,1,1,1,1,1,1,1,0,0,1,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,1},
  {1,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,1,0,1},
  {1,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,1,0,1},
  {1,1,1,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,1},
  {1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,1},
  {1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1},
  {1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1},
  {1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,1},
  {1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1},
  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1},
  {1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} }
end

Yes, there’s a way of compressing this or something, but I’m not short on space (yet) and it makes it easier to see in the code. I don’t know why I’ve done level 2 (Huddersfield Foundry) first, but it doesn’t matter.

The code to turn this into an image on the screen is:

function draw_level(l)
for row = 1,#levels[l] do
  for col = 1,#levels[l][row] do
   block = levels[l][row][col]
   if block == 1 then
    spr(levelsprites[l],4*col-4,4*row-4)
   end
  end
 end
end

And so, this (from the Spectrum):

Magically becomes this, on PICO-8:

Not bad, eh?

That was my first job. My second task was making the car rotate correctly. I managed that successfully, complicated slightly by creating the car out of two 4×4 pixel sprites rather than one single sprite. There’s a reason for this, which I can’t quite remember now, but has something to do with collisions. Then I ran into issues with collisions, so the rotation code needs to be partially re-written. Regardez:

It’s too fast, obviously, but the big issue is that although head-on collisions with the walls is correctly identified, turning left and right into them is not. I’ve identified this is down to the order in which the rotation and the collision detection take place, but to change it means the rotation code needs re-writing.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.