Every casino in a game needs something for players to throw their money at, so why don’t we make scratchcards for our players to test their luck?
There are quite a few ways lotto scratchcards can differ, so before we even touch the engine we should think about what rules we want the scratchcards to follow. For simplicity's sake, let’s give our player a single spot to scratch and 1-in-6 chance of winning. If they hit the winning spot then they get 10,000 gold, otherwise they get nothing.
Let’s start with an event that both sells our player a scratchcard and controls the scratchcard result. We want each scratchcard to cost gold, so we should nest the main sections in a conditional branch that checks if our player has at least 100 gold. If they don’t, then our scratchcard seller tells them how much gold they need to purchase one.
If our player does have enough gold, then we can give them a ‘yes/no’ option to buy a scratchcard. When they pick ‘yes’, then we can run the scratchcard event. The eventing itself is pretty straightforward, we just need to set a variable to a random number from 1 to 6 and then have a conditional branch check if the variable equals 1 (which is the winning number) or not. If the variable doesn’t equal 1, then our player loses and gets no reward. When the variable does equal 1 our player has won and receives 10,000 gold.
With our Scratchcard Seller event ready, we can playtest and see it in action. First thing that happens is buying the scratchcard and spending that 100 gold.
When we choose to buy a scratchcard, we get a message saying we will use it right away…
And then get our results instantly!
Of course, doing it this way takes control from our player. What if they wanted to save the scratchcard for later? Or what if we wanted to place scratchcards randomly in chests as a reward for exploring certain places? Then we’ll need to make our scratchcards into full items.
Our Scratchcard Seller can remain mostly the same as before, though instead of running the scratchcard event we give the player a scratchcard item.
Our scratchcard item itself is pretty simple. We want to make sure it’s only usable from the Menu Screen (so our player won’t get distracted in battle) and have the item call a common event when used.
Now, we could keep the scratchcard event the same as before, just in a common event instead, but why don’t we give our players some more control? We’ll still need to set a variable to a random number, but alongside that we can have our player choose a number and if it matches the random variable then they win. Having the event completely control if the scratchcard is a winner or not can make our player feel like the game has it out for them if they never win, but by being able to choose a number our player may feel like it was just bad luck instead.
So for our common event we’ll set the random variable to a number between 1 and 6, and then use the Show Choices command to let our player choose a number between 1 and 6 and set a second variable to that chosen number. A conditional branch can check if the two variables match and then reward our player if the variables do match or tell them they lost if the variables don’t match.
When we playtest, we can make sure our scratchcard item is working well. We can also see that maybe leaving the message box in the middle of the screen isn’t the best option, since the choice window can only show 4 of the 6 options at a time.
Once we choose a spot, then our event will tell us whether or not we won.
While playtesting we may have terrible luck and never get a winning scratchcard, so if we want to make sure that things are working well we could include a line in the message box (or use the console.log($gameVariables.value(n)) script call) to check both variables to make sure they are changing properly.
Our scratchcard item works well, but it’s not exactly the prettiest thing to look at right now. So let’s give it a makeover and have an actual scratchcard visible when the chosen spot’s foil is scratched off. There are a few ways we could do this, from moving our player to a special scratchcard map to playing an animation, but for this tutorial let’s use pictures. We’ll need a few pictures to get this to work, including a scratchcard base:
The scratch-off foil, with a few versions with more and more erased so we can have the foil disappear while it’s being scratched:
And finally, the markers to show if the spot is a loser or a winner:
The main scratchcard common event will stay the same as above, with the addition of Show Picture commands. At the start of the event we need to place the base (picture 1) and full foil pictures (pictures 3-8) on the screen. The positions will depend on your resolution and where you want the card to appear on the screen, so your numbers will probably be different than this example.
You may be wondering, why wasn’t picture 2 used? That’s because we’ll use picture 2 to place the winner/loser image behind the foil that’s being scratched off (since higher numbered pictures appear above lower numbers). If we only reveal the spot that our player chooses then we don’t need to place a winner/loser under every spot, only under the spot’s foil that was picked.
When our player chooses a spot, we can place the winner/loser picture (based on if the two variables match or not) under that spot’s foil picture and then copy-paste the foil picture a few times, changing the image each time with a short wait between them so the scratch-off is animated and then fully remove the foil by erasing that picture.
Once we’ve added every other spot’s pictures, we just need to do one more thing: remove all of the pictures at the end of the event. If we forget this step, then we’d be stuck with the scratchcard blocking our view of the game! So once we’ve announced the results and given out the reward, we need to include an Erase Picture command for every picture we used.
With it all set up and ready to go, we can playtest and make sure that our foil parts scratch off correctly to reveal the hidden results. If a certain spot isn’t being erased properly, then we need to double-check the Show Pictures command and make sure that the locations are in the right place.
And with that, you’re ready to add scratchcards to your game! You could build on this base to add in other rewards so that your players have better odds of winning something, or challenge their luck even more by adding extra spots to the cards. How would you add these to your game?
Have you been searching for some retro tiles to create a jail? Do you need some pixelated balloons to bring some extra emotion to your cutscenes? Have you been missing RPG Maker 2003’s hero Alex? If the answer to any of these questions is ‘yes’, then it’s time to check out HITAITARO’s dungeon pack!