Jump to content


Photo

Init_card() For Card Games!


  • Please log in to reply
No replies to this topic

#1 Thor The Thunderboy

Thor The Thunderboy

    GMC Member

  • New Member
  • 125 posts

Posted 06 February 2009 - 04:01 PM

I made this for my casino,but just posted it up because I think somebody could need it...
You just need sprite with all cards there and subimage 0 is the back...Order is clubs,spades,hearts,diamonds and finally two jokers.
It initializes objects subimage with other cards so no matches can be found.
It leaves card_style(eg. 0,Clubs),card_number(eg. card 2 gets 2,jack gets 11) and blackjack_value(2-9 own number 10,jack,queen and king 10,ace 11)...
Forming is easy,just put cards create event init_card(eg. obj_card,true)
Two possibilites to second argument,false,52 cards,no jokers,true,54 cards 2 jokers.(easy to modify for 4)
I think this is the easiest way to make playing cards in GM.
Oh and if you want them open or not open so just put in create event:

[codebox]////////////////////////////////////////////////////////////////////////////
// //
// Forming: init_card(object,jokers) //
// Note:Leaves variables card_style,card_number and blackjack_value. //
// Author: Thor The Thunderboy //
// Terms of use: Give credit if used. //
// //
////////////////////////////////////////////////////////////////////////////

var obj,maxcards;
obj=argument0

if argument1=true
maxcards=54
else
maxcards=52

image_index=1+round(random(maxcards-1));

if instance_number(obj)>maxcards-1
{
instance_destroy()
exit;
}

with(obj)
{
if image_index=other.image_index and !(id=other.id)
{
with(other)
init_card(obj,argument1)
exit;
}
}

if image_index>0 and image_index<14
card_style=1// Clubs

if image_index>13 and image_index<27
card_style=2// Spades

if image_index>26 and image_index<40
card_style=3// Hearts

if image_index>39 and image_index<53
card_style=4// Diamonds

if image_index>52
card_style=5// Jokers

if card_style=5
card_number=14
else
card_number=image_index-(card_style-1)*13

if card_number>9 and card_number<14
blackjack_value=10
else
blackjack_value=card_number

if card_number=1
blackjack_value=11[/codebox]

Enjoy and leave comments please!

Edited by Thor The Thunderboy, 07 February 2009 - 09:09 PM.

  • 0