Author Topic: How can I make card game with AGS ?  (Read 459 times)

How can I make card game with AGS ?
« on: 17 Apr 2019, 21:24 »
Has anyone here made a good card game with AGS? Like Black Jack or Solitaire?  :confused: :confused:

If so.  Would you be so kind and share a code or show me how you did it, please?  :-[


What I myself have done so far.  I created first a GUI and add made a sprites and  buttons for the cards  then I added one button wish I named bDeal.



And then I did this:


Code: Adventure Game Studio
  1. function bDeal_OnClick(GUIControl *control, MouseButton button)
  2. {
  3. if (Spil == 0)
  4. {
  5. BCards.Animate(VSPIL, 0, 5, eOnce);
  6. Wait(40);
  7. }
  8. Spil++;
  9.  
  10. BCards.Visible = false;
  11. BDSpil1.Visible = true;
  12. BDSpil2.Visible = true;
  13.  
  14. BSpil1.Visible = true;
  15. BSpil2.Visible = true;
  16.  
  17.  
  18.   if(Vinningspil1 == 0){
  19.    BDSpil1.Animate(VHJARTASPIL, 0, 0, eOnce)&&Heartace;
  20.    BSpil1.Animate(VHJARTASPIL, 5, 0, eOnce)&&Heart6;
  21.   BSpil2.Animate(VHJARTASPIL, 10, 0, eOnce)&&HeartGosi;
  22.   }
  23.   else if(Vinningspil1 == 1)
  24.  {
  25.    BDspil3.Visible = true;
  26.     BDSpil2.Animate(VHJARTASPIL, 10, 0, eOnce)&&HeartGosi;
  27.      BDspil3.Animate(VHJARTASPIL, 3, 0, eOnce)&&Heart4;
  28.  }
  29.  else if (Vinningspil1== 2)
  30.  {  
  31.    BDSpil4.Visible = true;
  32.    BDSpil4.Animate(VHJARTASPIL, 12, 0, eOnce)&&HeartQueen;
  33.    Display("You are Busted");
  34.    
  35.       }
  36.     else if (Vinningspil1== 3)
  37.     {
  38.  
  39.   BDSpil1.Visible = false;
  40.   BDSpil2.Visible = false;
  41.   BSpil1.Visible = false;
  42.   BSpil2.Visible = false;
  43.   BDspil3.Visible = false;
  44.   BDSpil4.Visible = false;
  45.   BCards.Visible = true;
  46.   BCards.Animate(VSPIL, 0, 5, eOnce);
  47. Wait(40);
  48. BCards.Visible = false;
  49.  BDSpil1.Visible = true;
  50.   BDSpil2.Visible = true;
  51.   BSpil1.Visible = true;
  52.   BDSpil1.Animate(VHJARTASPIL, 0, 0, eOnce)&&Heartace;
  53.    BSpil1.Animate(VHJARTASPIL, 5, 0, eOnce)&&Heart6;
  54.   BSpil2.Animate(VHJARTASPIL, 10, 0, eOnce)&&HeartGosi;
  55.   BDspil3.Visible = false;
  56.   BDSpil4.Visible = false;
  57.     }
  58.  Vinningspil1++;
  59.  }
  60.  


« Last Edit: 30 Apr 2019, 00:29 by Fribbi »

selmiak

  • ǝsıɔɹǝxǝ ʞɔǝu puɐ uıɐɹq
    • I can help with play testing
    • I can help with proof reading
    • I can help with translating
    • I can help with web design
    • selmiak worked on a game that won an AGS Award!
    •  
    • selmiak worked on a game that was nominated for an AGS Award!
Re: How can I make card game with AGS ?
« Reply #1 on: 22 Apr 2019, 09:54 »
Some examples for cardgames made with AGS:
Magus: https://www.adventuregamestudio.co.uk/site/games/game/1564/
Hubris: https://www.adventuregamestudio.co.uk/site/games/game/1541/
Dungeon Hands: https://www.adventuregamestudio.co.uk/site/games/game/2219/

Maybe eri0 can help you or show you some of his code he used for dungeon hands.
Codingwise you probably store all cards in an array, shuffle the array and then pick cards one after the other. maybe add a counting variable to know how many cards are played and where in the array you are.

Re: How can I make card game with AGS ?
« Reply #2 on: 23 Apr 2019, 21:54 »
Thanks.  This eri0 may send me message if he is interest to help me if he is still here.

Ghost

  • AGS Baker
  • Here, I light candles.
    • Ghost worked on a game that won an AGS Award!
    •  
    • Ghost worked on a game that was nominated for an AGS Award!
Re: How can I make card game with AGS ?
« Reply #3 on: 23 Apr 2019, 22:46 »
[oops]

Re: How can I make card game with AGS ?
« Reply #4 on: 24 Apr 2019, 12:26 »
@Fribby, I am not dead :P so the code for Dungeon Hands is open sourced on github.

https://github.com/ericoporto/DungeonHands
https://www.adventuregamestudio.co.uk/forums/index.php?topic=55546.0

I will briefly explain, so feel free to ask more details!

My approach for Dungeon Hands was to use three invisible characters with three inventories: Player 1 Hands, Table, and Player 2 Hands. There is an inventory item for each card in a deck - so if a card has two copies, two items exist. This simplified actually showing the cards on screen and allowed using Drag and Drop module to make moving cards around more natural.

I also had an array for each deck and used the items ID to be able to figure out which cards are in deck and correspond to each inventory items. All of this is coded in a script responsible for the "physical" existence and consistency of the cards, and also responsible to be able to shuffle the deck and draw cards.

Now that the cards exist, a different script has to take care of rules. The rules say who starts, what is a turn, and control the symbol to values mapping of the cards.

I would say to first figure out the "physical" part of a virtual deck of cards and then later making the rules work will be a lot easier, specially because you can visually debug :)
« Last Edit: 24 Apr 2019, 12:31 by eri0o »

Re: How can I make card game with AGS ?
« Reply #5 on: 26 Apr 2019, 09:39 »
Thanks EriOo.  First of all I'm glad you are not dead.    :grin:

I shall check on this files later today that
you shared and try to see if it can be useful for me.

I have tried your game.  And I'm still learning how to play it. I have never play card games like this before. It looks very good.

All I was asking was just a simple card game like based on Leisure Suit Larry 1.

Thanks.


Re: How can I make card game with AGS ?
« Reply #6 on: 28 Apr 2019, 17:16 »
Don't know if helpful, but for reference:

Randomizes sounds for the card drawing and stuff
https://github.com/ericoporto/DungeonHands/blob/master/CardSound.asc

Resizes the cards logical width to allow holding more cards in hands than screen limit
https://github.com/ericoporto/DungeonHands/blob/master/InventoryMonitor.asc

Solves the "physical existence" of cards:
https://github.com/ericoporto/DungeonHands/blob/master/Cards.asc

Takes care of rules and turns:
https://github.com/ericoporto/DungeonHands/blob/master/Play.asc

The hacky place where I check for drag and drop events  :-\
https://github.com/ericoporto/DungeonHands/blob/master/room5.asc

Process clicked on a deck then draw card
https://github.com/ericoporto/DungeonHands/blob/master/GlobalScript.asc


Re: How can I make card game with AGS ?
« Reply #7 on: 28 Apr 2019, 22:52 »
Thanks again.  I'm going to study and learn more after the weekend.

I will show my progress on a video later after few days after that.