ActionScript for Random Card Game

Hello helpful user:
I am fairly new to scripting in Flash and am struggling big time with a game I'm creating.
An overiview of the game might help: It is a matching/Poker game. The first level requires one to beat a random pair of cards by selecting cards that are face down on the stage to drag and drop into a designated slot before the time runs out. Second level is a three of a kind, third is a flush, fourth is a straight , fifth is a full house, then four of a kind, then straight flush.
I have the cards already on stage, set as movieclips and instance names reflecting there value (number,suit). You double click to flip the card. Drag and drop. Beat the presented hand to progress forward. Pretty basic, in theory.
Where I am struggling is how to have the cards appear in randomized spots on stage. I also want the "hand to beat" to be selected from the cards already on stage, but randomly(except for the largest pair so it doesn't accidentally make it so you can't win). And lastly, how can I make it so it will recognize when the "hand to beat" has been beaten and one can advance.
I'm afraid it will require 'if' statements and arrays, which I am still learning how to manipulate. I know what I want, but can't visualize the code to accomplish it. Please Help!
Thank You!

sorry, the actionscript i have so far for the pairs is as follows:
bcJs.addEventListener(Event.ENTER_FRAME, goCoverjaxSpade);
function goCoverjaxSpade(e:Event)
    bcJs.x = jaxSpade.x;
    bcJs.y = jaxSpade.y;
bcJs.doubleClickEnabled = true;
bcJs.addEventListener(MouseEvent.DOUBLE_CLICK, goDimbcJs);
function goDimbcJs(e:MouseEvent)
    bcJs.scaleX = .01;
    bcJs.scaleY = .01;
    trace("disappear");
bcJh.addEventListener(Event.ENTER_FRAME, coverbcJh);
function coverbcJh(e:Event)
    bcJh.x = jaxHeart.x;
    bcJh.y = jaxHeart.y;
bcJh.doubleClickEnabled = true;
bcJh.addEventListener(MouseEvent.DOUBLE_CLICK, goDimbcJh);
function goDimbcJh(e:MouseEvent)
    bcJh.scaleX = .01;
    bcJh.scaleY = .01;
    trace("disappear");
jaxHeart.doubleClickEnabled = true;
jaxHeart.addEventListener(MouseEvent.MOUSE_DOWN, itsPressedjaxHeart);
jaxHeart.addEventListener(MouseEvent.MOUSE_UP, letGojaxHeart);
jaxHeart.addEventListener(MouseEvent.DOUBLE_CLICK, reAppearbcJh);
function reAppearbcJh(e:MouseEvent)
    bcJh.scaleX = .99;
    bcJh.scaleY = .99;
    trace("reappear");
function itsPressedjaxHeart(e:MouseEvent)
    e.target.startDrag();
function letGojaxHeart(e:MouseEvent)
    e.target.stopDrag();
    if (jaxHeart.hitTestObject(pairSlot1))
        jaxHeart.x = pairSlot1.x;
        jaxHeart.y = pairSlot1.y;
jaxSpade.doubleClickEnabled = true;
jaxSpade.addEventListener(MouseEvent.DOUBLE_CLICK, reAppearbcJs);
jaxSpade.addEventListener(MouseEvent.MOUSE_DOWN, itsPressedjaxSpade);
jaxSpade.addEventListener(MouseEvent.MOUSE_UP, letGojaxSpade);
function reAppearbcJs(e:MouseEvent)
    bcJs.scaleX = .99;
    bcJs.scaleY = .99;
    trace("reappear");
function itsPressedjaxSpade(e:MouseEvent)
    e.target.startDrag();
function letGojaxSpade(e:MouseEvent)
    e.target.stopDrag();
    if (jaxSpade.hitTestObject(pairSlot2))
        jaxSpade.x = pairSlot2.x;
        jaxSpade.y = pairSlot2.y;

