The level takes shape: a world bigger than the screen
How I built scenery out of reusable tiles, then made the world scroll so it follows the player. The moment the game stops being a single fixed screen and becomes a real level to explore.
The problem
At the start, my game fitted on a single screen. The character could run, but he bumped into the edges very quickly, and there was nowhere to go. I wanted a real level, wide, with ground, walls, hanging platforms, something you want to travel through.
The trouble is that a large level drawn as one enormous image would cost far more than all the memory in the machine. Impossible. The scenery had to be built another way.
The answer: scenery made of reusable bricks
The trick is tiles. Rather than storing a giant image, I cut the scenery into small reusable blocks: a piece of ground, a chunk of wall, a platform. The level then becomes a grid that simply says "ground here, wall there, empty space here". It's light, and it lets me compose scenery far bigger than the screen without saturating memory.
For this first pass I made do with a few test tiles: empty space you can walk through, ground you walk on, a wall that blocks you, a platform. Enough to test the feel before worrying about the artwork.
The world scrolls with the player
The real change is that the character no longer lives in a screen, but in a world. He holds a position in that wide space, and it's the camera's job to show the right part of it at the right moment.
I locked the scrolling to the player: as long as he stays in the centre we follow along, and when he approaches an edge the scenery slides to keep him in view. With a limit at the ends of the level, so as not to reveal the void beyond. This scrolling is still entirely redrawn on every frame, which isn't the most economical method, but at this stage I wanted to validate the feel before optimising.
The result
The character finally wanders through a level bigger than the screen, with ground below, platforms in the air and a wall. The scenery scrolls when you approach the edges. This is the moment the project stopped being a static demo and started to look like the beginning of a game.
Download morteveille-002-tilemap.prg (2.1 KB) - Historical archive of this step. Arrows to move, up to jump, fire to quit. For the current version of the game, see the homepage.
Next step
Collisions with the scenery. For now the player walks through walls and platforms like a ghost. He needs to feel the ground under his feet and to bump into obstacles.
After that comes the STe hardware scroll, to make the scenery slide without having to redraw everything on every frame. But that is another story.
Leave a comment