设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 72|回复: 0

[制作教程] RMMV Picture Based Poker / Blackjack / High N Low

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    慵懒
    3 天前
  • 签到天数: 207 天

    连续签到: 1 天

    [LV.7]常住居民III

    3646

    主题

    862

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    21262
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    25800

    灌水之王

    发表于 昨天 21:21 | 显示全部楼层 |阅读模式
    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

    script call for displaying cards:
                    JavaScript:       
    //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);

    In the example gameVarID 166 will store the suit name gameVarID 176 will store the card value. This is snapped to upper left origin with a horizontal flip at 20% the original size and at opacity = 0 (transparent)
    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
                    JavaScript:       
    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);

    We setup the array for the suit and get a random value based on the array size. Next, we randomize the value from 2 to 14 ( range is 12) then add the min which is 2.

    script call for combining 2 arrays into 1:
                    JavaScript:       
    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;$gameVariables.setValue(191+i, roll);}

    Here we utilize the function concat. This will combine the array dia and hea into a new array deck and automatically assign the elements of array deck to 10 game variables from 191 to 200.

    script call for Fisher Yates Shuffle:
                    JavaScript:       
    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;     deck = temp;}for (var i=0; i<10; i++){var roll = deck;$gameVariables.setValue(191+i, roll);}

    This is the modern shuffle and fairest giving equal chances to all possible combinations. This is very useful for the deck shuffle.

    script call for card dealing no repeat:
                    JavaScript:       
    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));}

    Here we utilize the function splice which can add/remove elements of that value from the array. So every time we roll a random number from 0 to the last element of that array, it will automatically be removed.


    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:
                    JavaScript:       
    for (var i =1; i<max+1; i++){$gameScreen.erasePicture(i);}

    If you have 20 pictures used, let max = 20. This is very helpful to remove all pictures at once to conserve lines.

    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.
    Spoiler: Here's an image
    [/quote]
    2. Use insertion Method to sort the 2nd set in ascending order.  By insertion method, for example your array is [A, B, C, D, E], you will compare A and B, if A > B, you swap their position.. Then go with B and C, compare and swap, but since you swap B and C, you need to compare and swap A and B again.  I only have a total of 10 comparisons (1-A, 2-A, 2-B, 3-A, 3-B, 3-C, 4-A, 4-B, 4-C, 4-D)
    Spoiler: Here's an image[quote]

    A faster way would be using the sort function:
                    JavaScript:       
    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));}

    In this example, the new array deck will have its element arranged in ascending order. Both method uses the same algorithm. This is just shorter.

    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.
    Spoiler: Here's an image
    [/quote]
    4. Checking all the other card combinations. This can be tricky, but since you have arranged them in ascending order, the possible combinations are greatly trimmed! Remember, the format is now A B C D E. So if you're checking for a 5 of a kind you just need to check if the card combination is A A A A A like in the image below:
    Spoiler: Here's an image[quote]
    if you are checking 4 of a kind : A A A A E or A B B B BSpoiler: Here's an image
    [/quote]
    Full house will be : A A C C C or A A A D DSpoiler: Here's an image[quote]
    3 of a kind will be : A A A D E or A B B B E or A B C C CSpoiler: Here's an image
    [/quote]
    2 Pairs will will be : A A C C E or A B B C C  or A A C DDSpoiler: Here's an image[quote]
    1 Pair will be : A A C D E or A B B D E or A B C C E or A B C D DSpoiler: Here's an image
    [/quote]
    High Card : E will always be the High Card, and it should be a Jack or better to winSpoiler: Here's an image[quote]
    5. Payout Rules: you can just check the internet for the basic, you can always make your own. I made it such that based on the 10 different combination results here's my multipliers [200,100,50,25,9,6,4,3,2,1]
    Spoiler: Here's an image
    [/quote]
    Here you can see, the multipliers are arranged in increasing order. Since 5 of a kind is the highest, it is the 11th element of the array payout or payout[11]. Royal Flush is the 10th element or payout[10]. So when the variable ID 135 has a value of 11 it will multiply the value of the bet by 200!

    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
    5. Payout is 1.5 the bet if Blackjack, if just a normal win it's x1 your bet.
    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
    Spoiler: Here's an image[quote]
    5. Counting Streaks. I think this is what is fun about HighNLow.. You only get your payout if you Win. If you call wrong, you lose it all. The bet doubles each time you are correct. It literally tests your greed and pushes your luck!
    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.



    本贴来自国际rpgmaker官方论坛作者:xabileug处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/rmmv-picture-based-poker-blackjack-high-n-low.121822/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-10 01:10 , Processed in 0.113292 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表