Original Source
- Original title: RMMV Picture Based Poker / Blackjack / High N Low
- Original author: xabileug
- Original date: May 20, 2020
- Source thread: https://forums.rpgmakerweb.com/threads/rmmv-picture-based-poker-blackjack-high-n-low.121822/
- Source forum path: Game Development Engines > RPG Maker Tutorials > RMMV Tutorials
Summary
I have not found a tutorial for these gambling mini games , probably because they are too easy. I want to share my method. You will be needing 2 scripts by tomoaky (link to his google drive in my signature): 1)TMBtnPicture -> run common events when you click on the picture (you can use Triacontane PictureCallCommon ) 2)TMSimpleWindow -> displays upto 8 message windows simultaneously with custom size and position
Archived First Post
You will be needing 2 scripts by tomoaky (link to his google drive in my signature):
1)TMBtnPicture -> run common events when you click on the picture (you can use Triacontane PictureCallCommon )
2)TMSimpleWindow -> displays upto 8 message windows simultaneously with custom size and position
script call for displaying cards:
//var1 = suit var2 = value
$gameScreen.showPicture(ID, var1 + var2, origin, x, y, width, height, opacity, blend);
// example
$gameScreen.showPicture(6, $gameVariables.value(166) + $gameVariables.value(176), 0, 176, 180, -20, 20, 0, 0);
Remember to assign picture ID with the overlap in mind. Higher ID are displayed on top of the lower ID
script call for randomizing suit and value:
IMPORTANT !! You should assign first a value to the suit and value before using the show picture
const suit = ["d", "h", "c", "s"];
var randomsuit = suit[Math.floor(Math.random() * suit.length)];
$gameVariables.setValue(166, randomsuit);
$gameVariables.setValue(176, Math.floor(Math.random() * 12) + 2);
script call for combining 2 arrays into 1:
const dia = [1,2,3,4,5];
const hea = [6,7,8,9,10];
var deck = dia.concat(hea);
for (var i=0; i<10; i++){
var roll = deck[i];
$gameVariables.setValue(191+i, roll);
}
script call for Fisher Yates Shuffle:
const dia = [1,2,3,4,5];
const hea = [6,7,8,9,10];
var deck = dia.concat(hea);
var i = deck.length, j, temp;
while (--i > 0){
j = Math.floor(Math.random() * (i+1));
temp = deck[j]; deck[j] = deck[i]; deck[i] = temp;}
for (var i=0; i<10; i++){
var roll = deck[i];
$gameVariables.setValue(191+i, roll);
}
script call for card dealing no repeat:
const dia = [1,2,3,4,5];
const hea = [6,7,8,9,10];
var deck = dia.concat(hea);
deck.sort();
for (var i=0; i<11; i++){
var roll = Math.floor(Math.random() * deck.length);
$gameVariables.setValue(191+i, deck.splice(roll,1));
}
All pictures in the save file must be named according to how you defined the array for the suit. for example as : h1, h2...,h14 ; c1,c2,...c14, d1,d2,...d14, s1,s2,...s14,
You can spell out the names as diamond, heart, spade, club.. or anything you like
The values you can start from 1 to 13, or from 2 to 14. I use 2 to 14, as most card games have the ACE as the highest.
Don't forget to have a back card display too!
In case suit is not important in your game design, just name your pictures from 1 to 52. As a standard deck has 52 cards.
Flip effect using move picture: (horizontal)
1. show back side at 255 opacity, positive width
2. show front side at 0 opacity, negative width , assign x coor : origin + image width
3. move back side to 0 opacity, negative width , assign x coor : origin + image width
4. move front side to 255 opacity, positive width
5. Erase back side
**If you want the vertical flip, use height and y coor instead **
script call Quick Erase All Pictures:
for (var i =1; i<max+1; i++){
$gameScreen.erasePicture(i);}
Extra Game Feels:
1. Assign a background picture
2. Assign a BGM
3. Create a dramatic entrance for the Dealing of Cards
4. Assign SE when certain conditions are met (Use voice Actors!)
5. Use items in possession, skills, class, etc. for conditional branches for randomization of values
6. Keep a statistics
Things you should not forget:
1. Reset variables to zero during initialization
2. Use photoshop pixel coordination information when designing the layout of the cards
3. When first designing the mechanics, create a flowchart, then use the show text (message display) every step. When things seems to be buggy, you will know write away which part of the coding / eventing went wrong
4. Use the comment often so that you know what your idea was
GAME 1: POKER (Difficulty : ★ ★ ★ ★ ★ )
Poker is card game where the player with the best combination wins. To make things simpler for this tutorial, I will focus on the Solo Draw 5. The important part here is the checking of combinations. Here is my method:
1. Get 5 pairs of variables. 1st set of 5 will be the that of the player's.. The other set will be for the sort array.
A faster way would be using the sort function:
const dia = [1,2,3,4,5];
const hea = [6,7,8,9,10];
var deck = dia.concat(hea);
deck.sort();
for (var i=0; i<11; i++){
var roll = Math.floor(Math.random() * deck.length);
$gameVariables.setValue(191+i, deck.splice(roll,1));
}
3. After sorting them in ascending order, you will need to check if they are consecutive. Their difference with each other is 1. Because you have arranged them in ascending order, you will just have to check 4 times.
6. Use the Bet to control the random. Higher bet could be lower chance of getting high cards or increase chance of getting doubles
7. EXTRA : You can change how cards are revealed.. All 5, 2 - 1 - 1 - 1, 2 - 2 - 1, or 2 - 1 - 2. You can also add the redraw or Keep / Hold. When a player gets an Ace, they can redraw the other cards maybe?
I will not be discussing 2 Player or Multiplayer Texas Holdem. Creating a smart AI can be very difficult.
GAME 2: BLACKJACK (Difficulty : ★ ★ ★ ☆ ☆ )
Blackjack is a game where you try to reach a sum of 21. A is 1 or 11, 10 and Face Cards have 10. the rest values are as is.
So here's my game design.
1. Player gets two cards. Gets up to 3 hits.
2. Dealer gets 2 cards, 1st card face up, 2nd card face down.
3. Dealer's turn, 2nd card reveal, Gets up to 3 hits.
Troubles Get Around:
A. One of the confusing thing here is how to sum with those A's? Just use 11 if the sum is less than 21, then subtract 10, so it becomes 1 if it exceeds.
B. Until when can the dealer Hit? The normal rule is dealers hit until their sum is at least 17. So they wont hit if the sum of their cards is 18 or up.
4. Possible Results. I found 9 possible results from the game.
- Draw : LOSE
- Player has Blackjack : WIN
- Player Busts : LOSE
- Dealer Busts while Player did not : WIN
- Player has greater sum (NO BUST): WIN
- Dealer has Blackjack : LOSE
- Player has lesser sum (NO BUST) : LOSE
- Player has more Differential : LOSE
- Player has less Differential : WIN
6. Use bet to control the random. Higher bet could be lower chance of getting a blackjack!
GAME 3: HIGH N LOW (Difficulty : ★ ☆ ☆ ☆ ☆ )
In HighNLow, you just need to predict if the next card will be higher or lower than the current card. Here's the flow.
1. Show Deck
2. Reveal Card 1.
3. Ask High or Low
4. Reveal Card 2. If correct call, next round, double bet, repeat #3. If wrong End Game.
Troubles Get Around:
A. What if it's a Draw? To eliminate this possibility, use a conditional branch to check if the random is equal to the current and re-randomize until its not equal. This is why you set the value before using the show picture.
B. How do you compare the call and the result? I prefer to use Strings
6. Use Streak to control the random.. As streak increases, your chances of calling correct slims.
I hope this was helpful so you can build your own card games.
Downloads / Referenced Files
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadCreator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
Topic Summary
Loading summary...