Similar Messages

  • Creating cards for a card game

    So I'm playing with the idea of putting together a simple battle card playing game and am running up against a data/code issue. In the game will be various Cards (potentially hundreds). Each card will have some data describing various its strengths and it may also have complex methods that handle what happens when you play the card.
    (I'd like each Card implementation to represent what the card does, as opposed to who may hold a particular copy of it. For example, I'd like to have a unique JackOfDiamondsCard object that represents info specific to the card. I may then have several Hands that contain CardInstance objects, some of which may have a reference to the unique JackOfDiamondsCard object. Thus the JackOfDiamonsCard could appear in multiple hands.)
    At first glance it's a simple case of having a root Card class and hundreds of children that fill out the details. However, this has the problem that I can create many instances of the same card, which both seems like a waste of memory (since all instances would have exactly the same data) and would make equals() and hashCode() give different results for different instances of the same card.
    One way around this is to put all the cards together into a single enum, but that would quickly grow to an unmanagable (and unreadable) size. I'd also like to be able to group the cards into different packages, or maybe even spread them across several jars.
    Another way may be to turn each card into a singleton and then build an index of all the cards in the jar (maybe using @annotations?) This seems kind of complicated, though, and writing all those singletons would make for a lot of boilerplate in each card class.
    Any ideas on a good way to tackle this? Are singletons the way to go or should I put up with potentially multiple copies of the same card object floating around?

    Mark_McKay wrote:
    The problem is that I need the overriding classes to provide some fairly complex code for each card. In a battle card game, there may be several different things in play that each card could alter in a wacky way. One card may give the player more 'energy points'. Another may strike the opponent with lightning damage. A third may cause one player to randomly steal a card from the other player. A fourth could set up some sort of defense barrier. The wide (and unpredictable) range things that each card may do prevent me from creating just one generic card class. (Although that would work well if the cards only differed by their data).Allow me to introduce some friends of mine. Probably the first one is going to be easiest for you to understand and get working quickly. The last one, probably only any use in conjunction with one of the others here.
    This wacky behaviour is really just another property of the card, like it's suit, or name, or whatever. Behaviours, like data, can often be assigned to objects at runtime, rather than expressed with unweildy inheritance trees.

  • Learning ActionScript for developing FLASH Games

    Hi ,
    I dont whether i can post this question here or there is any other Forum for ActionScript , if so sorry for that .
    Now to the question , I know some what ActionScript like Events , custom UI Components , and classes  as required for simple FLEX development .
    To what extent we need to learn ActionScript to develop Flash Games ??
    Can anybody suggest me as where to start with , what is the correct approach and is there any IDE avialable for that .
    Please share your ideas on this     

    hi,
    Depends on what sort of games you want to write, firstly you will definitely need to become familiar with actionscript, most gaming and 3d engines for flash games are done in pure actionscript. You can developer your games in flex even if you don't uses mxml basically the real power of games is in the code which means actionscript.
    http://pushbuttonengine.com/  a gaming engine for flex/ flash
    http://away3d.com/  3d engine for flex/flash
    http://www.flashrealtime.com/flash-game-library-engine-list/   a site that will have you reading lots of interesting stuff.
    David.

  • Need some OO design pointers for a Java card game I wrote for uni

    Hi,
    I hope a few of you Java sifus can help me understand I dilemma I keep finding myself in.
    I created a card game for a university assignment which works great but its not very OO at the moment.
    I only have 3 classes; a Card class, a Deck class and a Game class which contains all my GUI, AI, Game Controller, Player and Hand code.
    The assignment is over but I feel like enhancing the game, adding animation, multiplayer, several AI agents etc.
    The first thing I have attempted is animation and I've hit a brick wall. I am trying to create animation for my card game whereby I have an animation showing the cards being shuffled and then an animation which shows the cards being dealt to the players. The game then commences. The cards on the GUI then need to be clickable (MouseListeners?) to play the game. If you're running Windows 7, load up 'Hearts' and you'll know what I'm trying to achieve.
    I don't understand how the GUI, and Card class need to be seperated so that its good OO.
    If I give you a few snippets of code, it might explain the situation:
    A snippet of my card class is as follows:
    import javax.swing.*;
    public class Card extends JLabel //Each card is a JLabel
         private int value;                    //variable for the value of the card
         private int suit;                         //variable for the suit of the card
         private ImageIcon frontOfCard;     //Displays the image of the front of the cards
         private ImageIcon backOfCard;          //displays the image of the back of the cards
         public Card (int Value, int Suit, ImageIcon front, ImageIcon back)
              value = Value;               
              suit = Suit;               
              frontOfCard = front;     
              backOfCard = back;
              setIcon(backOfCard);     //To make it non-visible when dealt
         }As you can see, each card is a JPanel. I've been told by some I shouldn't extend JPanel but rather that I should have a BufferedImage/Image instance variable for each card as the image of the card. The thing is that I need each card displayed on the GUI which can then be clickable. When it is clicked, it is moved from the players hand, into the players move. - There needs to be an animation showing this.
    I've got the animation code figured out in terms of how to move 'images' around a screen to make a pleasing animation. The problem is there are no clickable listeners for images, so the Images needs to be inside some container; a widget which can fire events - Hence the reason I have chosen to extend JPanel for my Cards.
    and a Deck class, snippet is as follows:
    public class Deck extends JLabel //The deck will be shown on the GUI as a JLabel
         private ArrayList<Card> standardDeck;
         public Deck()
              standardDeck = new ArrayList<Card>();
              ImageIcon cardBack = new ImageIcon("CardBack.png");
              setPreferredSize(new Dimension(90, 135));
              setIcon(cardBack);
              int cardCount = 0;     //This variable counts the cards. Is used to assist in the name generation of the imageicon filename
              String str; //the imageIcon constructor accepts filenames as strings so this string holds the filename of the corresponding card image file.
              for (int a=0; a<4; a++) //putting the cards into the deck with the specifed parameters
                   for (int b=2; b<15; b++)
                        cardCount+=1;     //incrementing the card count (the card files are named 1-52 as integers)
                        str = Integer.toString(cardCount); //Integer is converted to string type before being added to string str variable
                        str += ".png"; //To complete the image filename, ".png" has to be concatenated to the string.
                        standardDeck.add(new Card(b, a, new ImageIcon(str), cardBack)); //creating and then adding the cards
         }This is how I envisage a new class diagram for my game:
    Card class
    Game Class <--- Holds a Deck instance, Players instances, and the GUI instance
    Player Class <-- Will contains hand 'instances' , but I will not create a seperate 'Hand' Class, I will use an ArrayList.
    AI Class extends Player Class
    GUI Class
    Deck Class <-- contains 52 cards
    My question is, how do I show the Cards on the GUI if my Cards are in a Deck and the Deck is held in the Game class?
    Please note that there are 52 cards, so potentially 52 images on the GUI, each of which needs to be clickable. When clicked, the cards are moved about, e.g. from the deck to a players hand, from a players hand back to the deck, from a players hand to a players current move hand.
    etc
    I've read that GUI, program control, and logic should be seperated. If thats the case, what do I have in my GUI class if the Cards (which are JPanels) are held in the Deck class which in turn is held in the Game class?
    Any help on this would be greatly appreciated!
    I know what I have written may not be fully clear. I find it hard sometimes to fully convey a problem at hand. Please let me know if you don't understand what I've written and I'll do my best to explain further.

    Faz_86 wrote:
    Hi,
    I hope a few of you Java sifus can help me understand I dilemma I keep finding myself in.
    I created a card game for a university assignment which works great but its not very OO at the moment.
    I only have 3 classes; a Card class, a Deck class and a Game class which contains all my GUI, AI, Game Controller, Player and Hand code.
    The assignment is over but I feel like enhancing the game, adding animation, multiplayer, several AI agents etc.
    Admirable, and the best way to learn, doing something that interests you.
    The first thing I have attempted is animation and I've hit a brick wall. I am trying to create animation for my card game whereby I have an animation showing the cards being shuffled and then an animation which shows the cards being dealt to the players. The game then commences. The cards on the GUI then need to be clickable (MouseListeners?) to play the game. If you're running Windows 7, load up 'Hearts' and you'll know what I'm trying to achieve.
    I don't understand how the GUI, and Card class need to be seperated so that its good OO.
    If I give you a few snippets of code, it might explain the situation:
    A snippet of my card class is as follows:
    Do a quick Google on the model view controller pattern. Your listeners are your controllers. Your JPanel, JButton, etc. are your view. The AI, Player, Card and Deck (and presumably something like Score) are your model. Your model should be completely testable and not dependent on either the controller or the view. Imagine you could play the game from the command line. Get that working first. Then you can add all the bells and whistles for the UI.
    import javax.swing.*;
    public class Card extends JLabel //Each card is a JLabel
    (redacted)
    As you can see, each card is a JPanel. I've been told by some I shouldn't extend JPanel but rather that I should have a BufferedImage/Image instance variable for each card as the image of the card. The thing is that I need each card displayed on the GUI which can then be clickable. When it is clicked, it is moved from the players hand, into the players move. - There needs to be an animation showing this.Extending JPanel is fine. As you noted, you need something to add listeners to. However, I would separate things a bit. First, a card really only has a rank and suit (and perhaps an association to either the deck or a player holding the card). The notion of setIcon() is where you are tripping up. The card itself exists in memory. You should be able to test a card without using a UI. Create a separate class (CardPanel or something similar) that has a reference to a Card and the additional methods needed for your UI.
    I've got the animation code figured out in terms of how to move 'images' around a screen to make a pleasing animation. The problem is there are no clickable listeners for images, so the Images needs to be inside some container; a widget which can fire events - Hence the reason I have chosen to extend JPanel for my Cards.
    and a Deck class, snippet is as follows:
    public class Deck extends JLabel //The deck will be shown on the GUI as a JLabel
         private ArrayList<Card> standardDeck;
         public Deck()
              standardDeck = new ArrayList<Card>();
              ImageIcon cardBack = new ImageIcon("CardBack.png");
              setPreferredSize(new Dimension(90, 135));
              setIcon(cardBack);
              int cardCount = 0;     //This variable counts the cards. Is used to assist in the name generation of the imageicon filename
              String str; //the imageIcon constructor accepts filenames as strings so this string holds the filename of the corresponding card image file.
              for (int a=0; a<4; a++) //putting the cards into the deck with the specifed parameters
                   for (int b=2; b<15; b++)
                        cardCount+=1;     //incrementing the card count (the card files are named 1-52 as integers)
                        str = Integer.toString(cardCount); //Integer is converted to string type before being added to string str variable
                        str += ".png"; //To complete the image filename, ".png" has to be concatenated to the string.
                        standardDeck.add(new Card(b, a, new ImageIcon(str), cardBack)); //creating and then adding the cards
         }This is how I envisage a new class diagram for my game:
    I am not an animation buff, so I will assume the above works.
    Card classRemove the UI aspects to this class, and I think you are all set here.
    Game Class <--- Holds a Deck instance, Players instances, and the GUI instancePresumably this is where main() resides. It will certainly have a reference to model classes (player, game, deck, etc.) and likely the master JFrame (or a controller class you create yourself).
    Player Class <-- Will contains hand 'instances' , but I will not create a seperate 'Hand' Class, I will use an ArrayList.Does a player really have multiple hands? It seems to me more of a one-to-one relationship (or a player has a one-to-many relationship to Card).
    AI Class extends Player ClassWhy extend Player? Create a Player interface, then have a HumanPlayer and AIPlayer implementation. Common parts could be refactored out into either a helper class (delegation) or AbstractPlayer (inheritance).
    GUI ClassMy assumption is that this class has a reference to the master JFrame.
    Deck Class <-- contains 52 cards
    Yes. You may end up recycling this class such that a Deck can also function as a Hand for a given player. If there are differences between the two, create an interface and have a Hand and a Deck implementation. Coding to interfaces is a good thing.
    My question is, how do I show the Cards on the GUI if my Cards are in a Deck and the Deck is held in the Game class?You need to pass a reference to the appropriate view class. That is how MVC works. The controller receives a request from the view, dispatches to some model functionality you write (such as GameRulesEngine, Deck, etc.) and returns a result to the view (which could be the same view or a different one, imagine someone clicking 'high scores').
    Please note that there are 52 cards, so potentially 52 images on the GUI, each of which needs to be clickable. When clicked, the cards are moved about, e.g. from the deck to a players hand, from a players hand back to the deck, from a players hand to a players current move hand.
    etc
    That is up to you to write the animation code. In principle, you have a mouse listener, and then you take the appropriate rendering steps.
    I've read that GUI, program control, and logic should be seperated. If thats the case, what do I have in my GUI class if the Cards (which are JPanels) are held in the Deck class which in turn is held in the Game class?
    See above.
    Any help on this would be greatly appreciated!
    You are welcome.
    I know what I have written may not be fully clear. I find it hard sometimes to fully convey a problem at hand. Please let me know if you don't understand what I've written and I'll do my best to explain further.No, you have been doing fine.
    - Saish

  • Question - making rummy card game applet

    Hi, I am not sure if this is the right place to be putting this, if not please let me know. I'm trying to make an applet for the card game rummy for my final project for school. I was wondering if I could get some help on how to load a card image from a file and randomizing the images for the deal button or if not that then I am also trying a much simpler way due to time constraints. I was trying to make two arrays of strings: one for the facevalue of the card and another for the suit value, then randomize those and draw a string to the correct places for the dealt hand. I can't seem to get this to work well so far. Any help is greatly appreciated. Here is the code for the basic gui that I have now.
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.util.Random;
    import java.lang.*;
    public class CardGame extends Applet implements ActionListener {
         Button Deal;
         Button NewGame;
         Button PutDown;
         Color bgColor;
         Color rectColor;
         Image deck;
         MediaTracker mt;
         CheckboxGroup radioGroup;
         Checkbox radio1;
         Checkbox radio2;
         Checkbox radio3;
         Checkbox radio4;
         Checkbox radio5;
         Checkbox radio6;
         Checkbox radio7;
    **Its hard to tell but the arrays are commented out for now.     
         //String[] faceValue = {"ACE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "JACK", "QUEEN", "KING"};
    //     String[] suitValue = {"CLUBS", "HEARTS", "SPADES", "DIAMONDS"};
         public void init()
              setLayout(null);
              mt = new MediaTracker(this);
              Deal = new Button("Deal");
              NewGame = new Button("New Game");
              PutDown = new Button("Put Down");
              Deal.setBounds(750, 450, 75, 25);
              NewGame.setBounds(750, 475, 75, 25);
              PutDown.setBounds(750, 425, 75, 25);
              add(Deal);
              add(NewGame);
              add(PutDown);
              Deal.addActionListener(this);
              NewGame.addActionListener(this);
              PutDown.addActionListener(this);
              radioGroup = new CheckboxGroup();
              radio1 = new Checkbox(" ", radioGroup, false);
              radio2 = new Checkbox(" ", radioGroup, false);
              radio3 = new Checkbox(" ", radioGroup, false);
              radio4 = new Checkbox(" ", radioGroup, false);
              radio5 = new Checkbox(" ", radioGroup, false);
              radio6 = new Checkbox(" ", radioGroup, false);
              radio7 = new Checkbox(" ", radioGroup, false);
              add(radio1);
              add(radio2);
              add(radio3);
              add(radio4);
              add(radio5);
              add(radio6);
              add(radio7);
              radio1.setBounds(143, 525, 10, 10);
              radio2.setBounds(222, 525, 10, 10);
              radio3.setBounds(301, 525, 10, 10);
              radio4.setBounds(380, 525, 10, 10);
              radio5.setBounds(459, 525, 10, 10);
              radio6.setBounds(538, 525, 10, 10);
              radio7.setBounds(617, 525, 10, 10);
         public void Randomize()
              //this is where I need the help mostly.
         public void Stop()
         public void actionPerformed(ActionEvent evt)
         if (evt.getSource()== Deal)
                   setBackground(Color.green); //test
              else
                   Deal.setLabel("Not there, here!"); //another test
         if(radio1.getState())
                   setBackground(Color.blue); //just a test to make sure I know how to use the radio buttons
         public void paint(Graphics g) {
              g.drawString("Welcome to Rummy!!", 300, 50 );
              g.drawRect(100, 100, 600, 440);
              g.drawRect(110, 420, 75, 100);
              g.drawRect(190, 420, 75, 100);
              g.drawRect(270, 420, 75, 100);
              g.drawRect(350, 420, 75, 100);
              g.drawRect(430, 420, 75, 100);
              g.drawRect(510, 420, 75, 100);
              g.drawRect(590, 420, 75, 100);
              g.drawRect(110, 120, 75, 100);
              g.drawRect(190, 120, 75, 100);
              g.drawRect(270, 120, 75, 100);
              g.drawRect(350, 120, 75, 100);
              g.drawRect(430, 120, 75, 100);
              g.drawRect(510, 120, 75, 100);
              g.drawRect(590, 120, 75, 100);
              g.drawRect(300, 250, 75, 100);
              g.drawRect(380, 250, 75, 100);
              g.drawString("A S", 220, 445);
    }

    thanks for that...could I use something like this for the playing card class though:
    public class Card {
    public final static int SPADES = 0, // Codes for the 4 suits.
    HEARTS = 1,
    DIAMONDS = 2,
    CLUBS = 3;
    public final static int ACE = 1, // Codes for the non-numeric cards.
    JACK = 11, // Cards 2 through 10 have their
    QUEEN = 12, // numerical values for their codes.
    KING = 13;
    private final int suit; // The suit of this card, one of the constants
    // SPADES, HEARTS, DIAMONDS, CLUBS.
    private final int value; // The value of this card, from 1 to 11.
    public Card(int theValue, int theSuit) {
    // Construct a card with the specified value and suit.
    // Value must be between 1 and 13. Suit must be between
    // 0 and 3. If the parameters are outside these ranges,
    // the constructed card object will be invalid.
    value = theValue;
    suit = theSuit;
    public int getSuit() {
    // Return the int that codes for this card's suit.
    return suit;
    public int getValue() {
    // Return the int that codes for this card's value.
    return value;
    public String getSuitAsString() {
    // Return a String representing the card's suit.
    // (If the card's suit is invalid, "??" is returned.)
    switch ( suit ) {
    case SPADES: return "Spades";
    case HEARTS: return "Hearts";
    case DIAMONDS: return "Diamonds";
    case CLUBS: return "Clubs";
    default: return "??";
    public String getValueAsString() {
    // Return a String representing the card's value.
    // If the card's value is invalid, "??" is returned.
    switch ( value ) {
    case 1: return "Ace";
    case 2: return "2";
    case 3: return "3";
    case 4: return "4";
    case 5: return "5";
    case 6: return "6";
    case 7: return "7";
    case 8: return "8";
    case 9: return "9";
    case 10: return "10";
    case 11: return "Jack";
    case 12: return "Queen";
    case 13: return "King";
    default: return "??";
    public String toString() {
    // Return a String representation of this card, such as
    // "10 of Hearts" or "Queen of Spades".
    return getValueAsString() + " of " + getSuitAsString();
    } // end class Card
    except now how would I make something like this random I know theres a bunch of work before that, but just curious. Thanks

  • HT5268 I down loaded the new update today, now I can't play my favorite card game..? HELP!

    I downloaded the new java update today, now I can't play my favorite card game : ( Why?

    I don't know.  But you should check to see if there is an update available for the card game.

  • This card game for class

    i had this original program that i got to work then my teacher asked me to add in those gui stuff and now i dont know what to do
    ok here are my methods:
    // Demonstrating the JTextField class.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test extends JFrame {
    private JTextField input,input2;
    private JLabel label1,label2;
    private JButton endButton;
    // set up GUI
    public Test()
    super( "yo" );
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    // construct textfield with default sizing
    label1 = new JLabel("How many players?");
         input = new JTextField( 10 );
         input.setToolTipText ( "How many players?" );
    container.add( label1 );
    container.add( input );
    // construct textfield with default text
    label2 = new JLabel("How many cards?");
    input2 = new JTextField( 10 );
    input2.setToolTipText( "How many cards?" );
    container.add( label2 );
    container.add( input2 );
         endButton = new JButton( "Deal" );
         ButtonHandler ButtonAction = new ButtonHandler();
         endButton.addActionListener(ButtonAction);
    container.add( endButton );
    setSize( 275, 170 );
    setVisible( true );
    public static void main( String args[] )
    Test application = new Test();
    application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    private class ButtonHandler implements ActionListener
         public void actionPerformed( ActionEvent event )
              int players=0;
              int tofinish=1;
              String player;
              player = input.getText();
              String cards;
              cards = input2.getText();
              Cards card;
              card = new Cards();
              for (;tofinish<=players;tofinish++)
              card.clearitout();
              card.deal();
    } // end class TextFieldTest
    and then here is my test program
    import javax.swing.*;
    public class TestCards{
         public static void main (String[] args) {
         Cards card;
         card = new Cards();
         card.clearitout();
         card.deal();

    here is the code for the original game that worked without the gui
    import javax.swing.*;
    import java.util.Random;
    public class Cards extends Object{
    String cards[] = new String[52];
    String cardnames[] = {"ace","two","three","four","five","six","seven","eight","nine","ten","jack","queen","king"};
    String suitnames[] = {"spades","hearts","clubs","diamonds"};
    Random rand = new Random();
    //constructor
    public Cards()
    public void clearitout () {
    for(int index=1;index<=cards.length-1;index++)
    cards[index]=("unused");
    public void deal () {
    int cardsdelt=0;
    int index;
    while(cardsdelt<=5)
    index=(rand.nextInt(52));
    if (cards[index]=="unused")
    cards[index]="used";
    System.out.println(cardnames[identifycard(index)] + " of " + suitnames[identifysuit(index)]);
    cardsdelt++;
    System.out.println("");
    private int identifysuit(int index) {
    int suit=0;
    suit = index/13;
    return suit;
    private int identifycard (int index) {
    int card=0;
    card = index%13;
    return card;

  • Purchased Itunes card..Have balance on my itunes account but trying to use the balance for an APP game...how do i transfer the funds ?

    I had a itunes card purchased for me...I redeemed it on my iphone in the Itunes APP...shows it was redeemed succesfully.Want to use the balance for an APP game i have....SImpsons Tapped out...hoe do i transfer it to it . it keeps using my credit card for purchasing premium items...how do i fix this to the itunes balance...thanks

    So then put any sim card in and restore it.  this isn't rocket science

  • What are the Trading Card Games for iPod touch that doesn't requires Internet connection?

    What are the Trading Card Games for iPod touch that doesn't requires Internet connection? Suggestions, please.

    Why not look at the apps and fine out?
    The odds of someone here knowing that are slim to none.

  • Advice to implement a mouse listener for card game

    Hi,
    I am wondering about the best way to apply a mouselistener in my card game.
    - i only want to listen for 'clicks'
    - I have a JFrame with a JPanel inside. The JPanel has a null layout and many JLabels. The JLabels are the cards, i want to listen for mouse clicks on these 'cards'
    I have seen it is not possible to apply a mouse listener to a JPanel or JLabel so is the most efficient way to apply the listener to the JFrame and then use getComponent () to determine which JLabel has been clicked ? or is there a better way ?
    any thoughts appreciated . .

    hey dubai, thanks for your quick help today, it is much appreciated !
    i know the event should provide a reference to the source, i use the toString to overide the methods in the mouseEvent object and im printing this string to the console. It gives me the correct dimensions within my JPanel of where i clicked but the source is always given as the panel name. Have you any idea why it does not return the name of the JLabel ? I checked out the Action interface, thanks, it cud be very useful to seperate the code by using this.

  • What SDK for  board and card games dev?

    Hi,
    I'm creating board and card games as a hobby. I used Windows
    GDI in the past, but my experience is that my creativity is limited
    by the difficulty in manipulating sprites, transparency and
    scalable graphics. I don't care about 3D. I do care about
    synchronization between audio and video events. I'm currently using
    MS Visual Studio 6. Games available on shockwave.com surely use
    some sort of SDK to help carry these tasks, but I don't know if
    they all use the same or there are many flavors available. In
    extra, I like the fact you can easily develop online versions and
    play online with others. Can it support Mac? I can't spend a lot of
    money and time on new development tools, but maybe there is an
    Adobe product that would allow me to do exactly what I have in
    mind. Can someone tell me which product would best suit my need and
    what should be my expectations.
    Thanks,
    - JP

    I tried to look for clovertown processors, and they are still around 250 each plus there are different models....could you give some models of processors that will work for sure on my 1st gen mac?
    Regarding the video card:
    I tried to use the diamond 1Gb, and on the 8X slot it works basically at half the speed of the x1900 (3dmark 06 gave me 4200 for the x1900 and 2250 for the 4650); so the gain is close to 0
    Under macOs does not work at all; and when i tried to swap the 2 cards to boot the pc and use the 16x rail on the 4650, basically Vista decided to not recognize either card, leaving me with 1 monitor off and one on, without being able to recognize the video card.
    I wonder why the PCI utility on mac does not allow to set which slot will get the 16X....the only place where the x1900 fits is slot 4, so even if the card would work fine , i would have to swap cards and connectors everytime that i wanna play in bootcamp, and this is not the best choice
    Last attempt: tried with a 4870 and looks like the flashing does not always work (read trough 26 pages of a post on another site); so since i don't want to pay 350 for the apple version, i've got a 3rd party 3870 for less than 200 dollars (shame that the 4870 for pc cost the same price), that form the links that you guys gave me, seems the best choice for pro apps and games, compared to the 8800 (and the plus that under bootcamp i can get a second card and use crossfire is a huge plus, especially when the price of this card will go further down!).
    Thanks everyone for giving your suggestions, and hope that this post will help other people that, like me, were trying to update their machine to a better video card

  • Best bridge card game for Mac

    I'm looking for a really good Bridge (card game) app to play against on the computer and learn the game. Anything out there that works with Leopard?
    Also, a good online site would be great as well. Thanks!

    Having tried a number of bridge programs over the years, I have yet to find one that bids and plays well enough to let even a beginner learn about the game. I understand there are some PC versions that are somewhat better, but not one Mac program.
    If I may suggest, however, playing online with other people who are interested in learning is a much better way to go about it, plus it is much more social. [OKBridge|http://www.okbridge.com] is an online bridge club that has been around since [1990|http://www.okbridge.com/new-signup/deployed/about.php] (yeah, it's about as old as the Internet) and has 13,000 members all over the world. I've played at tables with players from four different continents! There are complete beginners and world champions, and a wonderful friendly atmosphere.
    Sad to say, [Pogo|http://www.pogo.com], while free, does not have the same ability to sustain a beginner. You can play, but be prepared to endure frustration. I play chess and backgammon on Pogo, but the bridge rooms are sorely lacking, and the level of play is terrible.

  • HT1353 why are card games that are free on my phone not free for my mac

    I am wondering why the card games that I play for free on my iPhone and iPad (and PC as well) are not free for my Mac through iTunes?  It makes no sense.  I have a new 13" apple macbook pro laptop running yosemite.  

    iTunes does not sell anything for your Mac.
    You would have to buy apps from the Mac Apps store for your Mac.
    They may differ in price, because they are not the same thing.  One is an iOS app, then  other is a computer app.
    The maker of the app can choose what to charge for and what not to charge for.  It could be that one contains ads and the other does not.
    At the end of the day, then maker of the apps decides what to charge or if to charge.

  • Just updated to ubuntu 11.04 which also updated firefox, but this new version has no card games in tools menu. Can I also install an older firefox just to use for free cell? It was the best version I've found and I am in withdrawal.

    hope this is the right place to ask this- but where are the card games in Firefoox 4? I hope they will be available again. thanks

    From the Firefox help files;<BR><BR>
    Try disabling graphics hardware acceleration. Since this feature was added to Firefox, it has gradually improved, but there still are a few glitches.

  • Card games for iMac G5

    I have just purchased a iMac with Intel and am giving my husband my old iMac G5 to take down to his "man cave". It will not be connected to the internet and he would like some games to install on it, preferably card games, that don't require internet access. Is this possible?

    Hi again Sheila,
    Many to choose from...
    http://www.mikesedore.com/mikecard.html
    http://www.macgamesandmore.com/downloadfreemacboardgames.html

Maybe you are looking for

  • Exit for ME21N - Change value on SAVE

    Hi everyone, i'm looking for an exit or BADI in ME21N that allows me to change a specific value in table eket. The idea is that after the SAVE, the field EINDT of EKET must be changed. I had aldready tried to use some exits, but not even one worked.

  • OPINION: site layout

    Hi guys! I would like to receive your comments about the layout on the page linked below. Some, if not most, of the link are not working, but I am concerned about the "first impression" it woud give the user. Any comments will be deeply welcomed!!! T

  • How many characters in users subscriptions of Interactive Report

    Hi, Can someone please help me in Apex 4.1. I would like to know how many characters can I enter in users subscriptions (email address) of Interactive Report and where data are stored. Thanks,

  • Error handling, logging and monitoring business process

    I would like to know more about error handling, logging and monitoring in business process? Can someone give more information on this one?

  • EIS error -  "Unable to set locale for GlobalC"

    Hello all! I'm working with Oracle Performance Scorecard and Oracle Integration Services to generate an Essbase cube. I'm not able no generate my cube from HPS even it doesn't showing any error in the screen but in the HPS log it shows the error mess