Here's the second example of a random generator. These are to be used as utilities by the programmer before creating a game. These are not meant to be true programs. Just randomizers that the programmer can tweak for desired results. Now let’s see what possibilities we can have for platformers. While the movement and objects may be different, the core code is still the same. As for objects, what kind of objects are common to all platformers? Having watched a few platformers being played, (and played a few myself) I decided on a few objects that were common to all of them. These include traps, platforms, power ups, and other objects.

Objects Needed:
1 Brick tile
4 Motion Brick tiles (Right, Left, Down, Up)
1 Spring tile
1 Ladder tile
1 Cling tile
1 Rope tile
1 Hole Pit tile
1 Lava Pit tile

I’m going to take a moment to explain what some of these tiles are. The Brick tile represent your main platform. Wherever this occurs there should not be another object. The Motion Bricks are bricks that move in your game. Otherwise known as moving platforms. The Spring tile is exactly what it sounds like. It could be used to bounce your main character up to a height that they might not reach otherwise. A Ladder is something that your character climbs. Whatever they climb to get somewhere is considered a ladder. Now, a Cling tile is a bit different. It’s usually a place your character can hang on to by one hand or both. A Rope tile is something your character swings on like a vine or some such thing. Then we have our first two common traps. The Hole Pit and the Lava Pit. The Hole Pit does not necessarily have to be represented by a tile in your game at all. Normally they’re just big gapes from one platform to the next. Lava Pits on the other hand, are deadly as soon as they are touched by the player. The lava does not necessarily have to be lava, but anything that is deadly to the player.

Objects Continued:
4 Spout tiles (Right, Left, Down, Up)
4 Pop Up Trap tiles (Right, Left, Down, Up)
4 Rotating Spike tiles: A 1 spike, a 2 spike, a 3 spike, and a 4 spike
4 Wall Spike tiles (Right, Left, Down, Up)
2 Cannon tiles: Elevating and Stationary
1 Crumbling Ceiling tile
1 Crumbling Floor tile
1 Spinner tile
1 Boulder tile
1 Coin tile
1 Power Up tile
1 Super Up tile
1 1UP tile
1 Enemy tile

I will go from top to bottom after I explain the Spinners first. I like to think of them as crazy ropes. Sure they have the same function, cross a gap to get to the next safe spot, but they do it differently. These spin around 360 degrees getting faster with each rotation. The faster you spin the farther your flung. Now let’s begin with the Spout tiles. These are different from the Pop ups for the expressed reason that they are timed. The player sees these going on and off and times his actions accordingly. Pop Up traps on the other hand, spring up when the player least expects it. Here they are, walking along a perfectly clear tile, when all of a sudden, Sproing! They get flung off or stabbed in the side and disoriented. Pup ups may or may not have a warning to them when they go off.
They may also have a delay before they’re reset, showing the player how to avoid them next time. The Rotating spikes are an interesting lot. The most basic of these is the 1 spike rotator. What they basically do, is rotate around a single point. The disco ball from Super Mario World is a good example. Wall spikes are stationary objects that wait for the stupid player to run into them. These usually mean instant death, unless the player has an advanced impenetrable armor suit on that can’t be punctured. Now we also have two types of Cannons. Cannons are anything fixed on a point that shoots objects at a player. The two types, stationary and elevating, have different behaviors. The stationary Cannon, for example, continuously shoots at the player and doesn’t change it’s angle. It shoots at timed intervals hoping to strike the player unawares. Elevating cannons, on the other hand, change their angle every so often hoping to catch the player in a constant barrage. They normally go from their lowest to highest point or vice versa.
The Crumbling Floor and Ceiling tiles behave in mainly the same way. Whenever a player walks on or under them, they begin to shake, and then fall. The player could be crushed to death or sent screaming to a bottomless pit. While I’ve not seen an entire stage made of a Crumbling Floor, Crumbling ceiling stages are among the most annoying. These crumbles don’t have to be constant all the time. They may go up and down at intervals. The floor may be slowly sinking, the ceiling may just be dropping bombs on the player. Or the floor could lead to a death trap. Boulders are constant surprises to players. A Boulders basic job is to chase the player at a fixed or slowly incrementing speed to keep them moving. Most of the time it’s instant or near death if the player touches the Boulder. Other times the Boulder may be a boss the player has to destroy. Normally, Boulders drop on one side of the screen and chase the player up or down to a safe spot. I’ve also seen weather act as a sort of timed Boulder that would gently push the player out of sync.
Now that we have most of the obstructions out of the way we can get on with what can help the player. Coins, Power Ups, Super Ups, and 1UPs tiles can all help the player. One of the most basic functions of Coins is to give the player a score. They can also give the player more health, a 1Up if enough are collected, or they can be used as cash to buy upgrades. Coins don’t necessarily have to be coins. I’ve seen bananas, bubbles, missiles, and even glow rings. Power Ups usually change the player’s appearance or costume to either another color or some sort of suit. These Power Ups generally give the player different abilities then what they normally can do or give them better armor. Sometimes the player may have to collect different parts of the Power Up to complete a permanent upgrade. The Super Ups are always temporary. These are normally some sort of invincibility that protects the player for a limited amount of time. Some Super Ups can be collected and stored by the player as a sort of weapon they can activate for a limited amount of time as well. Everybody who’s ever played a game know what 1Ups do. They give the player an extra life so they can continue the game if they die.
One of the most annoying and complexly simple of the objects, is the Enemy tile. Since they come in so many flavors, I’m only going to cover the most simple: the back and forth patroller. The way these guys work, is this. They wander aimlessly around the platform at fixed intervals hoping the player will step in range. When the player does, they blast away like crazy hoping to do enough damage to kill the player. The enemy may try to run away, call for back up, lead the player into a trap. It might sacrifice itself, surrender, feign surrender and wait for the player to pass before shooting him in the back. There are other things the enemy may do, but for the sake of simplicity, I’ll not cover those here. Sometimes though, the enemy may drop helpful items for the player to pick up after they’ve blasted it to pieces. Now that we know what these do, we can attempt to create a “map” if you will, of a platformer.

