Taking a break from adventuring to play some minigames is pretty common in RPGs. So let’s take some time today to learn how to event a plinko minigame.
If you’re not familiar with plinko, it is basically a game of chance where a disc or ball is dropped into rows of pegs that cause the ball to randomly bounce down the board until it lands in a slot at the bottom of the board that’s marked with a reward. While we could make it a bit more detailed and act more like pachinko, for this tutorial we’ll keep things simple.
There are a few ways we could set up our plinko minigame, but let’s use a separate plinko map for this tutorial. Since we need a way to get our player to the plinko map, we’ll also need an event that can send them to the right place. And where better to put that event than a casino?
Our transfer event is straightforward, the most important thing being that we make the player transparent when we transfer them to the plinko map so that they won’t be visible or in the way while playing.
Now that we can send our players to the plinko maps, we can get to work on the actual eventing.
Our first version will be a small one that fits our game’s screen. Our ball event that will be moving is placed near the top of the map, with pegs forming a grid under it. In this example we’re using tiles to mark the pegs, but if we wanted it to look nicer we could draw out a real background.
To make it even easier when we’re working on the main event, we can use regions to keep track of how many rows our ball will need to bounce off of.
We just need our ball event to move when told, so we can just set the image and adjust the speed while leaving the rest of the event empty.
For our row of rewards at the bottom of the board, they’ll also be empty of content besides the image and maybe a note to ourselves so that we remember what each reward is meant to be.
For this setup, we can use some of MZ’s icons that we placed into a spritesheet to mark our rewards. We’ll be using markers for a punishment, a small gold reward, a large gold reward, and an item reward.
With our board, ball, and rewards ready, we can start on the autorun event that will control the whole minigame! The first part we need is our ball’s random movement down the board, where it needs to move down a space so that it ‘hits’ a peg and then bounces either left or right down the board. The bounce choice is done by setting a variable to randomly choose between 1 and 2, with a conditional branch right after to have the ball event move in the right direction. So if the variable is set to 1, then the ball will jump left and down, and if the variable is 2, then the ball jumps right and down..
Since the same movement is repeated the whole way down the board, we can stick it all in a loop instead of writing it out over and over. At the end of the loop we just need to add a second variable to count the row the ball is on, and if it’s reached the last row then the loop is broken and our ball can stop moving. This is why we marked the rows with regions earlier, just so we know exactly what number to compare the second variable to.
Once our ball has reached the bottom of the board, we need to properly reward our players. To do that, let’s use conditional branches to compare our ball’s X location to each reward’s X (we don’t need to worry about the Y locations since they’ll all be the same), using the script call $gameMap.event(BallID).x == $gameMap.event(RewardID).x . If the Xs match, then the ball landed on that reward event and we can give the right prize, like so:
After we set up each reward, we can wrap up the minigame by sending our player back to the casino map.
All together, our plinko autorun event looks like this:
Then we just need to playtest and make sure things are working right.
One thing to keep in mind is that since it is all random you could keep getting the same reward over and over, so if you want to make sure a certain reward is working properly you could switch that reward event for the one that you keep getting (though if your luck is as good as mine, that will be when the ball hits a different reward spot).
Now that we’ve made a small board, let’s take a look at a larger one.
If we wanted a larger board with no other changes, we could just adjust the second variable’s conditional branch to add more rows and call it done. But why don’t we add in something that makes the player feel like they have more control of the game: a choice of which ball to use?
Our map will be quite similar to the small board, though obviously with more rows of pegs. The other major addition is two other ball events at the top of the board, so that we now have left, middle, and right starting places.
If we switch to the regions on this map, we can add the numbered rows just so that we know how many times our ball will need to bounce. But this time we’ll also need to mark the left and right sides of the board with two different regions.
Why do we need to do that? Since we’ve added the left and right ball starting points, it’s possible for our ball to bounce right off the board! While we could fix that by making our board even wider, the option we’ll be going with is to check if the ball is on the edge of the play area (and in one of those regions) and force the movement to stay on the board.
Since this board is too long to be fully visible, we should start our autorun by scrolling down so that our player knows what the different rewards are available. After that’s done, we need to let our player choose which ball they want to play with, having them choose either the left, middle, or right ball. Once they’ve made their choice, the other balls disappear and the ball can start moving.
This is where we can do some sneaky eventing though: no matter which ball they choose, only the first ball will actually move! Since each ball looks the same to the player, if we move the left ball to the middle or right position at the same time we make the other two balls transparent then it will look like their chosen ball is the one that will be moving.
With our ball now in the player’s chosen spot, we can get to the looping movement. It will be similar to the small board’s movement, with two major additions: player movement and region checking.
The player movement is simply having the player move down a few spaces each loop, to make sure that the ball event stays visible while it moves. You just need to make sure to set the player to Through On in a move route before the loop starts, either in the map transfer event or at the start of the autorun.
The region checking is to keep the ball from going off the board like we talked about earlier, and is pretty simple. After the random variable is set to 1 or 2, we just need to check our ball’s region and change the variable if it is in region 1 or 2. We can check the region with either the Get Location Info command or with the script call $gameMap.event(ballID).regionId() == # . If the region is 1, then we know that the ball is on the far left of the board and we need it to move right so we can force the variable to be 2. Once we’ve set up another conditional branch to deal with the right side’s region 2, the rest of the movement can proceed like before.
When our ball reaches the end, we’ll need to reward our player like in the small version. Though if we have multiple spots that give the same reward, we can combine their conditional branches by putting || between the script calls, like so:
To wrap up the event, we need to transfer our player back to the casino, making sure to turn their Through back Off so that they can properly interact with the rest of the game.
Once we’ve put it all together, our autorun ends up like this:
Now we just need to playtest and check that it all seems to be working right.
And with that, we can add plinko minigames to our games! Where could you add this to your games? Would you make any changes to better suit your game?
If you spend some time on our boards, you will sooner or later come across the mysterious term parallax mapping and find out, that some people might swear, that parallax mapping is the one true way for a good looking game. While you shouldn't blindly follow advice like that, today we are going to look at parallax mapping.