Set Up
We set the frame properties much like the first one except we want it horizontal instead of vertical. So we set it to 640x256. All of our objects are again 32x32 in size, including the TheMaker object. Since our code may not continuously cover the playground, we need to create a fake ground object. Create a 32x32 Ground tile and within the tile, make it 16x32 (HeightxWidth). So what we have would be half a tile of ground on the bottom side. We stick this into a Quick Backdrop and stretch it to match the frame size. Now we set TheMaker object at the bottom left corner. Again, we classify all the objects as group Neutral. Technically, we want it to do the opposite the Top Down generator. We want it to go from right, up one, left, up one, and then repeat until the top of the stage.

Code It
Now that we know what we want the generator to do, the simple thing left is to code it. Create two groups as before. One for TheMaker object and the other for a RandomLevel. First, we set TheMaker object to the bottom left corner of the screen. Then we have a key press activate TheMaker’s group and the RandomLevel group.

1. Start of Frame
>TheMaker: Set X pos to 0
>TheMaker: Set Y pos to Y Bottom Frame -32
>TheMaker: Set Flag0 on
/Then we activate the groups
2. Upon pressing “1”
>Special: Activate group TheMaker
>Special: Activate group RandomLevel

Now we set TheMaker’s group code for it’s movement. Remember, we want it to go right, up one, left, up one, and then repeat. The group RandomLevel creates the seed for TheMaker object.

Group: TheMaker
/First, we tell it to go to the right.
1. Every 00-10”
+TheMaker: Flag0 is on
>TheMaker: Set X(TheMaker)+32
/Now when it hits the edge, we tell it to go up one space. The Frame Width insures that it obeys this law /no matter what the frame size is.
2. X pos of TheMaker = Frame Width
>TheMaker: Set Flag0 off
>TheMaker: Set Y(TheMaker)-32
>TheMaker: Set Flag1 on
/Flag1 tells TheMaker to go to the left.
3. Every 00-10”
+TheMaker: Flag1 is on
>TheMaker: Set X(TheMaker)-32
/Remember the bug that I told you about in the Map Generator? Well, this is where I noticed it. So to fix it /here, we do the exact same thing. Then we reset the flags again.
4. X pos of TheMaker <= -32
+TheMaker: Flag1 is on
>TheMaker: Set Flag1 off
>TheMaker: Set Y(TheMaker)-32
>TheMaker: Set Flag0 on
/Now, this will tell TheMaker to go all the way to the top of the frame. Since we don’t want excess tiles /eating up the memory, we destroy TheMaker as soon as it goes above the top.
5. Y pos of The Maker <= Y Top Frame -32
>TheMaker: Destroy
/This ensures that TheMaker will not create farther then is necessary. Effectively stopping memory usage.

Now we program the random seed for the objects. It’s basically the same as the map generator. We give each object a random seed. Then we tell TheMaker to add one every 00-10” to it’s value. Then when the object’s A value matches TheMaker’s A value then we put the corresponding object down on the map.

/We do the exact same thing here as we did with the map generator. But because of the multitude of objects /and the copying of names with the only difference being the direction, I’ll only cover one of each multiple. /But make no mistake, you should have the sense to program those in by yourself.
1. Every 00-10”
>Brick: Set Alt Val A to Random( 38 )
>Spring: Set Alt Val A to Random( 38 )
>Ladder: Set Alt Val A to Random( 38 )
>Motion Brick Up: Set Alt Val A to Random( 38 )
>Rope: Set Alt Val A to Random( 38 )
>Cling Spot: Set Alt Val A to Random( 38 )
>Spinner: Set Alt Val A to Random( 38 )
>Hole Pit: Set Alt Val A to Random( 38 )
>Lava Pit: Set Alt Val A to Random( 38 )
>Spout Up : Set Alt Val A to Random( 38 )
>Rotating Spike 1: Set Alt Val A to Random( 38 )
>Wall Spike Up: Set Alt Val A to Random( 38 )
>Elevating Cannon: Set Alt Val A to Random( 38 )
>Stationary Cannon: Set Alt Val A to Random( 38 )
>Crumbling Ceiling: Set Alt Val A to Random( 38 )
>Crumbling Floor: Set Alt Val A to Random( 38 )
>Boulder: Set Alt Val A to Random( 38 )
>Coin: Set Alt Val A to Random( 38 )
>Power Up: Set Alt Val A to Random( 38 )
>Super Up: Set Alt Val A to Random( 38 )
>1UP: Set Alt Val A to Random( 38 )
>Enemy: Set Alt Val A to Random( 38 )
/If your wondering where I’m getting the 38 it’s from the directional objects that I’m ignoring for the /purposes of shortness. For example, I could’ve put in Spout Down and Rotating Spikes 2-4, but that would /take up too much space and attention. I hope your smart enough to put those in yourself otherwise you /wouldn’t have made those extra objects. And if you still don’t get it then try something else, like /photography as a hobby.

Then, just like the map generator, we have TheMaker object place an object down if it matches TheMaker’s A value.


1. Every 00-10”
+TheMaker Alt Val A<=0
>TheMaker: Add 1 to Alt Val A
2. Alt Val A (TheMaker) >=38
>TheMaker: Set Alt Val A to 0
/Now we have to check to see if the tile value matches TheMaker’s value and create one accordingly.
3. Alt Val A (Brick) = Alt Val A (TheMaker)
> Create Brick at 0’0 from TheMaker
4. Alt Val A (Spring) = Alt Val A (TheMaker)
> Create Spring at 0’0 from TheMaker
4. Alt Val A (Ladder) = Alt Val A (TheMaker)
> Create Ladder at 0’0 from TheMaker
5. Alt Val A (Motion Brick Up) = Alt Val A (TheMaker)
> Create Motion Brick Up at 0’0 from TheMaker
6. Alt Val A (Rope) = Alt Val A (TheMaker)
> Create Rope at 0’0 from TheMaker
7. Alt Val A (Cling Spot) = Alt Val A (TheMaker)
> Create Cling Spot at 0’0 from TheMaker
8. Alt Val A (Spinner) = Alt Val A (TheMaker)
> Create Spinner at 0’0 from TheMaker
9. Alt Val A (Hole Pit) = Alt Val A (TheMaker)
> Create Hole Pit at 0’0 from TheMaker
10. Alt Val A (Lava Pit) = Alt Val A (TheMaker)
> Create Lava Pit at 0’0 from TheMaker
11. Alt Val A (Spout Up) = Alt Val A (TheMaker)
> Create Spout Up at 0’0 from TheMaker
12. Alt Val A (Rotating Spike 1) = Alt Val A (TheMaker)
> Create Rotating Spike 1 at 0’0 from TheMaker
13. Alt Val A (Wall Spike Up) = Alt Val A (TheMaker)
> Create Wall Spike Up at 0’0 from TheMaker
14. Alt Val A (Elevating Cannon) = Alt Val A (TheMaker)
> Create Elevating Cannon at 0’0 from TheMaker
15. Alt Val A (Stationary Cannon) = Alt Val A (TheMaker)
> Create Stationary Cannon at 0’0 from TheMaker
16. Alt Val A (Crumbling Ceiling ) = Alt Val A (TheMaker)
> Create Crumbling Ceiling at 0’0 from TheMaker
17. Alt Val A (Crumbling Floor) = Alt Val A (TheMaker)
> Create Crumbling Floor at 0’0 from TheMaker
18. Alt Val A (Boulder) = Alt Val A (TheMaker)
> Create Boulder at 0’0 from TheMaker
19. Alt Val A (Coin) = Alt Val A (TheMaker)
> Create Coin at 0’0 from TheMaker
20. Alt Val A (Power Up) = Alt Val A (TheMaker)
> Create Power Up at 0’0 from TheMaker
21. Alt Val A (Super Up) = Alt Val A (TheMaker)
> Create Super Up at 0’0 from TheMaker
22. Alt Val A (1UP) = Alt Val A (TheMaker)
> Create 1UP at 0’0 from TheMaker
23. Alt Val A (Enemy) = Alt Val A (TheMaker)
> Create Enemy at 0’0 from TheMaker

Of course, we have to control these objects now just like we did in the last generator. First we kill them if they’re touching each other. Then we also kill them if they’re overlapping each other but we only pick one. Remember that each tile belongs to Class Neutral.

1. Collision between TheMaker and Class: Neutral
>Class Neutral: Destroy
2. Class Neutral is overlapping Class Neutral
+ Pick one of Class Neutral
>Class Neural: Destroy

Now run the frame and press key 1 on your keyboard. TheMaker object paints a level that goes right, up, left, up, and back right again. I like to think of two spaces being one screen. You could also think of a two by two grid as one screen. You could also be thinking, hey, I wonder if this could be used for RPG maps? Well, by already looking at it, you see it as top down, so I don’t see why not. If you want a more concentrated map, like one made of just enemies and traps, then create a second group that uses the same code, but with only the tiles you want. Questions? Comments? Something you think I forgot? Post it here. Thanks in advance.